The every day things from Thalamus' life.

Thalamus' Blog

18 April, 2004

Redhat Raid Migration.

Filed under: ComputerStuff_en — Thalamus @ 22:00

Goal : Convert a RedHat installation with one IDE disk – to run a TWO disk config with Raid1 level for security reasons.

Very brief description of the procedure:

* Install new kernel (might be required)

It can be a bit tricky on RedHat systems to know if the kernel itself is compiled with RAID support or not. Reason for this is that RedHat does put quite alot as modules and put it into the initrd.img – my suggestion, make a new kernel so you are sure it is.
A quite simple way of doing this is to install the kernel-source RPM that comes shipped with the kernel RedHat delivers. Go to the
/usr/src/kernel-versionnumber and under here you find a folder ‘configs’. Copy the config that describes your system to /usr/src/kernel-versionnumber directory and name it ‘.config’. This ensures that you use the same config RedHat did when they made the RPM they shipped. RedHat very often backports security features, and other special stuff, so, if the kernel looks a bit ‘old’ – it often aint
really true. In fact – as of this writing RedHat do use alot of 2.6 kernel stuff in 2.4 kernels. This is also why you can get a bit “fucked” when you download stock kernels from and makes the stuff yourself. But, enough about that now. Just now start the normal procedure of makeing your own kernel. I choose to make all the RAID stuff – stright into the kernel. But, that descission I leave up to you. Just make sure that you put the Raid level support stright into the kernel and dont run it as a module.

* After first boot of the new kernel

Now, check your new kernel – see if it boots and works as expected. If it does – then make a note of all the partitions in /etc/fstab. I suggest you write those down to paper somewhere. Ok – you now proved that your new kernel is working. Everything is fine … wh00h00 !

* BG Rescue CD

I did cheat abit here. I choose not to use RedHat’ own bootdisk, but instead downloaded and made me a copy of ‘The BG Rescue CD’. This CD contained all I needed for future use. /dev/mdX devices, mdadm etc. It also didnt ask things like automount etc. So, it was perfect for me at least. URL for this one now make it, and boot from it.

* fdisk/sfdisk

Now – make the new disk and its partitions the same size as the ones you have on the already running disk. This is simplest if both discs are identical. Then it is a simple,

‘sfdisk -d /dev/hda > /tmp/hda.part’
‘sfdisk /dev/hdb < /tmp/hda.part'

But, if not – well, do a ‘man fdisk’ 🙂

* /dev/md?

As stated, BG Rescue CD did have the devices needed already – so, I didnt need to make the Inodes. But, if you dont – its a simple ‘mknod’ command.

‘mknod /dev/md0 b 9 0’
‘mknod /dev/md1 b 9 1’ etc etc.
Run this command for all the metadevices you need (one for each partition you already have on your system)

* mdadm

Now – make the metadevices.

‘mdadm -Cv /dev/md0 -l1 -n2 /dev/hd[ab]1’

etc etc …

Yawn – wait for the discs to sync – you can check that by doing

‘cat /proc/metastat’

* fdisk – again ?!

Now it is time to use ‘fdisk’ to change the type of partition from ‘linux’ to ‘linux autoboot’.

‘fdisk /dev/hda’

The above would have changed the /dev/hda1 to “autoboot”. Do this for all partitions you are going to run as metadevices. And remember to do this for both disks.

* fsck/resize

You now need to check and resize the metadevices – since their size has slightly changed.

‘e2fsck -f /dev/md0’

You should get at warning here – but say ‘no’ to abort. Your really want this. Do this for all your new metadevices.
Now it is time to run the resize – also here – do it for all your new metadevices.

‘resize2fs /dev/md0’.

* mount the discs.

‘mkdir /mnt/sysimage’
‘mount /dev/md0 /mnt/sysimage’
‘mount /dev/md1 /mnt/sysimage/boot’ etc etc.
‘chroot /mnt/sysimage’

* Update important system files … grub, fstab

Edit /etc/grub.conf and /etc/fstab. The thing you really want with grub is to make it installed on both disk’s boot record

‘grub>find /grub/stage1’
‘grub>device (hd0) /dev/hdb’
‘grub>root (hd0,0)’
‘grub>setup (hd0)’

And last but not least – dont forget to update the /etc/fstab with the /dev/mdX devices instead of /etc/hdaX – or whatever it was before.

Good luck guys !

• • •