Moving root from LVM to standard ext4 partition

I'm on a server with Ubuntu 18.04LTS with single disk in LVM partition. Boot partition is ext2 , root partition is ext4 in volume group beta-root (as show below)

Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 798M 3.3M 795M 1% /run
/dev/mapper/beta-root 293G 129G 152G 46% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs 512M 0 512M 0% /clam-tmp
/dev/sda1 228M 111M 106M 52% /boot
tmpfs 798M 0 798M 0% /run/user/1001
tmpfs 798M 0 798M 0% /run/user/0
Disk /dev/sda: 300 GiB, 322122547200 bytes, 629145600 sectors
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: 0x000456c7
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
/dev/sda2 501758 125827071 125325314 59.8G 5 Extended
/dev/sda3 125827072 629145599 503318528 240G 8e Linux LVM
/dev/sda5 501760 125827071 125325312 59.8G 8e Linux LVM
# /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>
proc /proc proc nodev,noexec,nosuid 0 0
/dev/mapper/beta-root / ext4 errors=remount-ro,acl 0 1
# /boot was on /dev/sda1 during installation
UUID=9b35bbcc-61f6-410a-bc43-f06516bfedd6 /boot ext2 defaults 0 2
/dev/mapper/beta-swap_1 none swap sw 0 0
tmpfs /dev/shm tmpfs defaults,noexec,nosuid 0 0
tmpfs /clam-tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=512M 0 0

There's an understandable method to migrate full system from a mixed environment (LVM and non-LVM) to a new hard disk (let's say /dev/sdb) with same layout but with no LVM at all?

Thanks for support!

6

1 Answer

The steps I would follow, in a nutshell, are as thus:

  1. Boot from a liveUSB
  2. Install Boot-Repair:

    sudo add-apt-repository ppa:yannubuntu/boot-repair
    sudo apt-get update
    sudo apt-get install -y boot-repair
  3. Install and mount LVM drives as described here

    sudo apt-get install software-properties-common
    sudo apt-get install lvm2 #This step may or may not be required.
    sudo pvscan #Use this to verify your LVM partition(s) is/are detected.
    sudo vgscan #Scans for LVM Volume Group(s)
    sudo vgchange -ay #Activates LVM Volume Group(s)
    sudo lvscan #Scans for available Logical Volumes
    sudo mount /dev/YourVolGroup00/YourLogVol00 /YourMountPoint
  4. Mount the drive where you are moving the data

  5. Copy data from the old to the new drive:

    Copy the boot partition:

    sudo dd if=/dev/sda1 of=/dev/sdb1 bs=4096 

    Copy the root partition:¹

    sudo dd if=/dev/beta/root | pv -s 300G | dd of=/dev/sdb2 bs=4096
  6. Run Boot-Repair on the new drive:

    sudo boot-repair
  7. Reboot

Note 1: This could take a very long time.

7

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like