Networked Media Tank/快速格式化硬盘、安装NMT

使用下面的命令时必须小心。如果你并不完全明白每个命令是什么意思的话,就不要尝试。

对于经验丰富的Linux用户,本节介绍一种方法在10分钟以内格式化硬盘、安装NMT,而不使用NMT默认的安装向导。对于在格式化1.5T硬盘时总是遇到问题的用户,此方法可能会很有帮助。

开始之前

编辑

下载最新的固件和nmt应用软件。另外还要在NMT上安装Telnet,具体方法请参考Lundman所写的介绍telnet的文章[1]

在Linux系统上

编辑

你可以给硬盘分区,用mkfs生成两个文件系统,然后安装nmt应用软件和一些乱七八糟的东西(创建目录,设置权限等)。在NMT上格式化1.5T硬盘需要2个小时以上,而在我的笔记本上(用的OpenSuse系统)只需要几分钟时间。首先需要创建一个/tmp/newpart.txt文件(如果你的硬盘和我的尺寸不一样,第三个分区的扇区数量需要调整),内容如下:

# partition table of /dev/sdc
unit: sectors

/dev/sdc1 : start=       63, size=   514017, Id=83
/dev/sdc2 : start=   514080, size=  1012095, Id=82
/dev/sdc3 : start=  1526175, size=2928745890, Id=83
/dev/sdc4 : start=        0, size=        0, Id= 0

然后使用以下Linux命令:

linux:/home/linux # sfdisk /dev/sdc < /tmp/newpart.txt
Checking that no-one is using this disk right now ... 
OK                                                    

Disk /dev/sdc: 182401 cylinders, 255 heads, 63 sectors/track
Old situation:                                              
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdc1          0+ 182400  182401- 1465136001    7  HPFS/NTFS
/dev/sdc2          0       -       0          0    0  Empty     
/dev/sdc3          0       -       0          0    0  Empty     
/dev/sdc4          0       -       0          0    0  Empty     
New situation:                                                  
Units = sectors of 512 bytes, counting from 0                   

   Device Boot    Start       End   #sectors  Id  System
/dev/sdc1            63    514079     514017  83  Linux 
/dev/sdc2        514080   1526174    1012095  82  Linux swap / Solaris
/dev/sdc3       1526175 2930272064 2928745890  83  Linux              
/dev/sdc4             0         -          0   0  Empty               
Warning: no primary partition is marked bootable (active)             
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table                             

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)                                                          
linux:/home/linux # mkfs -t ext3 -j /dev/sdc1
mke2fs 1.41.1 (01-Sep-2008)                  
Filesystem label=                            
OS type: Linux                               
Block size=1024 (log=0)                      
Fragment size=1024 (log=0)                   
64256 inodes, 257008 blocks                  
12850 blocks (5.00%) reserved for the super user
First data block=1                              
Maximum filesystem blocks=67371008              
32 block groups                                 
8192 blocks per group, 8192 fragments per group 
2008 inodes per group                           
Superblock backups stored on blocks:            
        8193, 24577, 40961, 57345, 73729, 204801, 221185

Writing inode tables: done                            
Creating journal (4096 blocks): done                  
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
linux:/home/linux # mkfs -t ext3 -j -m 0 -T largefile4 /dev/sdc3   
mke2fs 1.41.1 (01-Sep-2008)                                        
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
357536 inodes, 366093236 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
11173 block groups
32768 blocks per group, 32768 fragments per group
32 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
linux:/home/linux # mount /dev/sdc1 /mnt
linux:/home/linux # dd if=/tmp/syb8634.nmt bs=60 skip=1 | (cd /mnt && tar xfz -)
403805+1 records in
403805+1 records out
24228316 bytes (24 MB) copied, 4.57992 s, 5.3 MB/s
linux:/home/linux # umount /mnt
linux:/home/linux # mount /dev/sdc3 /mnt                                     
linux:/home/linux # cd /mnt                                                  
linux:/mnt # mkdir Photo Video Music     
linux:/mnt # chmod 777 Photo Video Music     
linux:/mnt # cd /home/linux
linux:/home/linux # umount /mnt
linux:/home/linux # /sbin/mkswap /dev/sdc2
Setting up swapspace version 1, size = 518188544 bytes
linux:/home/linux #


在NMT上

编辑

现在将NMT与PC断开,然后重启。在节目源中会出现‘HARD_DISK_A1’和‘HARD_DISK_A3’,那是因为NMT识别到硬盘中没有安装有nmt 应用软件。如果下面命令执行起来有问题,只需要稍稍修改即可。打开Telnet并连接到NMT。

使用以下命令:

# mount
rootfs on / type rootfs (rw)
proc on /proc type proc (rw,nodiratime)
devpts on /dev/pts type devpts (rw)
tmpfs on /tmp type tmpfs (rw)
none on /sys type sysfs (rw)
/dev/sda on /opt/sybhttpd/localhost.drives/USB_DRIVE_A type vfat 

(rw,nodiratime,uid=1001,gid=1001,fmask=0022,dmask=0022,codepage=cp437,iocharset=utf8)
/dev/hda1 on /opt/sybhttpd/localhost.drives/HARD_DISK_A1 type ext3 (rw,data=ordered)
/dev/hda3 on /opt/sybhttpd/localhost.drives/HARD_DISK_A3 type ext3 (rw,data=ordered)
# umount /dev/hda1
# umount /dev/hda3
# cd /opt/sybhttpd/localhost.drives/
# rmdir HARD_DISK_A1 HARD_DISK_A3
# mkdir HARD_DISK
# mount /dev/hda1 /mnt
# mount /dev/hda3 /opt/sybhttpd/localhost.drives/HARD_DISK
# cd HARD_DISK
# chown nmt.nmt Music Photo Video
# cd /
# ln -s /opt/sybhttpd/localhost.drives/HARD_DISK /share
# cd /etc
# /etc/init_nmt start
SHAREROOT=/opt/sybhttpd/localhost.drives/HARD_DISK
Do chmod on /opt/sybhttpd/localhost.drives/HARD_DISK ...
Got /share/Video...
test: 2: unknown operand
test: 2: unknown operand
test: 2: unknown operand
/etc
Starting FTP Server...rm: cannot remove 'ms.pid': No such file or directory
rm: cannot remove 'httpd.pid': No such file or directory
Updating samba workgroup...
Updating samba password...Starting samba/mnt/syb8634/server
# /opt/sybhttpd/default/setups.cgi

此时在设置页面会出现‘内置服务器设置’这一项,可以进去打开任一项服务。

如果想要NMT识别到硬盘中已经安装了nmt应用软件,并且正确地在/mnt和/opt/sybhttpd/localhost.drives/HARD_DISK安装两个分区,下面几条命令会很有用。而仅仅用‘/etc/init_nmt start’来启动NMT往往不是很有效。

# cp /etc/hdinfo /mnt/.hdinfo
# chown nmt.nmt /mnt/.hdinfo

现在在NMT上进入 ‘设置->固件更新->服务器最新软件升级’,就会出现‘典型设置’这一项,如果你还是不放心的话,可以重新安装一次nmt 应用软件。

最后,重启NMT。

# /sbin/reboot