1

I didn't properly apportion my volumes when I set up a RHEL 8 server so now I'm trying to rectify that. I need to move disk space from home to root. Here's what I did:

  1. Booted from a RHEL ISO, went into troubleshooting mode, and dropped to the shell.
  2. Activated the volume group: vgchange -ay
  3. Temporarily mounted the volumes
 mkdir /mnt/sysimage/rt mkdir /mnt/sysimage/backup mount /dev/mapper/rhel_ylntest-home /mnt/sysimage/rt/ mount /dev/mapper/rhel_ylntest-root /mnt/sysimage/backup/ 
  1. Initiated the backup: xfsdump -l 0 -L "home lv backup" -M "backup" -f /mnt/sysimage/backup/home_backup.img /mnt/sysimage/rt
  2. Unmounted: umount /mnt/sysimage/rt/
  3. Deleted the logical volume: lvremove /dev/mapper/rhel_ylntest-home
  4. Created the desired size: lvcreate -Zy -L 500G -n home rhel
  5. Formatted the new volume: mkfs.xfs /dev/mapper/rhel_ylntest-home
  6. Mounted the volume: mount /dev/mapper/rhel_ylntest-home /mnt/sysimage/rt
  7. Restored from the backup: xfsrestore -f /mnt/sysimage/backup/home_backup.img /mnt/sysimage/rt
  8. Unmounted everything: umount /mnt/sysimage/rt/ /mnt/sysimage/backup/
  9. Rebooted back to the command line.

The home volume correctly decreased in size but the root volume didn't get any larger and the remaining disk space seems lost to the ether. What did I do wrong? I'm wondering if for step 7, I should have done lvcreate -Zy -L 500G -n home rhel_ylntest. I'm well out of my comfort zone here so please be prescriptive.

9
  • 2
    You never told LVM that the root LV should be expanded. lvresize -r -l +100%FREE /dev/mapper/rhel_ylntest-root (or some variant) is necessary. Commented Aug 1, 2023 at 17:23
  • After doing what doneal says, you'll also need to grow your filesystem to the new LV extends (resize2fs) Commented Aug 1, 2023 at 18:06
  • @doneal24 After which step do I do that? Commented Aug 1, 2023 at 21:13
  • @Panki I don't have ext filesystems (have xfs). Will resize2fs work here? Commented Aug 1, 2023 at 21:14
  • 1
    @Chanel Resizing the root LV can be done anytime after step 7. After that step you will have unallocated space in the VG that you can then use. Commented Aug 2, 2023 at 15:59

1 Answer 1

1

It was a success! For future reference, here are the steps I followed to reduce the size of home and increase the size of root.

  1. Booted from a RHEL ISO, went into troubleshooting mode, and dropped to the shell.
  2. Activated the volume group: vgchange -ay
  3. Temporarily mounted the volumes
 mkdir /mnt/sysimage/rt mkdir /mnt/sysimage/backup mount /dev/mapper/rhel_ylntest-home /mnt/sysimage/rt/ mount /dev/mapper/rhel_ylntest-root /mnt/sysimage/backup/ 
  1. Initiated the backup: xfsdump -l 0 -L "home lv backup" -M "backup" -f /mnt/sysimage/backup/home_backup.img /mnt/sysimage/rt
  2. Unmounted: umount /mnt/sysimage/rt/
  3. Deleted the logical volume: lvremove /dev/mapper/rhel_ylntest-home
  4. Created the desired size: lvcreate -Zy -L 500G -n home rhel
  5. Expanded the root volume: lvresize -r -l +100%FREE /dev/mapper/rhel_ylntest-root
  6. Formatted the new volume: mkfs.xfs /dev/mapper/rhel_ylntest-home
  7. Mounted the volume: mount /dev/mapper/rhel_ylntest-home /mnt/sysimage/rt
  8. Restored from the backup: xfsrestore -f /mnt/sysimage/backup/home_backup.img /mnt/sysimage/rt
  9. Unmounted everything: umount /mnt/sysimage/rt/ /mnt/sysimage/backup/
  10. Rebooted back to the command line.
1
  • Life saver. Thank you. Commented Feb 7, 2024 at 8:13

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.