View Single Post
Old 8th December 2012, 00:54
pligor pligor is offline
Junior Member
Join Date: Dec 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Arrow raid-1 on ubuntu 12.04

I was following this tutorial:

and I tried to recreate it for ubuntu 12.04 since a lot of things have changed.

Don't be scared with the length of this thread. It is really only the first two pages of the tutorial in a nutshell. It is the procedure I followed while I was trying to create a raid-1 on a running system that now has two identical disk drives.

Please try to follow it to see what is wrong because the tutorial of raid-1 for ubuntu 12.04 would be very useful and now is missing!

This is the procedure (not working yet):
just to see which disks are detected
	cat /proc/diskstats
	sudo lshw -c storage -c disk

Typically is sdb
Format your drive using the disk utility
    In Disk Utily use default Master Boot Record

Take all the partition configuration from sda and put it in sdb. We want an exact copy so this is the first step
	sudo sfdisk -d /dev/sda | sfdisk --force /dev/sdb
To format the drive
  sudo fdisk /dev/sdb

for all partitions (sdb1 and sdb5) do the following:
		Type 't' to change the partition's system id
		Choose partition number
		Type 'L' to list all codes
		choose the code "fd" for Linux raid auto
		finally on the main menu type 'w' to write (save) all the changes and quit
install mdadm
	sudo apt-get install mdadm
To make sure that there are no remains from previous RAID installations on /dev/sdb, we run the following commands:
	sudo mdadm --zero-superblock /dev/sdb1
	sudo mdadm --zero-superblock /dev/sdb5

create raid-array
	//sudo mdadm --create --verbose --auto=yes /dev/md0 --level=1 --raid-devices=2 /dev/sda /dev/sdb	
	sudo mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1
	sudo mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb5
to verify execute this:
	cat /proc/mdstat
	should now show that you have two degraded RAID arrays ([_U] or [U_] means that an array is degraded while [UU] means that the array is ok)
Create filesystems on raid arrays
	//sudo mkfs.ext4 /dev/md0
	sudo mkfs.ext2 /dev/md0
	sudo mkswap /dev/md1

Set new mdadm configuration by first backing up the original
	sudo cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig

execute the line below to save to a temporary file
	sudo mdadm --examine --scan > temporary.txt
	copy and paste at the end(append) of this file:
		sudo nano /etc/mdadm/mdadm.conf
		sudo gedit /etc/mdadm/mdadm.conf
	and of course delete temporary file
		sudo rm temporary.txt
Next we modify /etc/fstab. Comment out the current /, /boot, and swap partitions and
add new lines for them where you replace the UUIDs with /dev/md0 (for the / partition) and /dev/md5 (for the swap partition), AGAIN don't know for third one
	sudo nano /etc/fstab
	sudo gedit /etc/fstab
Next replace /dev/sda1 with /dev/md0 in /etc/mtab:
	sudo nano /etc/mtab
	sudo gedit /etc/mtab
Now up to the GRUB2 boot loader. Create the file /etc/grub.d/09_swraid1_setup as follows
	sudo cp /etc/grub.d/40_custom /etc/grub.d/09_swraid1_setup
	sudo nano /etc/grub.d/09_swraid1_setup
	sudo gedit /etc/grub.d/09_swraid1_setup
	Copy paste this inside:
		menuentry 'Ubuntu, with Linux 3.2' --class ubuntu --class gnu-linux --class gnu --class os {
				    insmod raid
				    insmod mdraid
				    insmod part_msdos
				    insmod ext2
				    set root='(md/0)'
				    echo    'Loading Linux 3.2.0-34-generic ...'
				    linux   /vmlinuz-3.2.0-34-generic root=/dev/md0 ro  quiet
				    echo    'Loading initial ramdisk ...'
				    initrd  /initrd.img-3.2.0-34-generic
	Make sure you use the correct kernel version in the menuentry stanza (in the linux and initrd lines). You can find it out by running
		uname -r

Because we don't use UUIDs for our block devices, open /etc/default/grub...
	sudo nano /etc/default/grub
	sudo gedit /etc/default/grub
...and uncomment the line GRUB_DISABLE_LINUX_UUID=true

set BOOT_DEGRADED to true so that the system can boot from a degraded array without asking 
	sudo nano /etc/initramfs-tools/conf.d/mdadm
	sudo gedit /etc/initramfs-tools/conf.d/mdadm

Now run
	sudo update-grub
Next we adjust our ramdisk to the new situation:
	sudo update-initramfs -u

Now let's mount /dev/md0 (we don't need to mount the swap array /dev/md5):
	sudo mkdir /mnt/md0
	sudo mount /dev/md0 /mnt/md0
Next we change the partition type of /dev/sda5 to Linux raid autodetect and add /dev/sda5 to the /dev/md1 array:
	sudo fdisk /dev/sda
SUGGESTION HERE IS TO CREATE A Linux raid autodetect ONLY FOR THE SWAP PARTITION! Does this makes sense or should we do it for the main partition as well??
But even if we try the first attemtp to add the device to the array:
	sudo mdadm --add /dev/md1 /dev/sda5
does NOT succeeed !

Now we copy the contents of /dev/sda1 to /dev/md0	
Attempt to Copy 1:
	cd /boot
	sudo cp -dpRx . /mnt/md0

Attempt to Copy 2:
	sudo cp -dpRx / /mnt/md0

You should now the md0 array in the output of:
Afterwards we must make sure that the GRUB2 bootloader is installed on both hard drives, /dev/sda and /dev/sdb:
	sudo grub-install /dev/sda
	sudo grub-install /dev/sdb
Reply With Quote
Sponsored Links