How to Migrate Linux from Traditional Partitions to LVM Without Reinstallation


14 views

Many sysadmins discover LVM's benefits (like volume resizing, snapshots, and flexible storage pools) only after setting up traditional partitions. The good news: conversion is possible without reinstalling your system, though it requires careful execution.

Before proceeding, ensure you have:

• A complete backup of all critical data

• A live USB/CD for emergency recovery

• At least 20% free space on your source partitions

• Understanding of your current partition layout (lsblk -f and fdisk -l)

Here's the technical workflow I've used successfully on Debian/Ubuntu systems. For RHEL/CentOS, adjust package names accordingly:

# Install necessary tools
sudo apt install lvm2

# Create physical volume on target disk
sudo pvcreate /dev/sdaX

# Create volume group
sudo vgcreate vg0 /dev/sdaX

# Create logical volumes matching your current setup
sudo lvcreate -L 20G -n root vg0
sudo lvcreate -L 8G -n home vg0
sudo lvcreate -L 2G -n swap vg0

# Format the new volumes
sudo mkfs.ext4 /dev/vg0/root
sudo mkfs.ext4 /dev/vg0/home
sudo mkswap /dev/vg0/swap

For the actual data transfer, I prefer rsync for its reliability:

# Mount both source and destination
sudo mkdir /mnt/{old,new}
sudo mount /dev/sdaY /mnt/old
sudo mount /dev/vg0/root /mnt/new

# Copy data preserving permissions
sudo rsync -aAXv /mnt/old/ /mnt/new/

Critical post-migration steps:

# Update fstab with new UUIDs
sudo blkid /dev/vg0/root >> /etc/fstab
sudo blkid /dev/vg0/home >> /etc/fstab

# For GRUB2 systems:
sudo grub-install /dev/sda
sudo update-grub

Your assumption is correct - Windows cannot natively access LVM volumes. For shared partitions:

  • Keep Windows-accessible partitions as standard NTFS/FAT32
  • Consider creating a separate non-LVM ext4 partition for Linux-Windows file sharing

Always test your new setup before deleting old partitions:

# Check LVM status
sudo vgdisplay
sudo lvdisplay

# Verify filesystem integrity
sudo fsck /dev/vg0/root

Common pitfalls include forgetting to update initramfs (update-initramfs -u) or incorrect fstab entries. Always have a recovery plan.


Many sysadmins who discovered LVM's benefits (like myself) face a common dilemma - how to migrate existing traditional partitions to LVM without reinstalling the entire system. While challenging, it's absolutely possible with careful planning and execution.

Before beginning, ensure you have:

  • Backup of all critical data (mandatory)
  • Live CD/USB with LVM tools (Ubuntu/Debian live images work well)
  • Enough free space (either unpartitioned or shrinkable)
  • Basic understanding of LVM concepts (PVs, VGs, LVs)

Here's the technical workflow I've successfully used:


# 1. Boot into live environment
sudo -i
fdisk -l # identify current partitions

# 2. Create physical volume on target disk
pvcreate /dev/sdaX

# 3. Create volume group
vgcreate vg0 /dev/sdaX

# 4. Create logical volumes matching original partition sizes
lvcreate -L 20G -n root vg0
lvcreate -L 8G -n home vg0
lvcreate -L 2G -n swap vg0

# 5. Create filesystems on new LVs
mkfs.ext4 /dev/vg0/root
mkfs.ext4 /dev/vg0/home
mkswap /dev/vg0/swap

The critical phase - copying data without corruption:


# Mount both source and target
mkdir /mnt/{src,dest}
mount /dev/sdaY /mnt/src # source partition
mount /dev/vg0/root /mnt/dest

# Rsync for reliable transfer
rsync -aAXv /mnt/src/* /mnt/dest/

# Verify checksums (example for /etc)
find /mnt/src/etc -type f -exec md5sum {} + > /tmp/src.md5
find /mnt/dest/etc -type f -exec md5sum {} + > /tmp/dest.md5
diff /tmp/src.md5 /tmp/dest.md5

After migration, update your bootloader:


# For GRUB2:
mount --bind /dev /mnt/dest/dev
mount --bind /proc /mnt/dest/proc
mount --bind /sys /mnt/dest/sys
chroot /mnt/dest
grub-install /dev/sda
update-grub

Regarding your Windows dual-boot question:

  • Windows cannot natively read LVM volumes
  • Shared NTFS partitions must remain as basic partitions
  • Consider keeping /boot as standard partition if using GRUB

After successful conversion, you gain:

  • Online resizing capabilities
  • Snapshot functionality
  • Easier storage management
  • Better disk utilization

Common issues and solutions:


# If system fails to boot:
1. Check /etc/fstab entries match new LVs
2. Verify initramfs includes LVM modules:
   lsinitramfs /boot/initrd.img-$(uname -r) | grep lvm

# Regenerate initramfs if needed:
update-initramfs -u -k all