Mirroring root partition to another disk and making it bootable

I have 2 disks in my system partitioned identically.

My current OpenSuSE Leap 15.0 root partition is /dev/sda7 and is ext4.
Also, the grub2 that boots this partition is installed only in that partition’s boot record (During boot, I chain to that with another MBR boot loader).

What I want to do is mirror my Leap 15.0 root partition (/dev/sda7) to /dev/sdb7, and to make it similarly bootable (from the partition boot record of /dev/sdb7).

I know how to format /dev/sdb7 as ext4 (OpenSuSE’s partitioner makes this easy).
I also know how to mirror the content of the /dev/sda7 file system to /dev/sdb7 (rsync to the rescue. I know better than to use dd / UUIDs must be unique.).
I’m pretty sure I can modify the /etc/fstab on the copy to point to the new partition UUIDs for /dev/sdb7 (and similarly for swap).

Q: What I am very fuzzy on is the process for modifying the grub2 config to re-install grub2 in the /dev/sdb7 partition boot record so that it is independently bootable.

Since I can do a lot of damage if I foul this up, I thought I’d first ask…

Does anyone know of a good FAQ that describes how to do this? What’s the easiest/safest way to do this?

[noparse](Ancient history:)[/noparse]

When I did this “root partition mirroring” long ago (with grub1 and pre-UUIDs)…

I vaguely recollect that I had a hard time re-running grub to install it on the 2nd hard disk from a Rescue Mode shell booted off the install DVD, because the kernels were different between the DVD/rescue shell and the target root partition on the 2nd disk. Does this sound right? Should I expect any problems trying to do this from a DVD Rescue Mode shell? Or is it reasonable to try and fix the grub install on /dev/sdb7 (the copy of my root partition on the 2nd hard disk) when booted into /dev/sda7 (my primary Leap 15.0 install on my 1st disk).

Also, I recall having to edit the /etc/fstab to get the copy to mount the proper partitions, though then they were identified by /dev/hda# and /dev/hdb#. I’m assuming a similar edit but with partition UUIDs is what’s required now.

As with most things in the FOSS world, there’s no single right way to clone or do multiboot. :slight_smile:

The most bulletproof way I know is to do everything else needed first, then substitute the clone for the original (removing the original), then boot installation media selecting “boot installed system”, and update using YaST Bootloader.

I actually do much of what you’re trying to do often, as I have been since last century, but I don’t use Grub2 for MBR disks, or UUIDs for filesystems or cmdlines. Grub never goes on an MBR here, only on / or /boot or my real “boot” partition.

You can make the process simpler for yourself it you apply unique human-memorable volume labels to all filesystems, switch your fstabs to use those unique volume labels, and create a custom.cfg file that uses unique volume labels for Grub to append or prepend to its auto-generated grub.cfg menus. To prepend instead of append, mv /etc/grub.d/4[0,1]_custom to 0[6,7]_custom. Grub can continue pacifying itself with UUIDs, but they need not complicate your life if you choose not to let them.

Same here. I use a separate bootloader in the MBR and confine grub to the partition.

The most bulletproof way I know is to do everything else needed first, then substitute the clone for the original (removing the original), then boot installation media selecting “boot installed system”, and update using YaST Bootloader.

Thanks for the tip!

Could you give me a little more detail about what you mean by the “boot installation media selecting ‘boot installed system’”? Sorry for being a bit of a n00b here.

Just now I did try booting the Leap 15.0 Install DVD and looking for the “boot installed system” option. I didn’t find one by that name.

What I do see is “Boot from Hard Disk”, which apparently loads the MBR bootloader and gives control to it. There is also More … -> Boot Linux System, which I tried, without success. It prompts for “Select a system to Boot” (e.g. sda7, sdb7, etc.; I picked sda7), then Select a kernel to boot (I picked the latest kernel on sda7), "You may select an alternative device name for the system partition (I tried several different options on different boots, including sda7 and a /dev/disk/… path with uuid). Both of these reported “Sorry, your system didn’t boot.” And this is for the partition and kernel I’m running right now, so I know it’s a valid, bootable Linux partition.

Based on this, I’m assuming that the “Boot Linux System” option may not be what you’re talking about, or I just don’t know the secret handshake to make it work.

Alternatively, did you mean starting to boot into my main Linux partition normally, and when it’s at the grub screen, hacking the kernel command-line options to try to redirect it to loading off another partition (e.g. /dev/sdb7 instead of /dev/sda7)? If so, which option overrides do you tend to use?

You can make the process simpler for yourself it you apply unique human-memorable volume labels to all filesystems, switch your fstabs to use those unique volume labels, and create a custom.cfg file that uses unique volume labels for Grub to append or prepend to its auto-generated grub.cfg menus. To prepend instead of append, mv /etc/grub.d/4[0,1]_custom to 0[6,7]_custom. Grub can continue pacifying itself with UUIDs, but they need not complicate your life if you choose not to let them.

I’ll definitely explore that later. Thanks!

Boot Linux System is the one that I thought was called Boot Installed System.http://fm.no-ip.com/SS/Suse/YaST/150/150-BIOSmenu3.jpg

It prompts for “Select a system to Boot” (e.g. sda7, sdb7, etc.; I picked sda7), then Select a kernel to boot (I picked the latest kernel on sda7), "You may select an alternative device name for the system partition (I tried several different options on different boots, including sda7 and a /dev/disk/… path with uuid). Both of these reported “Sorry, your system didn’t boot.” And this is for the partition and kernel I’m running right now, so I know it’s a valid, bootable Linux partition.
I just tried here, and it didn’t work for me either - twice. I don’t know why. So on 3rd try I selected Rescue System instead. After login:

# blkid 					# partition selection "menu"
# ls -l /mnt 					# ensure mount point exists and is empty
# mount -t auto -o noatime /dev/sda14 /mnt	# mount root partition
# ls -l /mnt 					# ensure correct result
# mount -o bind /dev /mnt/dev
# mount -o bind /run /mnt/run
# mount -o bind /sys /mnt/sys
# mount -o bind /proc /mnt/proc
# chroot /mnt 
# yast2

At this point since yast2 started I quit to send this.

Alternatively, did you mean starting to boot into my main Linux partition normally, and when it’s at the grub screen, hacking the kernel command-line options to try to redirect it to loading off another partition (e.g. /dev/sdb7 instead of /dev/sda7)? If so, which option overrides do you tend to use?
I would be escaping the Grub menu, then in Grub edit mode substituting the correct disk,partition#s and root=, but I don’t wish to strain my brain detailing this method now…

Ok, thanks! I appreciate your trouble in testing the DVD and detailing this alternative method. I’ve saved this off and will try it soon. Need to update my backups first. :slight_smile: