Moving a Linux Root LVM from a Second Disk Back to the Primary Disk and Rebuilding Boot Files
Moving a Linux Root LVM from a Second Disk Back to the Primary Disk and Rebuilding Boot Files
Moving a Linux Root LVM from a Second Disk Back to the Primary Disk and Rebuilding Boot Files
Moving a Linux Root LVM from a Second Disk Back to the Primary Disk and Rebuilding Boot Files
In some Linux environments, especially systems using LVM, the root logical volume may accidentally span multiple disks. This can create boot risks when /boot is part of the root filesystem and the root logical volume has extents on more than one physical disk.
This guide explains how to move the root logical volume extents from /dev/sdb1 back to /dev/sda1, rebuild the boot files, reinstall GRUB, and validate that the system boots correctly.
Important: Perform these steps carefully and only during an approved maintenance window. Always ensure that you have a valid backup or snapshot before making LVM or bootloader changes.
Scenario
The system currently has:
- Root logical volume:
/dev/system/root - Volume group:
system - Primary disk:
/dev/sda - Secondary disk:
/dev/sdb - Root filesystem currently spanning both
/dev/sda1and/dev/sdb1 /bootis part of/, not a separate filesystem
The goal is to ensure that:
/dev/system/rootuses only/dev/sda1- Boot files no longer span multiple disks
- GRUB is reinstalled on
/dev/sda - The instance boots successfully after the change
Step 1: Verify the Current Layout
First, check the current disk, LVM, and filesystem layout.
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,FSTYPE
pvs
vgs
lvs -o +devices
lvdisplay -m /dev/system/root
df -hT /boot
Expected current issue:
/bootshould show under/dev/mapper/system-root/dev/system/rootmay show extents on both/dev/sda1and/dev/sdb1
This confirms that the root logical volume is spread across multiple physical volumes.
Step 2: Expand the First Disk
From the console or storage management side, increase the size of the first disk:
/dev/sda
In this example, the current /dev/sda size is 40 GB.
Since the root filesystem is 100 GB and swap is 10 GB, increase /dev/sda to at least 120 GB. This provides enough space for:
- Root filesystem
- Swap
- Some additional buffer
Step 3: Grow the Partition and Resize the Physical Volume
After increasing the disk size, grow the partition:
growpart /dev/sda 1
Then resize the LVM physical volume:
pvresize /dev/sda1
Verify that free space is now available on /dev/sda1:
pvs
pvdisplay /dev/sda1
You should now see available free space on /dev/sda1.
Step 4: Move Root LV Extents from /dev/sdb1 to /dev/sda1
Move the root logical volume extents from /dev/sdb1 to /dev/sda1:
pvmove -n root /dev/sdb1 /dev/sda1
If the command requires the full logical volume path, use:
pvmove -n /dev/system/root /dev/sdb1 /dev/sda1
Wait until pvmove completes successfully and reaches 100%.
Do not interrupt this operation while it is running.
Step 5: Verify the Root LV Is Now Only on /dev/sda1
After the move completes, verify the logical volume mapping:
lvs -o +devices /dev/system/root
lvdisplay -m /dev/system/root
Expected result:
/dev/system/root should show only /dev/sda1
There should be no /dev/sdb1 entry under /dev/system/root.
Step 6: Optional — Remove /dev/sdb1 from the Volume Group
Only run this step if /dev/sdb1 no longer contains any active logical volume extents and the customer does not need it as part of the system volume group.
Check the current LVM layout:
pvs
lvs -o +devices
If /dev/sdb1 is no longer needed, remove it from the volume group:
vgreduce system /dev/sdb1
After this command, /dev/sdb1 will no longer be part of the system volume group.
Step 7: Mount the Root Filesystem for Chroot
Activate the volume group:
vgchange -ay system
Mount the root logical volume:
mount /dev/system/root /mnt
Bind the required system directories:
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /run /mnt/run
These mounts are required so that bootloader and initramfs commands work correctly inside the chroot environment.
Step 8: Chroot and Rebuild Boot Files
Enter the chroot environment:
chroot /mnt /bin/bash
Confirm the operating system and kernel files:
cat /etc/os-release
ls -l /boot/vmlinuz-*
ls -l /boot/initrd-*
ls -l /lib/modules
For SLES systems, regenerate the initramfs using:
mkinitrd
If mkinitrd is not available, use dracut for the installed kernels:
for kver in $(ls /lib/modules); do
dracut -f /boot/initrd-${kver} ${kver}
done
Reinstall GRUB on the boot disk:
grub2-install /dev/sda
Regenerate the GRUB configuration:
grub2-mkconfig -o /boot/grub2/grub.cfg
Exit the chroot:
exit
Step 9: Unmount Filesystems and Deactivate the Volume Group
Unmount the bind mounts and root filesystem:
umount /mnt/run
umount /mnt/sys
umount /mnt/proc
umount /mnt/dev
umount /mnt
Deactivate the volume group:
vgchange -an system
Step 10: Boot Validation
After reattaching the disk and starting the instance, validate the system.
Run the following commands:
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,FSTYPE
df -hT /boot
lvs -o +devices /dev/system/root
systemctl --failed
Expected final result:
/dev/system/rootshould be located only on/dev/sda1/bootwill still be part of/- Since
/is now only on/dev/sda1, boot files are no longer spanning multiple disks - GRUB should be installed again on
/dev/sda - The instance should boot successfully
Final Notes
This procedure is useful when a Linux root logical volume has accidentally been extended across multiple disks and the boot files are part of the root filesystem.
By moving all root LV extents back to the primary disk and reinstalling GRUB, the system becomes easier to boot, recover, and manage.
Always validate the LVM layout before and after the migration, and avoid removing any physical volume from a volume group until you are certain it no longer contains active extents.
메타데이터
- post_id
- d6c69b766dc0
- slug
- moving-a-linux-root-lvm-from-a-second-disk-back-to-the-primary-disk-and-rebuilding-boot-files-d6c69b766dc0
- url
- https://medium.com/@dibinjacob7794/moving-a-linux-root-lvm-from-a-second-disk-back-to-the-primary-disk-and-rebuilding-boot-files-d6c69b766dc0
- canonical_url
- https://medium.com/@dibinjacob7794/moving-a-linux-root-lvm-from-a-second-disk-back-to-the-primary-disk-and-rebuilding-boot-files-d6c69b766dc0
- author_url
- https://medium.com/@dibinjacob7794
- status
- ok
- fetched_at
- 2026-06-21 15:33:18