Introduction
I have recently bought 2 WD (Western Digital) 2 TB Elements external (USB 2.0) harddrives. I am using them for making Backups, therefore I considered a NAS to be overkill.
This article is pure for me to remember the steps I took to get RAID 1 working, and which devices I have, and what my logs said.
The steps followed are basically the steps as mentioned in [1].
Steps
# yum install mdadm
# apt-get update && apt-get install mdadm
# fdisk /dev/sdb
# fdisk /dev/sdc
# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
# mkfs.ext3 -j -Lraid1 -v -m1 /dev/md0
-- -v = verbose
-- -m1 = percentage of disk used for Root, 1% is more than enough (=20gb)
-- -j = journaling
-- -L = label, in this case "raid1".
# mkdir /mnt/raid1
# mount /dev/md0 /mnt/raid1
# df -H
What my system said in "dmesg", once the drives were under power and plugged into USB ports.# apt-get update && apt-get install mdadm
# fdisk /dev/sdb
# fdisk /dev/sdc
# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
# mkfs.ext3 -j -Lraid1 -v -m1 /dev/md0
-- -v = verbose
-- -m1 = percentage of disk used for Root, 1% is more than enough (=20gb)
-- -j = journaling
-- -L = label, in this case "raid1".
# mkdir /mnt/raid1
# mount /dev/md0 /mnt/raid1
# df -H
[ 1128.092533] usb 2-1.3: new high-speed USB device number 8 using ehci_hcd
[ 1128.189507] Initializing USB Mass Storage driver...
[ 1128.189698] scsi10 : usb-storage 2-1.3:1.0
[ 1128.189820] usbcore: registered new interface driver usb-storage
[ 1128.189824] USB Mass Storage support registered.
[ 1129.190936] scsi 10:0:0:0: Direct-Access WD Ext HDD 1021 2021 PQ: 0 ANSI: 4
[ 1129.192184] sd 10:0:0:0: Attached scsi generic sg2 type 0
[ 1129.195482] sd 10:0:0:0: [sdb] 3907024896 512-byte logical blocks: (2.00 TB/1.81 TiB)
[ 1129.197278] sd 10:0:0:0: [sdb] Write Protect is off
[ 1129.197284] sd 10:0:0:0: [sdb] Mode Sense: 17 00 10 08
[ 1129.199146] sd 10:0:0:0: [sdb] No Caching mode page present
[ 1129.199153] sd 10:0:0:0: [sdb] Assuming drive cache: write through
[ 1129.204101] sd 10:0:0:0: [sdb] No Caching mode page present
[ 1129.204118] sd 10:0:0:0: [sdb] Assuming drive cache: write through
[ 1129.220472] sdb: sdb1
[ 1129.225647] sd 10:0:0:0: [sdb] No Caching mode page present
[ 1129.225653] sd 10:0:0:0: [sdb] Assuming drive cache: write through
[ 1129.225658] sd 10:0:0:0: [sdb] Attached SCSI disk
[ 1131.676246] usb 2-1.8: new high-speed USB device number 9 using ehci_hcd
[ 1131.770350] scsi11 : usb-storage 2-1.8:1.0
[ 1132.770974] scsi 11:0:0:0: Direct-Access WD Ext HDD 1021 2021 PQ: 0 ANSI: 4
[ 1132.772018] sd 11:0:0:0: Attached scsi generic sg3 type 0
[ 1132.773413] sd 11:0:0:0: [sdc] 3907024896 512-byte logical blocks: (2.00 TB/1.81 TiB)
[ 1132.775265] sd 11:0:0:0: [sdc] Write Protect is off
[ 1132.775274] sd 11:0:0:0: [sdc] Mode Sense: 17 00 10 08
[ 1132.777192] sd 11:0:0:0: [sdc] No Caching mode page present
[ 1132.777198] sd 11:0:0:0: [sdc] Assuming drive cache: write through
[ 1132.781952] sd 11:0:0:0: [sdc] No Caching mode page present
[ 1132.781958] sd 11:0:0:0: [sdc] Assuming drive cache: write through
[ 1132.800861] sdc: sdc1
[ 1132.805944] sd 11:0:0:0: [sdc] No Caching mode page present
[ 1132.805950] sd 11:0:0:0: [sdc] Assuming drive cache: write through
[ 1132.805956] sd 11:0:0:0: [sdc] Attached SCSI disk
Originally, the drives came preformatted with NTFS, but that was easily fixed.[ 1128.189507] Initializing USB Mass Storage driver...
[ 1128.189698] scsi10 : usb-storage 2-1.3:1.0
[ 1128.189820] usbcore: registered new interface driver usb-storage
[ 1128.189824] USB Mass Storage support registered.
[ 1129.190936] scsi 10:0:0:0: Direct-Access WD Ext HDD 1021 2021 PQ: 0 ANSI: 4
[ 1129.192184] sd 10:0:0:0: Attached scsi generic sg2 type 0
[ 1129.195482] sd 10:0:0:0: [sdb] 3907024896 512-byte logical blocks: (2.00 TB/1.81 TiB)
[ 1129.197278] sd 10:0:0:0: [sdb] Write Protect is off
[ 1129.197284] sd 10:0:0:0: [sdb] Mode Sense: 17 00 10 08
[ 1129.199146] sd 10:0:0:0: [sdb] No Caching mode page present
[ 1129.199153] sd 10:0:0:0: [sdb] Assuming drive cache: write through
[ 1129.204101] sd 10:0:0:0: [sdb] No Caching mode page present
[ 1129.204118] sd 10:0:0:0: [sdb] Assuming drive cache: write through
[ 1129.220472] sdb: sdb1
[ 1129.225647] sd 10:0:0:0: [sdb] No Caching mode page present
[ 1129.225653] sd 10:0:0:0: [sdb] Assuming drive cache: write through
[ 1129.225658] sd 10:0:0:0: [sdb] Attached SCSI disk
[ 1131.676246] usb 2-1.8: new high-speed USB device number 9 using ehci_hcd
[ 1131.770350] scsi11 : usb-storage 2-1.8:1.0
[ 1132.770974] scsi 11:0:0:0: Direct-Access WD Ext HDD 1021 2021 PQ: 0 ANSI: 4
[ 1132.772018] sd 11:0:0:0: Attached scsi generic sg3 type 0
[ 1132.773413] sd 11:0:0:0: [sdc] 3907024896 512-byte logical blocks: (2.00 TB/1.81 TiB)
[ 1132.775265] sd 11:0:0:0: [sdc] Write Protect is off
[ 1132.775274] sd 11:0:0:0: [sdc] Mode Sense: 17 00 10 08
[ 1132.777192] sd 11:0:0:0: [sdc] No Caching mode page present
[ 1132.777198] sd 11:0:0:0: [sdc] Assuming drive cache: write through
[ 1132.781952] sd 11:0:0:0: [sdc] No Caching mode page present
[ 1132.781958] sd 11:0:0:0: [sdc] Assuming drive cache: write through
[ 1132.800861] sdc: sdc1
[ 1132.805944] sd 11:0:0:0: [sdc] No Caching mode page present
[ 1132.805950] sd 11:0:0:0: [sdc] Assuming drive cache: write through
[ 1132.805956] sd 11:0:0:0: [sdc] Attached SCSI disk
root@micemouse:~# fdisk /dev/sdb
Command (m for help): p
Disk /dev/sdb: 2000.4 GB, 2000396746752 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907024896 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000575ba
Device Boot Start End Blocks Id System
/dev/sdb1 2048 3907024895 1953511424 7 HPFS/NTFS/exFAT
Command (m for help):
Command (m for help): p
Disk /dev/sdb: 2000.4 GB, 2000396746752 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907024896 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000575ba
Device Boot Start End Blocks Id System
/dev/sdb1 2048 3907024895 1953511424 7 HPFS/NTFS/exFAT
Command (m for help):
root@micemouse:~# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm: /dev/sdb1 appears to be part of a raid array:
level=raid0 devices=0 ctime=Thu Jan 1 01:00:00 1970
mdadm: partition table exists on /dev/sdb1 but will be lost or
meaningless after creating array
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: /dev/sdc1 appears to be part of a raid array:
level=raid0 devices=0 ctime=Thu Jan 1 01:00:00 1970
mdadm: partition table exists on /dev/sdc1 but will be lost or
meaningless after creating array
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
Time to grab a cup of something for the next part. Formatting 2 Terabytes takes a while.mdadm: /dev/sdb1 appears to be part of a raid array:
level=raid0 devices=0 ctime=Thu Jan 1 01:00:00 1970
mdadm: partition table exists on /dev/sdb1 but will be lost or
meaningless after creating array
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: /dev/sdc1 appears to be part of a raid array:
level=raid0 devices=0 ctime=Thu Jan 1 01:00:00 1970
mdadm: partition table exists on /dev/sdc1 but will be lost or
meaningless after creating array
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
root@micemouse:~# mkfs.ext3 -j -Lraid1 -v -m1 /dev/md0
mke2fs 1.42 (29-Nov-2011)
fs_types for mke2fs.conf resolution: 'ext3'
Filesystem label=raid1
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
122093568 inodes, 488345040 blocks
4883450 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
14904 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
mke2fs 1.42 (29-Nov-2011)
fs_types for mke2fs.conf resolution: 'ext3'
Filesystem label=raid1
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
122093568 inodes, 488345040 blocks
4883450 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
14904 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
Status
# watch -n 2 cat /proc/mdstat
# tail -f /proc/mdstat
# mdadm --query /dev/md0
maartenl@micemouse:~$ tail -f /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
1953380160 blocks super 1.2 [2/2] [UU]
[>....................] resync = 0.1% (2340864/1953380160) finish=1801.8min speed=18046K/sec
unused devices: <none>
tail: /proc/mdstat: file truncated
Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
1953380160 blocks super 1.2 [2/2] [UU]
[>....................] resync = 0.1% (2340864/1953380160) finish=1801.8min speed=18046K/sec
unused devices: <none>
# tail -f /proc/mdstat
# mdadm --query /dev/md0
maartenl@micemouse:~$ tail -f /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
1953380160 blocks super 1.2 [2/2] [UU]
[>....................] resync = 0.1% (2340864/1953380160) finish=1801.8min speed=18046K/sec
unused devices: <none>
tail: /proc/mdstat: file truncated
Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
1953380160 blocks super 1.2 [2/2] [UU]
[>....................] resync = 0.1% (2340864/1953380160) finish=1801.8min speed=18046K/sec
unused devices: <none>
References
- [1] How to configure usb mybooks as RAID 1
- http://martystech.lucidway.org/2008/01/how-to-configure-usb-mybooks-as.html
- Linux - creating software reaid one arrays
- http://www.cyberciti.biz/faq/linux-creating-software-raid-one-arrays/
- Software RAID HOWTO
- http://tldp.org/HOWTO/Software-RAID-HOWTO.html
- RAID - Wikipedia
- http://en.wikipedia.org/wiki/RAID
- Linux RAID HOWTO
- https://raid.wiki.kernel.org/index.php/Linux_Raid
You know this bait is just too good right?
ReplyDeleteWell, let's respond in a perhaps unexpected manner. Modern linux LVM writes volume metadata on the disk itself, not just in the config files. So even if you unplug them and put them back, in a different box, in the wrong order, they short sort themselves out.
Too bad you're using archaic Linux MD, rather than LVM2... ;-)