administration:system-mirror
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
administration:system-mirror [2008/03/12 18:40] – damir | administration:system-mirror [2009/03/16 14:00] (current) – damir | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Mini Raid Software howto ====== | ====== Mini Raid Software howto ====== | ||
- | ==== Prologue ==== | + | ===== Prologue |
- | * with the instructions that follow we move a complete root system disk from bare partitions to a raid 1 software layer. | + | * with the instructions that follow we move a complete root system disk from bare partitions to a RAID 1 software layer. |
- | * all the work is done without putting the server off-line. | + | |
- | * only one reboot process is needed if the disks are already installed on the server. | + | * **all the work is done without putting the server off-line, but it's better to stop the services before starting the copy of the files from the old disk to the new one** |
+ | * only one reboot process is needed if the disks are already installed on the server | ||
+ | ==== The second disk is already installed and the partition Table is empty ==== | ||
- | ==== Preparing | + | |
- | We will move the system disk of a linux system from a standard partition scheme, to a raid 1 system withous | ||
- | === We suppose that the second disk is already installed and that the partition Table is empty === | ||
* /dev/sda: is the original disk from where the system boot | * /dev/sda: is the original disk from where the system boot | ||
* /dev/sdb: is the second disk | * /dev/sdb: is the second disk | ||
- | \\ | + | |
- | * we need to create the correct partitions we need: | + | ==== create the correct partitions we need ==== |
* 100 MB for the boot partition | * 100 MB for the boot partition | ||
* 2Gbyte for the swap partition (there' | * 2Gbyte for the swap partition (there' | ||
Line 48: | Line 48: | ||
- | * now we need to create the raid 1 partitions for the boot and the other partitions | + | ==== now we need to create the raid 1 partitions for the boot and the other partitions |
* /dev/md0 will be the first raid 1 partition used only by the /boot directory | * /dev/md0 will be the first raid 1 partition used only by the /boot directory | ||
* /dev/md1 will be the raid 1 disk used for everything else | * /dev/md1 will be the raid 1 disk used for everything else | ||
Line 55: | Line 55: | ||
mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1 | mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1 | ||
mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb3 | mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb3 | ||
+ | echo ' | ||
+ | mdadm --detail --scan >> / | ||
+ | </ | ||
+ | |||
+ | * we created the raid devices (in downgraded mode) | ||
+ | * the informations about the devices is written in the **/ | ||
+ | |||
+ | ==== the /dev/md0 partition will be used flat for the boot partitions ==== | ||
+ | * so we can format it right now | ||
+ | < | ||
+ | mkfs.ext3 /dev/md0 | ||
+ | </ | ||
+ | |||
+ | ==== the /dev/md1 partition will be splitted using the lvm layer ==== | ||
+ | * if the virtual disk **vg1** is already used, please change the example below | ||
+ | < | ||
+ | pvcreate /dev/md1 | ||
+ | vgcreate vg1 /dev/md1 | ||
+ | lvcreate --name root -L 4G vg1 | ||
+ | lvcreate --name usrlocal -L 4G vg1 | ||
+ | lvcreate --name var -L 4G vg1 | ||
+ | lvcreate --name export -L <bigger than the disk>G vg1 | ||
+ | lvcreate --name export -l <extens available reported by the previous command> vg1 | ||
+ | </ | ||
+ | * we assigned the /dev/md1 partition to an lvm disk and we created different lvm partitions | ||
+ | |||
+ | * now we need to format the partitions just created | ||
+ | < | ||
+ | mkfs.ext3 / | ||
+ | mkfs.ext3 / | ||
+ | mkfs.ext3 / | ||
+ | mkfs.ext3 / | ||
+ | </ | ||
+ | |||
+ | ==== time to mount the partitions to copy the system from the original disk ==== | ||
+ | < | ||
+ | mkdir /1 | ||
+ | mount / | ||
+ | cd /1 | ||
+ | mkdir -p boor usr/local var export proc sys dev | ||
+ | mount /dev/md0 boot | ||
+ | mount / | ||
+ | mount / | ||
+ | mount / | ||
+ | </ | ||
+ | |||
+ | * ok, the new partitions are mounted and ready to receive all the contents | ||
+ | < | ||
+ | rsync -aH --exclude=/ | ||
+ | </ | ||
+ | * wait until the system is copied | ||
+ | | ||
+ | |||
+ | ==== Create the new initrd image file ==== | ||
+ | * after the copy we need to create a new initrd and change the information in the **/ | ||
+ | * avoid the use of label inside this file, instead use the physical name of the devices | ||
+ | * you should have something like that: | ||
+ | < | ||
+ | vi / | ||
+ | |||
+ | / | ||
+ | / | ||
+ | tmpfs / | ||
+ | devpts | ||
+ | sysfs / | ||
+ | proc /proc | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | # | ||
+ | LABEL=SWAP-sdb2 | ||
+ | </ | ||
+ | * the reference to the swap partition on the first disk must be commented | ||
+ | |||
+ | * now we can create the new initrd image **include also the serial-ata module, if necessary** | ||
+ | < | ||
+ | mkinitrd --preload raid1 --preload raid456 --preload sata_nv --fstab / | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Edit the grub configuration file in the original disk ==== | ||
+ | * change the file adding a instance forthe new disk | ||
+ | * this is the original instance: | ||
+ | < | ||
+ | title Fedora (2.6.23.15-80.fc7) RAID | ||
+ | root (hd0,0) | ||
+ | kernel / | ||
+ | initrd / | ||
+ | </ | ||
+ | * must be changed in: | ||
+ | < | ||
+ | title Fedora (2.6.23.15-80.fc7) RAID | ||
+ | root (hd0,0) | ||
+ | kernel / | ||
+ | initrd / | ||
+ | |||
+ | title Fedora (2.6.23.15-80.fc7) RAID | ||
+ | root (hd1,0) | ||
+ | kernel / | ||
+ | initrd / | ||
+ | </ | ||
+ | |||
+ | * leave the default boot partition to the old disk, so in case of trouble we can reboot | ||
+ | |||
+ | ==== Install the boot loader on the second disk ==== | ||
+ | * we need to install the grub boot loader on the new disk using the **grub** command | ||
+ | * avoid the **grub-install** command, doesn' | ||
+ | |||
+ | < | ||
+ | grub | ||
+ | root (hd1,0) [enter] | ||
+ | setup (hd1) [enter] | ||
+ | quit [enter] | ||
+ | </ | ||
+ | |||
+ | ==== update the data on the second disk ==== | ||
+ | * we need to copy the changes from the original disk to the new one | ||
+ | |||
+ | < | ||
+ | rsync -aH /boot/ /1/boot/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Reboot ==== | ||
+ | * time to reboot and see what happens | ||
+ | < | ||
+ | reboot | ||
+ | </ | ||
+ | |||
+ | * **at the boot prompt select the second boot option** and verify that is the right one checking that contains the **root (hd1,0)** line | ||
+ | * if everything was right the system should boot with the raid 1 disk | ||
+ | |||
+ | |||
+ | ===== The New System ===== | ||
+ | * now we have the system running on the software raid disk, but the raid is in downgrade mode (only one disk is operating at the moment) | ||
+ | * we need to connect the original disk tho the current one | ||
+ | * for this reason we need to remove all the partitions on the old disk a recreate the new partition map that must be identical to the one of the **/ | ||
+ | |||
+ | * in our examples /dev/vg0 is the old lvm disk | ||
+ | |||
+ | ==== Deleting the old lvm partitions ==== | ||
+ | * we disable the old lvm partitions to avoid confusion | ||
+ | < | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | * now we can erase the lvm partitions | ||
+ | < | ||
+ | lvremove vg0/root | ||
+ | lvremove vg0/ | ||
+ | lvremove vg0/var | ||
+ | lvremove vg0/export | ||
+ | </ | ||
+ | |||
+ | * then we need to remove the vg | ||
+ | < | ||
+ | vgremove vg0 | ||
+ | pvremove /dev/sda3 | ||
+ | </ | ||
+ | |||
+ | ==== Creating the new partition table form the second disk ==== | ||
+ | * now we can recreate the new partition table copying the partition of /dev/sdb to /dev/sda | ||
+ | < | ||
+ | | ||
+ | </ | ||
+ | | ||
+ | ==== add the second disk to the raid system ..... ==== | ||
+ | |||
+ | < | ||
+ | mdadm --manage /dev/md0 --add /dev/sda1 | ||
+ | mdadm --manage /dev/md1 --add /dev/sda3 | ||
+ | </ | ||
+ | * the raid subsystem is synchronizing the content of both disks | ||
+ | |||
+ | ==== .... and update the grub code ==== | ||
+ | |||
+ | < | ||
+ | grub | ||
+ | root (hd0,0) | ||
+ | setup (hd0) | ||
+ | quit | ||
+ | </ | ||
+ | |||
+ | ==== the last task is to create the second swap partition ==== | ||
+ | |||
+ | < | ||
+ | mkswap -L SWAP-sda2 /dev/sda2 | ||
+ | swapon /dev/sda2 | ||
+ | </ | ||
+ | |||
+ | * uncomment the line about the swap partition inside /etc/fstab | ||
+ | |||
+ | ===== Kernel upgrade ===== | ||
+ | **During Kernel upgrade the grub file must be manually modified in order to add the reference to the second disk** | ||
+ | |||
+ |
administration/system-mirror.1205347201.txt.gz · Last modified: 2008/03/12 18:40 (external edit)