HowTo Single Disk to RAID: differenze tra le versioni

Vai alla navigazione Vai alla ricerca
Final edit, everything should be there
(Again, saving, not complete)
(Final edit, everything should be there)
Riga 3: Riga 3:


== Context ==
== Context ==
We sat up a new/old server, [[BitArno]], it has a nice /home of ~6TB backed by a RAID and a separate dick for the / partition. As the drive for the / was tested before getting to production resulting in no errors we tought we didn't need a RAID for it. We installed debian stable 8.1, sat up every service, went to bet to wake up with a hung server refusing to boot.
We sat up a new/old server, [[BitArno]], it has a nice /home of ~6TB backed by a RAID and a separate disk for the / partition. As the drive for the / was tested before getting to production resulting in no errors we tought we didn't need a RAID for it. We installed debian stable 8.1, sat up every service, went to bed just to wake up with a hung server refusing to boot.


An on site check was required, we got there and found out that the / drive was failing to reallocate sectors, we fsck'ed it and it booted. "Great!" that same evening it was failing again and so we decided to switch from a single disk root to a RAID1 backed root expecially because we do use commodity hardware taken from old computers.
An on site check was required, we got there and found out that the / drive was failing to reallocate sectors, we fsck'ed it and it booted. "Great!" that same evening it was failing again and so we decided to switch from a single disk root to a RAID1 backed root expecially because we do use commodity hardware taken from old computers.
Riga 22: Riga 22:
== Step by step guide ==
== Step by step guide ==
Here I'll try to cover step by step the command we used, it has been a while since we did it so I'm not 100% sure I'll remember everything
Here I'll try to cover step by step the command we used, it has been a while since we did it so I'm not 100% sure I'll remember everything
First a layout of the partition befor the RAID
First a layout of the partition befor the RAID
  sda                        8:0    0 114.5G  0 disk   
  sda                        8:0    0 114.5G  0 disk   
Riga 104: Riga 105:
It was time to install grub and regenerate the image to contain LVM and RAID modules, this was the hardest part as we wrongly supposed all the modules were already present.
It was time to install grub and regenerate the image to contain LVM and RAID modules, this was the hardest part as we wrongly supposed all the modules were already present.


We added "domdadm" to  GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub, the line should look something like
cat /etc/default/grub| grep -i cmdli
GRUB_CMDLINE_LINUX_DEFAULT="quiet domdadm"
And we added the modules needed to GRUB_PRELOAD_MODULES in the same file, if the line don't exist create it
GRUB_PRELOAD_MODULES="lvm diskfilter mdraid1x"
Then it was time to install grub on both HDD in the MBR, note that it wasn't needed to specify the boot partition as we were in a chroot
grub-install /dev/sda
grub-install /dev/sde
And just to be sure
update-grub
We exited from the chroot, unmounted everything, rebooted and kept our finger crossed till the password prompt of the root-on-RAID booted system.
This last step I simplified, we made several errors and had to boot into live several times, because we kept forgetting to add the needed modules and command lines arguments
To be sure to boot from the raid root you can edit the grub entry before booting, make sure it's like the following
insmod mdraid1x
Have to be present inside the menuentry section of your os and the linux entry looks similar to
linux  /vmlinuz-3.16.0-4-amd64 root=/dev/mapper/ba--system-root ro  quiet domdadm
As we failed to achieve everithing on the first try we edited the grub command line and the performed grub install from the booted system.
Once we managed to boot we had to finalize the process and add the old drive to the RAID array
We backed up the partition table of the new disk
sfdisk -d /dev/sde > /tmp/savetablesde
Unmounted the automatically-mounted /dev/sda[1,2,5] deactivating the swap and LVM
swapoff /dev/mapper/bitarno-system-swap
vgchange -an bitarno--system
Whiped out all the old drive first 100M
dd if=/dev/zero of=/dev/sda bs=100M count=1
sync
And in the end we copied the partition table on the old disk
sfdisk /dev/sda < /tmp/savetablesde
And we added the partitions to the array
mdadm /dev/md1 --add /dev/sda1
mdadm /dev/md2 --add /dev/sda5
DONE!


You can check the status of the resync of mdadm with
cat /proc/mdstat


== Issues ==
== Issues ==
111

contributi

Menu di navigazione