I’ve been searching the internet for any answer to this and have not found anything that I can wrap my head around, not that specifically answers my questions anyway.
I installed a new hard disk in my computer and I want to move my existing 20.04 Ubuntu installation to it using after setting up lvm physical disk/volume group/logical on the new disk (prior installation didn’t have lvm and I want to convert it to lvm and move everything back so I’m going to be doing this again after I re-partition the old disk)
I ran all the commands to get my lvm setup like I want it (except I want to pull out the /home and put it on it’s on logical volume which I will do on the return trip)
These are a couple of articles I’ve read and though they are helpful I am getting some issues getting my system to boot off the new disk and I must be missing a setup step that allows lvm to boot:
https://www.thegeekdiary.com/centos-rhel-converting-an-existing-root-filesystem-to-lvm-partition/
I’m aware the second is for a different flavor of linux…
First here is fdisk for /dev/sdb:
root@Uranus:~# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sdb: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: WDC WD5000BEVT-2
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf43e5cfa
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 2099200 2097153 1G 8e Linux LVM
/dev/sdb2 20992001 976773167 955781167 455.8G 8e Linux LVM
and lvs
root@Uranus:~# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv1 boot -wi-a----- 512.00m
lv2 ubuntu -wi-ao---- 419.00g
lv3 ubuntu -wi-ao---- 36.00g
I got all the stuff move to the new lv2 volume using:
root@Uranus:~# tar -cvpzf /mnt/lv2/backup.tar.gz --exclude=/mnt/lv2/backup.tar.gz --one-file-system --acls --xattrs --selinux /
root@Uranus:~# tar -C /mnt/lv2 -xf /mnt/lv2/backup.tar.gz
I also did the above commands for /boot and placed that on the boot logical volume
I updated my /dev/lv2/etc/fstab to mount / and /boot from their logical partitions using the UUID’s.
At this point since I’m dealing lvm I am trying to figure out what command to get the new disk to boot after I go into bios and change the boot order.
I ran dpkg-reconfigure grub-pc but that wiped out the /boot on the new logical partition.
here is the fstab:
root@Uranus:/mnt/lv2/etc# cat fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / on /dev/sdb2 during installation
UUID=b0f9cf0b-55ed-4d9e-bda9-d55f47b64d46 / ext4 errors=remount-ro 0 1
# /boot/efi on /dev/sdb1
UUID=3e51c0bc-46e3-4394-8b0b-ca7aaee4eb54 /boot/efi ext4 umask=0077 0 1
# boot swap space on logical volumn /dev/ubuntu/lv3
UUID=626fdd18-ce48-4498-bba7-baa9ccebde93 none swap sw 0 0
How do I get grub to boot the logical volumes and properly load / ?
Keep in mind I haven’t gotten that disk to boot yet so I need to have whatever program run to make it "bootable" other than the flag from fdisk.
Thanks in advance.
>Solution :
I was finally able to get everything working on the “new” drive. I followed the following instructions:
https://help.ubuntu.com/community/UbuntuDesktopLVM
and everything worked great.
Wish I had found that at the beginning. Now I just need to figure out how to copy everything over without affecting any configuration files. If anyone knows any good articles please point me in that direction. Otherwise I’m just going to copy my /home directory and reinstall any software I have.