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