|
This was my starting file-system configuration. Note that everything on this page is done as root.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 3.7G 247M 3.3G 7% /
varrun 2.0G 96K 2.0G 1% /var/run
varlock 2.0G 0 2.0G 0% /var/lock
udev 2.0G 104K 2.0G 1% /dev
devshm 2.0G 0 2.0G 0% /dev/shm
lrm 2.0G 38M 1.9G 2% /lib/modules/2.6.22-14-generic/volatile
/dev/sda8 153G 193M 145G 1% /home
/dev/sda3 7.4G 145M 6.9G 3% /tmp
/dev/sda6 15G 1.8G 13G 13% /usr
/dev/sda7 15G 166M 14G 2% /usr/local
/dev/sda5 30G 563M 28G 2% /var
# fdisk -l
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000ab54e
Device Boot Start End Blocks Id System
/dev/sda1 * 1 486 3903763+ 83 Linux
/dev/sda2 487 1459 7815622+ 82 Linux swap / Solaris
/dev/sda3 1460 2432 7815622+ 83 Linux
/dev/sda4 2433 30401 224660992+ 5 Extended
/dev/sda5 2433 6322 31246393+ 83 Linux
/dev/sda6 6323 8267 15623181 83 Linux
/dev/sda7 8268 10212 15623181 83 Linux
/dev/sda8 10213 30401 162168111 83 Linux
Disk /dev/sdb: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0003ae13
Device Boot Start End Blocks Id System
So the first thing to do is install some packages.
# apt-get install initramfs-tools mdadm
Load some kernel modules
# modprobe md
# modprobe linear
# modprobe multipath
# modprobe raid0
# modprobe raid1
# modprobe raid5
# modprobe raid6
# modprobe raid10
Copy the partition table from /dev/sda to /dev/sdb and verify the results.
# sfdisk -d /dev/sda | sfdisk /dev/sdb
# fdisk -l
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000ab54e
Device Boot Start End Blocks Id System
/dev/sda1 * 1 486 3903763+ 83 Linux
/dev/sda2 487 1459 7815622+ 82 Linux swap / Solaris
/dev/sda3 1460 2432 7815622+ 83 Linux
/dev/sda4 2433 30401 224660992+ 5 Extended
/dev/sda5 2433 6322 31246393+ 83 Linux
/dev/sda6 6323 8267 15623181 83 Linux
/dev/sda7 8268 10212 15623181 83 Linux
/dev/sda8 10213 30401 162168111 83 Linux
Disk /dev/sdb: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0003ae13
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 486 3903763+ 83 Linux
/dev/sdb2 487 1459 7815622+ 82 Linux swap / Solaris
/dev/sdb3 1460 2432 7815622+ 83 Linux
/dev/sdb4 2433 30401 224660992+ 5 Extended
/dev/sdb5 2433 6322 31246393+ 83 Linux
/dev/sdb6 6323 8267 15623181 83 Linux
/dev/sdb7 8268 10212 15623181 83 Linux
/dev/sdb8 10213 30401 162168111 83 Linux
Change the partition type of the partitions on /dev/sdb to Linux raid autodetect.
# fdisk /dev/sdb
Command (m for help): t
Partition number (1-8): 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
NOTE: Repeat for partition numbers 2,3 and 5-8. Skip 4!
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
If the drive /dev/sdb had been used before, we would issue the following commands to clean up these remains. Again, skip 4.
# mdadm --zero-superblock /dev/sdb1
# mdadm --zero-superblock /dev/sdb2
# mdadm --zero-superblock /dev/sdb3
# mdadm --zero-superblock /dev/sdb5
# mdadm --zero-superblock /dev/sdb6
# mdadm --zero-superblock /dev/sdb7
# mdadm --zero-superblock /dev/sdb8
Create the RAID arrays with the missing placeholder (since the system is currently running):
# mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1
# mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb2
# mdadm --create /dev/md2 --level=1 --raid-disks=2 missing /dev/sdb3
# mdadm --create /dev/md4 --level=1 --raid-disks=2 missing /dev/sdb5
# mdadm --create /dev/md5 --level=1 --raid-disks=2 missing /dev/sdb6
# mdadm --create /dev/md6 --level=1 --raid-disks=2 missing /dev/sdb7
# mdadm --create /dev/md7 --level=1 --raid-disks=2 missing /dev/sdb8
Check array status.
# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md7 : active raid1 sdb8[1]
162168000 blocks [2/1] [_U]
md6 : active raid1 sdb7[1]
15623104 blocks [2/1] [_U]
md5 : active raid1 sdb6[1]
15623104 blocks [2/1] [_U]
md4 : active raid1 sdb5[1]
31246272 blocks [2/1] [_U]
md2 : active raid1 sdb3[1]
7815552 blocks [2/1] [_U]
md1 : active raid1 sdb2[1]
7815552 blocks [2/1] [_U]
md0 : active raid1 sdb1[1]
3903680 blocks [2/1] [_U]
unused devices:
Note: Status of [_U] means degraded, while [UU] means OK.
Next we create filesystems on our RAID arrays, as follow:
- ext3 on /dev/md0
- swap on /dev/md1
- ext3 on /dev/md2
- ext3 on /dev/md4
- ext3 on /dev/md5
- ext3 on /dev/md6
- ext3 on /dev/md7
# mkfs.ext3 /dev/md0
# mkswap /dev/md1
# mkfs.ext3 /dev/md2
# mkfs.ext3 /dev/md4
# mkfs.ext3 /dev/md5
# mkfs.ext3 /dev/md6
# mkfs.ext3 /dev/md7
Update /etc/mdadm/mdadm.conf:
# cd /et/mdadm
# cp mdadm.conf mdadm.conf-20071218
# mdadm --examine --scan >> mdadm.conf
Adjust the system to RAID1. First, mount these partitions.
- /dev/md0
- /dev/md2
- /dev/md4
- /dev/md5
- /dev/md6
- /dev/md7
NOTE: Don't need to mount /dev/md1, the swap array.
# mkdir /mnt/md0
# mkdir /mnt/md2
# mkdir /mnt/md4
# mkdir /mnt/md5
# mkdir /mnt/md6
# mkdir /mnt/md7
# mount /dev/md0 /mnt/md0
# mount /dev/md2 /mnt/md2
# mount /dev/md4 /mnt/md4
# mount /dev/md5 /mnt/md5
# mount /dev/md6 /mnt/md6
# mount /dev/md7 /mnt/md7
Update /etc/ftab:
# cd /etc
# cp fstab fstab-20071218
Replace /dev/sda1 with /dev/md0
Replace /dev/sda2 with /dev/md1
Replace /dev/sda3 with /dev/md2
Replace /dev/sda5 with /dev/md4
Replace /dev/sda6 with /dev/md5
Replace /dev/sda7 with /dev/md6
Replace /dev/sda8 with /dev/md7
Here is the result
proc /proc proc defaults 0 0
/dev/md0 / ext3 defaults,errors=remount-ro 0 1
/dev/md7 /home ext3 defaults 0 2
/dev/md2 /tmp ext3 defaults 0 2
/dev/md5 /usr ext3 defaults 0 2
/dev/md6 /usr/local ext3 defaults 0 2
/dev/md4 /var ext3 defaults 0 2
/dev/md1 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec 0 0
/dev/scd1 /media/cdrom1 udf,iso9660 user,noauto,exec 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec 0 0
Edit /etc/mtab
Replace /dev/sda1 with /dev/md0
Replace /dev/sda2 with /dev/md1
Replace /dev/sda3 with /dev/md2
Replace /dev/sda5 with /dev/md4
Replace /dev/sda6 with /dev/md5
Replace /dev/sda7 with /dev/md6
Replace /dev/sda8 with /dev/md7
Here is the result
/dev/md0 / ext3 rw,errors=remount-ro 0 0
proc /proc proc rw,noexec,nosuid,nodev 0 0
/sys /sys sysfs rw,noexec,nosuid,nodev 0 0
varrun /var/run tmpfs rw,noexec,nosuid,nodev,mode=0755 0 0
varlock /var/lock tmpfs rw,noexec,nosuid,nodev,mode=1777 0 0
udev /dev tmpfs rw,mode=0755 0 0
devshm /dev/shm tmpfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
lrm /lib/modules/2.6.22-14-generic/volatile tmpfs rw 0 0
/dev/md7 /home ext3 rw 0 0
/dev/md2 /tmp ext3 rw 0 0
/dev/md5 /usr ext3 rw 0 0
/dev/md6 /usr/local ext3 rw 0 0
/dev/md4 /var ext3 rw 0 0
securityfs /sys/kernel/security securityfs rw 0 0
/dev/md0 /mnt/md0 ext3 rw 0 0
/dev/md2 /mnt/md2 ext3 rw 0 0
/dev/md4 /mnt/md4 ext3 rw 0 0
/dev/md5 /mnt/md5 ext3 rw 0 0
/dev/md6 /mnt/md6 ext3 rw 0 0
/dev/md7 /mnt/md7 ext3 rw 0 0
Now update the GRUB boot loader. Open /boot/grub/menu.lst and add fallback 1 right after default 0.
default 0
fallback 1
Make a copy of the first kernel stanza, and edit as follows
title Ubuntu 7.10, kernel 2.6.22-14-generic RAID (hd1)
root (hd1,0)
kernel /boot/vmlinuz-2.6.22-14-generic root=/dev/md0 ro quiet splash
initrd /boot/initrd.img-2.6.22-14-generic
quiet
Update the ramdisk.
# update-initramfs -u
Copy the following contents
/dev/sda1 (/) to /mnt/md0
/dev/sda3 (/tmp) to /mnt/md2
/dev/sda5 (/var) to /mnt/md4
/dev/sda6 (/usr) to /mnt/md5
/dev/sda7 (/usr/local) to /mnt/md6
/dev/sda8 (/home) to /mnt/md7
# cp -dpRx / /mnt/md0
# cd /tmp
# cp -dpRx . /mnt/md2
# cd /var
# cp -dpRx . /mnt/md4
# cd /usr
# cp -dpRx . /mnt/md5
# cd /usr/local
# cp -dpRx . /mnt/md6
# cd /home
# cp -dpRx . /mnt/md7
Prepare GRUB (Part 1)
# grub
Probing devices to guess BIOS drives. This may take a long time.
[ Minimal BASH-like line editing is supported. For
the first word, TAB lists possible command
completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub> root (hd0,0)
root (hd0,0)
grub> setup (hd0)
setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 17 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
Done.
grub> root (hd1,0)
root (hd1,0)
grub> setup (hd1)
setup (hd1)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd1)"... 17 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd1) (hd1)1+17 p (hd1,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
Done.
grub> quit
quit
Attempt to reboot. This did not work at first on my system... (bummer)...
Eventually I got it to boot, by using the key to pull up the GRUB boot menu at boot time and editing the boot command, taking away everything after "ro" option.
Change partition types on /dev/sda to Linux raid autodetect.
# fdisk /dev/sda
Command (m for help): t
Partition number (1-8): 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
NOTE: Repeat for partition numbers 2,3 and 5-8. Skip 4!
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Add the /dev/sda* partitions to the RAID arrays
# mdadm --add /dev/md0 /dev/sda1
# mdadm --add /dev/md1 /dev/sda2
# mdadm --add /dev/md2 /dev/sda3
# mdadm --add /dev/md4 /dev/sda5
# mdadm --add /dev/md5 /dev/sda6
# mdadm --add /dev/md6 /dev/sda7
# mdadm --add /dev/md7 /dev/sda8
Now watch the status until all of the raids are good
# watch cat /proc/mdstat
Here is the final status:
# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md7 : active raid1 sda8[0] sdb8[1]
162168000 blocks [2/2] [UU]
md6 : active raid1 sda7[0] sdb7[1]
15623104 blocks [2/2] [UU]
md5 : active raid1 sda6[0] sdb6[1]
15623104 blocks [2/2] [UU]
md4 : active raid1 sda5[0] sdb5[1]
31246272 blocks [2/2] [UU]
md2 : active raid1 sda3[0] sdb3[1]
7815552 blocks [2/2] [UU]
md1 : active raid1 sda2[0] sdb2[1]
7815552 blocks [2/2] [UU]
md0 : active raid1 sda1[0] sdb1[1]
3903680 blocks [2/2] [UU]
unused devices:
Adjust /etc/mdadm/mdadm.conf to the new situation
# mdadm --examine --scan >> /etc/mdadm/mdadm.conf
# cat /etc/mdadm/mdadm.conf
# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#
# by default, scan all partitions (/proc/partitions) for MD superblocks.
# alternatively, specify devices to scan, using wildcards if desired.
DEVICE partitions
# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes
# automatically tag new arrays as belonging to the local system
HOMEHOST
# instruct the monitoring daemon where to send mail alerts
MAILADDR root
# definitions of existing MD arrays
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=7534430a:7681e480:cafbc0c5:d84d4d31
ARRAY /dev/md1 level=raid1 num-devices=2 UUID=5b183767:a5549ac0:cafbc0c5:d84d4d31
ARRAY /dev/md2 level=raid1 num-devices=2 UUID=092bb420:9bfe6d78:cafbc0c5:d84d4d31
ARRAY /dev/md4 level=raid1 num-devices=2 UUID=b02e485c:17d38bfa:cafbc0c5:d84d4d31
ARRAY /dev/md5 level=raid1 num-devices=2 UUID=31cd571b:8d1a053f:cafbc0c5:d84d4d31
ARRAY /dev/md6 level=raid1 num-devices=2 UUID=01dc52f6:c97e68c1:cafbc0c5:d84d4d31
ARRAY /dev/md7 level=raid1 num-devices=2 UUID=6bec7088:fb173b2b:cafbc0c5:d84d4d31
Prepare GRUB (Part 2)
We want to go back and edit /boot/grub/menu.lst again. Make a copy of the first stanza (hd1,0) and put it after the first stanza. Edit this copy and change hd1 to hd0. Comment out the other stanzas. Then find this line:
# kopt=root=UUID=54737ca9-97e2-4c41-a9cb-0d9869a34746 ro
Make it look like this:
# kopt=root=/dev/md0 ro
So this is what we have for stanzas now:
title Ubuntu 7.10, kernel 2.6.22-14-generic RAID (hd1)
root (hd1,0)
kernel /boot/vmlinuz-2.6.22-14-generic root=/dev/md0 ro quiet splash
initrd /boot/initrd.img-2.6.22-14-generic
quiet
title Ubuntu 7.10, kernel 2.6.22-14-generic RAID (hd0)
root (hd0,0)
kernel /boot/vmlinuz-2.6.22-14-generic root=/dev/md0 ro quiet splash
initrd /boot/initrd.img-2.6.22-14-generic
quiet
Save changes and update the ramdisk
# update-initramfs -u
Now reboot:
# reboot
References
I found this great article that gave me complete guidance! |