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:
- 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:
- Prep the new disk (create partitions)
- create PV
- Add the new PV to the same VG that contains the target LVs
- Create a Mirror of the target LVs on the new PV
- Separate the mirrors into two separate LVs
- Split the VG so the new PV with the mirrored LVs on is in a new VG
- tidy up (rename LVs, VGs)
- 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
fdisk -l (Mine is called
/dev/sdg3). Now create new PV:
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
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"
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.
lvconvert --splitmirrors 1 --name new_root /dev/mint-vg/root /dev/sdg3
Now repeat for
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!)
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
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
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.
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.
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
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!