1

I have Linux Mint installed on and booting from an LVM drive with two physical disks in the volume group (1TB each). I have purchased a new hard drive (4TB) and I would like to clone the whole thing and get it booting from the new disk.

I'm really struggling to find instructions for this procedure when the root file system is on an LVM drive.

I followed these instructions and have successfully managed to mirror the mint-vg/root and mint-vg/swap_1 logical volumes on to the new disk, I then split the mirror with lvconvert --splitmirror and split the Volume Group with vgsplit. This made a nice clone of all my files I just cant for the life of me work out how to boot from the new copy!

First I tried renaming all the LVs and VGs so the old ones had "OLD_" prefixed and the new ones had the names of the old ones. For example "mint-vg" became "OLD_mint-vg" and "new_mint-vg" became "mint-vg" etc.

I then realised that one of the old drives has a primary partition on that is bootable. Here is the original configuration of drives: (sde and sdf are the old drives and sdg is the new one)

$ lsblk

NAME                MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sde                   8:64   0 931.5G  0 disk 
└─sde1                8:65   0 931.5G  0 part 
  └─mint--vg-root   253:2    0   1.8T  0 lvm  /run/timeshift/backup
sdf                   8:80   0 931.5G  0 disk 
├─mint--vg-root     253:2    0   1.8T  0 lvm  /run/timeshift/backup
└─mint--vg-swap_1   253:3    0   976M  0 lvm  [SWAP]
sdg                   8:96   0   3.7T  0 disk 

I have tried grub-install /dev/sdg and got "grub-install: error: failed to get canonical path of '/cow'"

I have also experimented with these instructions but I can't create the Primary partition because my new disk is bigger than 2048G which is the maximum partition size.

I also have installed linux mint on to the new disk to see how it configures the partitions and they look like this:

sdg                   8:96   0   3.7T  0 disk 
└─sdg1                8:97   0     1M  0 part
└─sdg2                8:98   0   513M  0 part
└─sdg3                8:99   0   3.7T  0 part
  └─vgmint-root       253:1  0   3.7T  0 lvm
  └─vgmint-swap_1     253:2  0   967M  0 lvm [SWAP]

Would it now be possible to clone my old root and swap LVs and just replace the ones from the new Mint installation? Will it really be that simple? Otherwise if anyone can walk me through the process of setting up the necessary boot config so I can get my cloned system running again or point me to some clear instructions I'd be really grateful.

Thanks,

Dan.

Edit

Thanks ever so much for your help, I’m literally pulling my hair out over this!

Okay, here is the pastebin link you requested but beware my system has 7 drives in and I’m booting from a linux mint live USB.

The original OS is on drives /dev/sde and /dev/sdf/and I have renamed the VG and LVs with prefix “OLD_”. The new drive is /dev/sdg and has a fresh install of Linux Mint on it at the moment which will need to be removed going forwards. I installed it so I could see how it configures the partitions.

It looks like the new Mint installer has chosen the BIOS option you mentioned and a bios_grub partition (/dev/sdg1)

Now that the Mint installer has set up said partitions, can I now delete the volume group “vgmint” from the fresh install and replace it with my cloned volume group "mint-vg"? If so what will I have to reconfigure to get it to boot? Or should I wipe the drive and start afresh?

6
  • UEFI or BIOS installs? MBR or gpt partitioned drives. Drives below 2TB could be MBR, but drives over 2TB must be gpt. If UEFI you need an ESP and UEFI install, if BIOS you need a bios_grub partition so grub can install correctly to gpt drive. Your /cow is the live installer COW - copy on write. So you tried installing grub to live installer not your new LVM. Please copy & paste the pastebin link to the Bootinfo summary report. Lets see details, use ppa version with your USB installer (2nd option) or any working install, not Boot-Repair ISO help.ubuntu.com/community/Boot-Repair
    – oldfred
    Feb 2 at 20:19
  • Thanks for your help, I have added an edit at the bottom of my original post with the info you requested.
    – Dandelion
    Feb 3 at 11:34
  • I do not know LVM well enough to really be able to help. But since you split volumes you seem to show duplicate UUIDs? That is not allowed if drives are separate.
    – oldfred
    Feb 3 at 19:56
  • There's no duplicate volumes yet, just ignore all drives apart from sde, sdf & sdg. If I replace the ʻvgmintʻ volume group on ʻ/dev/sdg3ʻ with a copy of my old system volume group ("OLD_mint-vg"), obviously I'd rename it to "mint_vg", how do I configure grub to boot from ʻmint-vg/rootʻ now on sdg3?
    – Dandelion
    Feb 3 at 20:29
  • You can chroot into your install. Example: help.ubuntu.com/community/ManualFullSystemEncryption/… chroot with UEFI, LVM, encryption on NVMe drive ubuntuforums.org/…
    – oldfred
    Feb 4 at 3:52

1 Answer 1

2

I have been messing about with this for days now so I figured I should post my solution for anyone else that is having a similar problem. Here is how to clone your Mint installation to a new 4TB disk when installed on an LVM spanned across 2x 1TB disks:

Useful links:

Terminology

  • PV = Physical Volume
  • VG = Volume Group
  • LV = Logical Volume

To make a clone of a system disk installed on an LVM system with the intention of booting from the clone we will perform the following steps:

  1. Prep the new disk (create partitions)
  2. create PV
  3. Add the new PV to the same VG that contains the target LVs
  4. Create a Mirror of the target LVs on the new PV
  5. Separate the mirrors into two separate LVs
  6. Split the VG so the new PV with the mirrored LVs on is in a new VG
  7. tidy up (rename LVs, VGs)
  8. Install Grub To Make bootable

1 - Prep the new disk

If your disk is smaller than 2048 gigabytes you can prep the disk with an MBR partition but that is not covered here.

If you want to boot to a drive that is bigger than 2TB you must create a BIOS boot partition. I found these instructions useful but to be honest I cheated a bit.

The way I configured my partitions was to do a fresh install of linux mint on to my new drive. That set up 3 partitions the BIOS boot partition (bios_grub) some unknown fat32 partition (i'm still looking in to this I'm thinking about deleting it it's half a gig!!!) and an LVM2 partition (with LVs ʻrootʻ and ʻswap_1ʻ in).

I then deleted the new volume group with the fresh install of Mint leaving a blank partition (/dev/sdg3) and then cloned my old mint VG in to the blank partition.

I think if I had created the 1meg Bios partition with fdisk as outlined in these instructions then an LVM partition with the rest of the disk I could probably have avoided installing mint afresh. However it worked so feel free to experiment or cheat it's up to you.

2 - Create PV

Now you have your disk partitioned you need to find the device name of the biggest partition with lsblk or fdisk -l (Mine is called /dev/sdg3). Now create new PV:

pvcreate /dev/sdg3

3 - Add the new PV to the same VG as the target LV

You can list the logical volumes with vgs (I will use "mint-vg") and add the new PV like this:

vgextend mint-vg /dev/sdg3

4 - Create a Mirror of the target LV on the new PV

List your LVs with lvs, mine was called "root", I also cloned swap_1 so you can just repeat these instructions for both LVs.

If your LV is fairly large mirroring can take a long time while it copies all the data. It will keep you informed of its progress on the screen and if you have a power outage or something like that it should just continue from where it left off next time you boot on to your live disk. You might also want to run it in the background with the -b option.

lvconvert --type mirror -m1 /dev/mint-vg/root /dev/sdg3

Once it has finished you might want to check that it all looks good:

lvs -a -o +devices | egrep "LV|root"

Notice the Cpy%Sync column it should display the percent copied.

Now start this section again and mirror the "swap_1" LV.

5 - Separate the mirrors into two separate LVs

Next convert the mirrored LV in to an actual LV. The two LVs (the original and the copy) will be on the same VG so it will be necessary to rename them as you do it (I will use "new_root"). Also it is important to flush the caches with the sync command first just to be on the safe side.

sync
lvconvert --splitmirrors 1 --name new_root /dev/mint-vg/root /dev/sdg3

Now repeat for /dev/min-vg/swap_1

6 - Split the VG so the new PV with the mirrored LV on it is in a new VG

Before we split the VG we must deactivate the LV: (the -a stands for activate [y|n])

lvchange -an /dev/mint-vg/new_root
lvchange -an /dev/mint-vg/new_swap_1

Now we can make a new VG from /dev/sdg3 which will still have the mirrored LVs on it:

vgsplit mint-vg new_mint-vg /dev/sdg3

You should now be able to see the copied LVs and two VGs with their associated devices

lvs -o +devices

7 - tidy up (rename LVs, VGs and perhaps mark a VG for exporting)

If (like me) you are trying to copy your system to a new disk that you intend to boot from and wipe the old system drives you will need to rename all the LVs and VGs so the old "mint-vg" is called "OLD_mint-vg" and the new "new_mint-vg" is called "mint-vg" etc and the same for the LVs.

you can rename an LV and a VG like this: (unmount first!)

umount /dev/mapper/mint—vg-root
lvrename mint-vg root OLD_root
vgrename mint-vg OLD_mint-vg

If you intend to remove a volume group (Perhaps you have copied it to an external drive for transportation) you should deactivate the LVs on it and the VG itself and mark it for exporting:

lvchange -an /dev/mint-vg/old_root
vgchange -an old_mint-vg
vgexport old_mint-vg

Now if you run pvs you should see the VGs attributes have an x to indicate that it is marked for exporting and there is no a attribute meaning it is not active.

8 - Install Grub To Make bootable

A quick mention of fstab

Here is a brief description of your /etc/fstab file.

I just wanted to quickly mention your /etc/fstab file. It is used to tell your system about partitions that need to be mounted, in which order to mount them and to assign certain options to them upon mounting. In my case I renamed my LVs and it's VG so they were the same as the originals. Additionally, in my /etc/fstab file my partitions are identified with their device name and not the unique UUID which meant that everything just worked for me.

it might be worth having a look at your /etc/fstab file just to familiarise yourself with it.

cat /etc/fstab

If you have renamed your VG, any of the LVs or your partitions are identified by their UUID in your fstab file you will likely have to edit your fstab file to get your system booting and your volumes mounted.

you can find out the UUIDs by typing blkid in your terminal.

Grub

To get your clone booting from your new disk you need to install Grub on it. To do this you must first mount the root folder so we can point grub to the /boot folder.

These instructions might be useful but if you don't tell it about your /boot folder you will get the following error: "failed to find the canonical /cow". After reading the Grub manual info grub-install - I was able to install grub by pointing it to the /boot/ folder on the root LV. Here's how:

First create a mount point folder: then mount the root LV and finally you can install grub

mkdir /mnt/root
mount /dev/mint-vg/root /mnt/root
grub-install --boot-directory=mnt/root/boot /dev/sdg

This will set up your ʻ/bootʻ folder and create a new ʻcore.imgʻ in your BIOS boot partition. You should be able to boot now, don't forget to change the boot device in your bios!

God speed!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.