[SOLVED] Moving /home from default root LVM installation to new volume group on new disk
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2004
    Location
    Huntington Beach, CA
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Moving /home from default root LVM installation to new volume group on new disk

    Hi all,

    Maybe I'm overthinking this or am missing the forest for the trees, but what seems like a simple operation escapes me.

    I'm running F29 on a "default" installation where the root, swap and home logical volumes are all within the "root" volume group. I want to move home into a dedicated vg on a new pv on a much larger disk. The last time I did this I just moved the data onto a new partition and modified the fstab file accordingly. Now, the only line in fstab that would seem to apply is /dev/mapper/fedora_hallie-root / ext4 defaults 1 1". I can see the mapped /home lv in blkid but don't know how it gets mapped. I've read that the mounting of /home is now controlled by systemd but I can't find anything online (or in the Fedora documentation) that explains how this all now works. I keep seeing references to keeping /home separate for upgrading purposes but can't seem to find the steps to do so when working within LVM.

    I've thought about just removing the existing LV from the root vg and adding a line in fstab pointing to the new location. (I've already installed the new disk with a copy of /home on it in a new lv.) I would also like to do the same with /etc and maybe /usr and /var. Is it really this simple - what am I missing?

    Can someone please help me? This is getting frustrating! Thanks much.

    Sid

  2. #2
    Join Date
    Mar 2019
    Location
    Colorado USA
    Age
    23
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Moving /home from default root LVM installation to new volume group on new disk

    You should be able to use the new LVM partition the same as any other disk and mount it as /home through fstab.

    I have my root VG subdivided for filesystem consistency, as well as a separate disk for /home, and this is my fstab:
    Code:
    [luna@Celestia ~]$ cat /etc/fstab
    
    #
    # /etc/fstab
    # Created by anaconda on Tue May  7 01:45:22 2019
    #
    # Accessible filesystems, by reference, are maintained under '/dev/disk/'.
    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
    #
    # After editing this file, run 'systemctl daemon-reload' to update systemd
    # units generated from this file.
    #
    /dev/mapper/root-root   /                       ext4    defaults        1 1
    UUID=f40ef2d2-9c95-473a-b3d2-3b9c77c09f40 /boot                   ext4    defaults        1 2
    UUID=66A9-1529          /boot/efi               vfat    umask=0077,shortname=winnt 0 2
    /dev/mapper/home-home   /home                   ext4    defaults        1 2
    /dev/mapper/root-public /public                 ext4    defaults        1 2
    /dev/mapper/root-var    /var                    ext4    defaults        1 2
    /dev/mapper/root-swap   none                    swap    defaults        0 0
    I think when they say it's handeled by systemd, they mean that systemd is now in charge of fstab, as implied by that header.

  3. #3
    Join Date
    Dec 2004
    Location
    Huntington Beach, CA
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Moving /home from default root LVM installation to new volume group on new disk

    Thanks for the quick response. I take it you "subdivided" the root VG manually and entered each of the locations using vgsplit? I ask since when I run blkid each LV has a unique UUID. Also, there's no language in my fstab file about running 'systemctl daemon-reload' (or anything else) after editing.

    Thanks again.

  4. #4
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Moving /home from default root LVM installation to new volume group on new disk

    If you have all the contents of your old /home on the new disk in a lv associated with a pv for that new disk, then you could simply comment out the old /home mountpoint from your /etc/fstab and add a new entry in /etc/fstab to mount your new home using the UUID presented by that new lv.
    If your old entry was using /dev/mapper no problems, you should be using UUID and you can use the UUID that blkid returns for your new lv instead of a /dev/mapper/xxx in fstab. The above reply shows an example of that for /boot (obviously if you are not using an ext4 filesystem change that value).

    I would, on your newly created home filesystem just create a file called anything.txt that does not exist on the existing home filesystem, change the fstab entries and reboot. If after the reboot your home filesystem contains that file you have achieved your goal. A bit of a sledgehammer, the below is probably better.

    The safer way is that you could as root after editing /etc/fstab simply umount the existing /home and mount /home to make sure the new uuid entry works, by making sure that new file exists in the new /home. While much safer that rebooting as you can simply change the fstab entries back if it does not work it should be noted that you can only do that if you logon directly as root (which should have a home of /root) and not as yourself first. The reason being that if you logon as yourself first even if you 'cd /' before su-ing to root there may be processes autostarted when you logon that would prevent /home from being umounted. I suppose you could use fuser to identify and kill them all, but easier to logon as root directly if you can. (tip: fedora starts tty sessions as well as a gui session for desktop users, you may have a pretty desktop logon but crtl-alt-f3 and ctrl-alt-f4 will take you to command line login where you should be able to login directly as root if you are comfortable with the command line)

    The 'new' file is important, you need to be absolutely sure you have the correct new filesystem mounted before proceeding, and having a simple file in place is easier than worrying/checking the outputs of df and displays of /dev/mapper entries; doesn't mean you shouldn't check but knowing for certain that that particular file only exists on your new home filesystem is a pretty good indicator that if it is there you have the correct filesystem mounted.

    Once you are happy your new lv is the one being mounted correctly (and do reboot to ensure it is before proceeding) you can use the lvremove (refer to 'man lvremove') command to delete the old lv for home from the original pv to free up space on that disk to expand other lvs or create new ones; and remove the commented line for the old home filesystem from /etc/fstab of course.

    Do not do the same with /etc, /usr and /var. They should remain on the boot disk as they are required to boot the system, there is a reason they do not have separate mount points.
    If the purpose of the exercise is to make more space available on the boot disk you have already achieved that and can simply enlarge those lv definitions and filesystems using the space made available by removing the origional home lv.

    If you boot the system and /home does not mount you will not be able to login as yourself (as the /home directory is needed) but can still login as root to fix the issue. If /etc, /var or /usr are not available you have a brick instead of a computer. Apart from the issue that disks spin up at different rates and the second disk may not be available when needed, there is the issue of hard drive failures where your system could become unbootable if either of the two drives fail; better to have everything needed to boot the system on one disk and make sure you have a restore image so you only have to worry about one boot disk to rebuild when it fails, and yes disks do eventually fail.

  5. #5
    Join Date
    Dec 2004
    Location
    Huntington Beach, CA
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Moving /home from default root LVM installation to new volume group on new disk

    Markdk,

    Thanks much for your detailed explanation. I now (think!) I see how to make the change-over, relying on the UUID as the "baseline" for the reconfiguration. I'll give it a try and let you know how it worked out.

    Sid

  6. #6
    Join Date
    Jun 2005
    Location
    Montreal, Que, Canada
    Posts
    6,082
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Moving /home from default root LVM installation to new volume group on new disk

    I had a small SSD and I ran out of space. I had to shuffle some files on a second device.
    What I did was the following:

    As root
    I created a mount point on / (I called mine /homex )
    I created a partition for the new /home on the second device
    I created a fstab entry for the second device as /homex and ran mount /homex
    I ran rsync to copy over all of /home to /homex
    At this point, you have /home and /homex identical.
    On the / partition you want to rename /homex to /home and /home to /homex
    reboot
    I all is ok, the new /home is in use.
    After confirmation rm -rf /homex
    and cleanup fstab
    Last edited by lsatenstein; 21st June 2019 at 11:03 PM. Reason: Included reminder to do everything as root.
    Leslie in Montreal

    Interesting web sites list
    http://forums.fedoraforum.org/showth...40#post1697840

  7. #7
    Join Date
    Dec 2004
    Location
    Huntington Beach, CA
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Moving /home from default root LVM installation to new volume group on new disk

    Thanks. Your reply helped me understand the process better and I'm planning to make the switch over the weekend.

  8. #8
    Join Date
    Dec 2004
    Location
    Huntington Beach, CA
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Moving /home from default root LVM installation to new volume group on new disk

    So moving /home from within the default lvm group in Fedora 30 proved to be more complicated than first thought. So that others don't have to search for the steps (a process that took hours), here's what worked for me. Note that this was a new installation, not an upgrade from a previous Fedora version. YMMV if this is done on an existing or modified installation.
    1. Created a new volume group on a fresh (new) disk and a new logical volume to be used for the new /home. I used a new disk both for expanded capacity and to avoid configuration issues with the next version of Fedora. I first partitioned the disk, as recommended by RH and the LVM teams, which is not universally accepted as necessary. In this case, the entire disk (1tb) is dedicated to a single volume group. While it is possible to move a LV from one VG to another, I've had problems doing so efficiently in the past.
    2. Using rsync, I cloned the existing /home onto the new /home after mounting the new LV to a temporary mount point.
    3. Added an entry into fstab, mounting the new LV as /dev/vg/lv_home, as with any other add-on storage point. (I also included the necessary file type, etc., information in the fstab entry.)
    4. From the command line on a second virtual terminal, unmounted /home.
    5. Using lvrename, renamed the original /dev/vg/lv_home to /dev/vg/lv_home-old.
    6. As a test, mounted the new /dev/vg/lv_home to /home and everything checked out. Rather than update using the 'systemctl daemon-reload' as was suggested elsewhere, I rebooted. (In case you're wondering, I had read about inconsistent results using the daemon-reload approach.)
    7. On reboot, the new /home would not load correctly, throwing off permission error messages. This resulted from two identifiable issues: first, the permissions on the home folder, and SELinux settings. (FWIW, the system dropped into emergency mode where I could read the journal.)
    8. Running (as root) chmod 755 on the /home folder solved the first problem.
    9. Running "restorecon -R /home" as root solved the SELinux issue.
    10. Rebooted once more and everything worked as expected.
    Being paranoid about potential data loss, I had multiple backups, just in case. I've not yet deleted the original /home logical volume; I'll do that once I've convinced myself that nothing's going to break!
    Hope someone finds this of value.
    Last edited by AlwaysLearning; 12th July 2019 at 04:09 PM.

Similar Threads

  1. Re: Moving my HOME directory to another disk
    By TablePC in forum Using Fedora
    Replies: 4
    Last Post: 23rd February 2013, 01:31 PM
  2. Replies: 0
    Last Post: 14th September 2009, 09:54 PM
  3. Moving my HOME directory to another disk
    By josephmo in forum Using Fedora
    Replies: 8
    Last Post: 9th January 2009, 10:14 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •