USBの外付けHDD(RAID 1) をUbuntuサーバにつけてみた。
ボーナスが出たので、外付けHDDを買ってきて、自宅サーバにくっつけてみた。
買ったのはIO-DataのHDC2-U 1.0という1TBのやつ。500GBx2構成で、Raid0とかRaid1にすることができる。
[rakuten:jism:10276519:detail]
・・えーと、有楽町のビックカメラで25500円で買ったんだけどさー、上のリンクだと22600円だってよ・・どーゆーこと?w
まあ、それはさておき、何でこんなものを買ったかというと、自宅サーバにくっつけて息子のビデオとか家族の写真とか、を置くデータライブラリにしたいと思ったから。
そんなイメージです。
WindowsとMacOS X 対応って書いてあったんだけど、ま、きっと使えるさということで買ってみた。
蓋をあけてみると、「Windowsの場合」「Macの場合」なんていう説明書がついてて、よくある「(自己責任で)Linuxいけます」的な説明がまったくなく、ちょっと不安が出てきた。
LinuxにUSBの外付けHDDくっつけるのって実はやったことなかったので、ググりながらやってみましたですよ。
手順は以下のような感じ:
RAID 1 に設定
説明書を読んで、ボタンをプチプチやってみた。ランプがピカピカしたあとで、紫色になった。これでいいのかな?
つないでみる
まずは、壁の蓋をあけて、中に入っている自宅サーバを確認。ふむ。なんか熱いなぁ・・50度越えてるからねぇ・・ファンの向きを変えてみようか・・ まあいいや。とりあえずさしてみよう。
認識したか確認
root@thyme:~# fdisk -l Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x000f26b5 Device Boot Start End Blocks Id System /dev/sda1 * 1 31 248976 83 Linux /dev/sda2 32 19457 156039345 5 Extended /dev/sda5 32 19457 156039313+ 8e Linux LVM Disk /dev/sdb: 500.0 GB, 500055432192 bytes 255 heads, 63 sectors/track, 60794 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00000000 Disk /dev/sdb doesn't contain a valid partition table
おお、/dev/sdbってのが500.0GBとな。素晴らしい。でも、最後の一行がいやだなぁ。説明書には、工場出荷時にFAT32でフォーマット済みってかいてあったのに・・
(書いてて今気づいたけど、RAID 1に設定したときにフォーマットも吹っ飛んだってことかな?)
パーティション作成
root@thyme:~# 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 0xb5e95976. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. The number of cylinders for this disk is set to 60794. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) 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)
へー。Linuxのfdisk ってこういう感じなのか。
nを選んでパーティションを作ります。
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-60794, default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-60794, default 60794): Using default value 60794
全領域primariyの1番ってことでいいかなと思ったので、pの1とやってみた。
ついでによくわからないけど、tってコマンドでLinuxのファイルシステムだよーっと設定してみた。
Command (m for help): t Selected partition 1 Hex code (type L to list codes): L 0 Empty 1e Hidden W95 FAT1 80 Old Minix be Solaris boot 1 FAT12 24 NEC DOS 81 Minix / old Lin bf Solaris 2 XENIX root 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 5 Extended 41 PPC PReP Boot 85 Linux extended c7 Syrinx 6 FAT16 42 SFS 86 NTFS volume set da Non-FS data 7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / . 8 AIX 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility 9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM df BootIt a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e1 DOS access b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS e4 SpeedStor e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ee EFI GPT 10 OPUS 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/ 11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b 12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f1 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f4 SpeedStor 16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fd Linux raid auto 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fe LANstep 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid ff BBT 1c Hidden W95 FAT3 75 PC/IX Hex code (type L to list codes): 83 Changed system type of partition 1 to 83 (Linux) Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: If you have created or modified any DOS 6.x partitions, please see the fdisk manual page for additional information. Syncing disks.
フォーマット
root@thyme:/srv# mkfs -t ext3 /dev/sdb1 mke2fs 1.40.8 (13-Mar-2008) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 30523392 inodes, 122081943 blocks 6104097 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=0 3726 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 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.
マウント
/etc/fstabを書き換えてmount -a でよいらしい。
# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 # /dev/mapper/thyme-root UUID=00000000-0000-0000-0000-000000000000 / ext3 defaults,errors=remount- ro 0 1 # /dev/sda1 UUID=00000000-0000-0000-0000-000000000000 /boot ext3 defaults 0 2 # /dev/mapper/thyme-swap_1 UUID=00000000-0000-0000-0000-000000000000 none swap sw 0 0 /dev/hdb /media/cdrom0 udf,iso9660 user,noauto,exec 0 0 /dev/sdb1 /srv/data ext3 defaults 0 0
root@thyme:/srv# vi /etc/fstab
root@thyme:/srv# mount -a
あ、エラーった、 /srv/data というところにマウントしたかったんだけど、ディレクトリ作ってなかった。
root@thyme:/srv# mkdir /srv/data root@thyme:/srv# mount -a
おっけー^^いけたっぽい。
確認してみよう。
root@thyme:/srv/data# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/thyme-root 141G 3.7G 130G 3% / varrun 1.7G 72K 1.7G 1% /var/run varlock 1.7G 0 1.7G 0% /var/lock udev 1.7G 44K 1.7G 1% /dev devshm 1.7G 0 1.7G 0% /dev/shm /dev/sda1 236M 43M 181M 20% /boot /dev/sdb1 463G 199M 439G 1% /srv/data
できたできた。うしし。ちゃんとミラーリングしてくれてるかどうかはよくわからないけど、
ファイル置いたりしても、置けるし、HDDのエラーランプもつかないので、ミラーリングできてるってことでいいのかなと思う。