There are a few similar questions online but I haven't seen any that cover the exact scenario. This is a question and answer in one to a problem that took me several hours to work out.
I wanted to clone a drive and maintain /boot without having to mess around with grub.
1 Answer
Boot up on a live CD/USB and then use dd to clone from the old disk to the new one:
dd if=/dev/sda of=/dev/sdb Shutdown and remove old drive to avoid vg conflicts Actually what I did is clone /dev/sda to a file on third drive so I could a) have a backup and b) start from scratch fairly easily. If you run the dd step again, reboot as pvdisplay will still show the old statistics.
shutdown -h nowAfter booting up on live cd/usb again, sdb becomes sda
use parted to create a new partition after all existing partitions. I found parted to be easier than fdisk in this case because you can just tell it to use all available space
gparted /dev/sdaNow create a new physical volume. Some people suggest changing the existing pv size (pvresize --setphysicalvolumesize), but this never worked for me and resulted in errors at the lvextend step
pvcreate /dev/sda3 (The new partition)
vgextend /dev/vgname /dev/sda3You should now see the additional free space
vgdisplayApologies for the lack of output, I'm not running all of this again :D
Now we need to extend the lvm partition. Note that if you have a swap partition at the end, don't worry, lvm handles that for you.
lvextend /dev/vgname/root -L+150G(vgdisplay showed you how much space you could add)
lvscanThis will show you that the space has been allocated, but we're still not quite there, df won't show the additional free space.
e2fsck -f /dev/vgname/root
resize2fs /dev/vgname/rootNow we should be there, if you mount up /dev/vgname/root, df will report the new partition size and free space.
Remove your live CD/USB and reboot, your install should work.
These steps worked with a Ubuntu Server 16.04.2 install and a Ubuntu 16.04.2 live USB.