I am trying to clone the drive below to a new drive of a bigger size:
sda 8:0 0 223.6G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 223.1G 0 part ├─vg1-root 254:0 0 200G 0 lvm / ├─vg1-home_cachepool_cdata 254:1 0 23G 0 lvm │ └─vg1-home 254:4 0 3.7T 0 lvm /home └─vg1-home_cachepool_cmeta 254:2 0 20M 0 lvm └─vg1-home 254:4 0 3.7T 0 lvm /home(/dev/sda1 is the BIOS boot partition mounted on /boot.)
Can I just do a dd if=/dev/sda of=/dev/sd[NEW DRIVE] bs=4096? Or do I have to do something with the LVM partition?
1 Answer
dd will handle the LVM just fine.
Make sure your boot loader points to the right drive on your clone, otherwise it won't boot.
Finally, you will need to resize the LVM on the clone. Technically you should be able to enlarge a logical volume without a problem while it is mounted, but I suggest doing all operations of this nature on unmounted drives.
lvresize -L <new size>G --resizefs MyLVGroup/myvol
will resize the partition and the filesystem at the same time. Tip: add + right before <new size> in the above command to extend by that amount instead of resizing to it.
To extend the logical volume separately from resizing the filesystem do the following:
lvresize -L +<amount to extend>G MyLVGroup/myvol
Then expand the filesystem with:
resize2fs /dev/MyLVGroup/myvol
Look at askubuntu's Q "How can I resize an LVM partition? (i.e: physical volume) and archwiki's LVM - Volume Operations for more information on resizing the LVM.
5