録画サーバーはコンパクトにまとめようと思っていたので、当初HDDは2.5インチの500Gを選んだ。
どうせネットワーク経由でつながっているし、HDDがいっぱいになってきたらどっかの外付けに移せばいいと思っていたが、色々と問題が出てきたので、サーバーに外付けHDDを刺してとりあえずしばらくの間は凌ぐことに決めた。
買ってきたHDDは、Seagateの2TのHDDで、外付けケースはGroovyの35SATA-U3-BK。これで3台目の外付けケースだが、選んだ理由はUSB3.0対応と、並べた時にカッコ良さそうなデザインだから。
だが、録画サーバーはUSB2.0ポートしか無いので、近いうちにサーバーのリプレースか、それとも他の解決策を模索しなくてはいけないだろう。
LinuxにUSBでHDDを繋ぐのは初めてだったので、いろいろなページを見て調べた。概ね、次の手順になるみたいだ。
1.HDDをつなぎ、dmesgコマンドでデバイスを確認する。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
[2498375.356023] usb 1-8: new high speed USB device using ehci_hcd and address 3 [2498375.488876] usb 1-8: New USB device found, idVendor=04c5, idProduct=2028 [2498375.488884] usb 1-8: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [2498375.488890] usb 1-8: Product: MB86C311 [2498375.488894] usb 1-8: Manufacturer: FUJITSU [2498375.488898] usb 1-8: SerialNumber: 0000000000002023 [2498375.489086] usb 1-8: configuration #1 chosen from 1 choice [2498376.268657] Initializing USB Mass Storage driver... [2498376.268920] scsi2 : SCSI emulation for USB Mass Storage devices [2498376.269090] usb-storage: device found at 3 [2498376.269095] usb-storage: waiting for device to settle before scanning [2498376.269124] usbcore: registered new interface driver usb-storage [2498376.269129] USB Mass Storage support registered. [2498381.268229] usb-storage: device scan complete [2498381.268738] scsi 2:0:0:0: Direct-Access ST2000DM 001-1ER164 CC43 PQ: 0 ANSI: 6 [2498381.270715] sd 2:0:0:0: [sdb] 3907029168 512-byte logical blocks: (2.00 TB/1.81 TiB) [2498381.271586] sd 2:0:0:0: [sdb] Write Protect is off [2498381.271598] sd 2:0:0:0: [sdb] Mode Sense: 1f 00 00 08 [2498381.271606] sd 2:0:0:0: [sdb] Assuming drive cache: write through [2498381.273203] sd 2:0:0:0: [sdb] Assuming drive cache: write through [2498381.273240] sdb: unknown partition table [2498381.293810] sd 2:0:0:0: [sdb] Assuming drive cache: write through [2498381.293839] sd 2:0:0:0: [sdb] Attached SCSI disk |
実行すると、最後の方にこんな感じの文字列がつらつらと並んだ。デバイス名はsdbで認識され、買ったばかりだからパーティションがまだ無いというメッセージが出ている。すでにDOS用にフォーマットされているやつとかだと、この出力が違うらしい。
2.(自分は必要なかったけど)fdiskコマンドで既存のパーティションを消す
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
root@TVRecorder:~# fdisk -l Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x000dde42 Device Boot Start End Blocks Id System /dev/sda1 * 1 60555 486400000 83 Linux /dev/sda2 60555 60802 1983489 5 Extended Partition 2 does not start on physical sector boundary. /dev/sda5 60555 60802 1983488 82 Linux swap / Solaris Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes 255 heads, 63 sectors/track, 243201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdb doesn't contain a valid partition table root@TVRecorder:~# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x6af4f7a1. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): d No partition is defined yet! |
fdisk -lコマンドで既存のパーティションを確認して、DOS向けのが有ればfdiskコマンドで消す。自分は必要なかったが、fdiskのインタラクティブでdコマンドを使いパーティションを消して、wコマンドでそれを確定するみたいだ。
3.パーティションを作る
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
root@TVRecorder:~# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x6af4f7a1. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): p Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes 255 heads, 63 sectors/track, 243201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x6af4f7a1 Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-243201, default 1): #ここでエンター Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201): #ここもエンター Using default value 243201 Command (m for help): p Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes 255 heads, 63 sectors/track, 243201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x6af4f7a1 Device Boot Start End Blocks Id System /dev/sdb1 1 243201 1953512001 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. |
fdiskのインタラクティブでnコマンドを入力し、新規パーティションの作成を選択。その後、プライマリパーティションを作成するのでpコマンド、あとは全領域を使うので、デフォルト値をそのまま使うためにエンター2回。
4.mkdfコマンドでパーティションをフォーマット
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
root@TVRecorder:~# mkfs -t ext3 /dev/sdb1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 122101760 inodes, 488378000 blocks 24418900 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 14905 block groups 32768 blocks per group, 32768 fragments per group 8192 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 31 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. |
普通にext3でフォーマット。NTFSのフォーマットと比べてだいぶ早い気がするが、そこは何かWindowsとLinuxのファイル管理の違い的なアレがあるのだろう。全く詳しくないので、そのうち調べることを決意する。
5.マウント
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# マウントポイントを作成 root@TVRecorder:~# mkdir /var/chinachu_ext/ # マウント root@TVRecorder:~# mount /dev/sdb1 /var/chinachu_ext/ # 確認 root@TVRecorder:~# df Filesystem 1K-ブロック 使用 使用可 使用% マウント位置 /dev/sda1 478768024 444344164 10103860 98% / tmpfs 508488 0 508488 0% /lib/init/rw udev 503632 172 503460 1% /dev tmpfs 508488 0 508488 0% /dev/shm /dev/sdb1 1922858352 200160 1824982592 1% /var/chinachu_ext root@TVRecorder:~# |
dfコマンドで、新しくHDDが認識されていることが確認できる。
ひとまずは、これで終了。あとは取り外すときに、unmoutを忘れないだけだと思う。