Root mirroring in SUSE 10.1

Hi,

I want to mirror root hard disk in SUSE LINUX 10.1.

I have two 80G hard disks, I searched in google but I did not find any good link to describe this.

Please see below info..


Server1:~ # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda6              16G  1.2G   14G   8% /
udev                  1.3G  140K  1.3G   1% /dev
/dev/sda7              59G   33M   59G   1% /home
Server1:~ # sfdisk -d /dev/sda
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=       63, size=156232062, Id= f, bootable
/dev/sda2 : start=        0, size=        0, Id= 0
/dev/sda3 : start=        0, size=        0, Id= 0
/dev/sda4 : start=        0, size=        0, Id= 0
/dev/sda5 : start=      126, size=  2104389, Id=82
/dev/sda6 : start=  2104578, size= 31471272, Id=83
/dev/sda7 : start= 33575913, size=122656212, Id=83
Server1:~ #
Server1:~ #
Server1:~ #  sfdisk -d /dev/sdb
# partition table of /dev/sdb
unit: sectors

/dev/sdb1 : start=        0, size=        0, Id= 0
/dev/sdb2 : start=        0, size=        0, Id= 0
/dev/sdb3 : start=        0, size=        0, Id= 0
/dev/sdb4 : start=        0, size=        0, Id= 0
Server1:~ # cat /etc/fstab
/dev/sda6            /                    reiserfs   acl,user_xattr        1 1
/dev/sda7            /home                reiserfs   acl,user_xattr        1 2
/dev/sda5            swap                 swap       defaults              0 0
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
usbfs                /proc/bus/usb        usbfs      noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
Server1:~ #

Please help me, I am new to SUSElinux and please give me helpful links.

How did you arrive at that partitioning scheme? Is there any other disk installed in the system (eg. running Windows)? Where is the boot loader installed (check /boot/grub/menu.lst)? Do you have a working backup of any important files on the machine (not only on the Linux disk, but really the complete machine)?

only one instance is installed.
It is a testing machine, so we do not have any important files for now.

So Kindly suggest me procedure.

Thanks
srini

Is this a testing machine based on an production machine, and you want to apply the mirroring procedure to the production machine later? Or is it just for experimenting? If the later, I'd say scrap it and set up mirroring during the installation (less hassle).

Yes exactly ...

I want to replicate this on production server.

Thanks
Srini

Ok, we could go on forth an back for a while now, but I think that would be rather tiresome. So please, post as much information about the systems as possible. Otherwise the probability is very very high that whatever advice we give will screw up your system.

What's the partitioning layout on the production server?
Did you replicate the layout on the test machine?
Is the test machine a physical or virtual one?
Do you only want to mirror the root partition or others too?
Do you, at any point in the foreseeable future, plan to switch to LVM to manage your disks?
What boot loader are you using (Grub, LILO) and where is it installed (MBR, first partition)?

Hi,
Thanks for your reply.

Partition lay out is same on both production and development.
We do not have any plans to migrate to LVM.
Boot loader is grub.
It is a physical machine.
I want to mirror / & boot (Or these separate ? I dont know, My df is not showing separately).

Will you please post reply ASAP.

Thanks
Srini

Hello mate,
..to mirror disks you should use a volume manager as is mentioned above (LVM will do you) -you will need to build logical devices that you can manage - mirror or what ever.
You will need a disk manager get sorted anyway to manage SAN/NAS devices if required- well I dont see any local application moutpoints there.
Your df -h shows me that you having only default linux install/build set up - this does not look like layout of production or test server to me.
Simply you need to re-think the project, partition the disks right, then grab the slices and build the logical devices, and then mirror the devices accross the controllers...
I think you can do the all the low lever work easy in YAST..

Alright. I've asked about the partition layout since it seems quite strange: 3 logical partitions (2 Linux + 1 Swap) inside an Windows extended partition isn't what you usually find in an production environment. A virtual machine might have been better for testing, since you could create snapshots to go back to if a step fails.

I'll try to create a suitable checklist/how-to, but it might take some time. Things like this shouldn't be rushed...

---------- Post updated at 17:01 ---------- Previous update was at 12:39 ----------

Alright, I think I've got it.

DISCLAIMER:
This procedure is extremely dangerous and should not be applied to any production server without a proven good backup. Neither I nor this site can be held accountable for any data loss you might encounter. Really.

  1. Boot to "Rescue mode" using the installation CD
  2. Replicate the partition layout:
    text sfdisk -d /dev/sda | sed -e 's/sda/sdb' | sfdisk /dev/sdb
  3. Change the partition type of /dev/sdb6 to "RAID autodetect"
    text echo -e "t\n6\nfd\nw" | fdisk /dev/sdb
  4. Create the array with 1 disk missing (will be added later)
    text mdadm --create /dev/md0 -l 1 -n 2 -x 0 /dev/sdb6 missing
    #
  5. Create a filesystem on it
    text mkfs -t reiserfs /dev/md0
  6. Mount the old and new "root"
    text mkdir /tmp/old mount /dev/sda6 /tmp/old mkdir /tmp/new mount /dev/md0 /tmp/new
  7. Copy over the old contents (could take a while)
    text cd /tmp/old find . -xdev | cpio -pmdV /tmp/new/.
  8. Cross your fingers, because after the next step the original system is probably not salvageable.
  9. Unmount the old "root" and change the partition type
    text cd /tmp umount old echo -e "t\n6\nfd\nw" | fdisk /dev/sda
  10. Add the "old root" to the array so it can rebuild in the background
    text mdadm --add /dev/md0 /dev/sda6
  11. chroot into the new array to make needed changes. Do not exit the chroot until told to do so
    text chroot /tmp/new
  12. Mount some needed stuff
    text mount -t proc proc /proc /etc/init.d/boot.udev stop & /etc/init.d/boot.udev start
  13. Replace sda6 with md0 in these files: /boot/grub/menu.lst, /etc/fstab
  14. Install Grub on both disks (the '>' indicate to enter this at the Grub prompt and are not part of the command)
    text grub > root (hd0,5) > setup (hd0) > root (hd1,5) > setup (hd1) > quit
  15. Create a suitable mdadm.conf
    text echo "DEVICE partitions" > /etc/mdadm.conf mdadm --examine --scan >> /etc/mdadm.conf
  16. Rebuild initrd (replace xxx with the appropriate file)
    text cd /boot mkinitrd -k vmlinux-xxx -i initrd-xxx
  17. Umount and exit the chroot
    text /etc/init.d/boot.udev stop umount /proc exit
  18. Check the rebuild status with mdadm --detail /dev/md0
  19. When the array is done rebuilding shutdown -r now
  20. Hope that do didn't do anything wrong
1 Like

Hi,

Thanks a lot for your great work.
I will test this and post reply.

As it is only testing server, no problem with data.

Regards
Srini

It worked.

Only that grub part I was not able to execute, when I was in chroot.

I had done that grub installation on disks after exiting from chroot.

Thanks again for your help.