New /home created with re-install

Due to a failed upgrade to Fedora 30, I have had to re-install the OS. I already had an existing /home partition and wanted to reuse it as is. However, doing the install a new /home was created (it looks like on another volume). Is it possible to just delete the new /home and then create a mount point for the old /home or is there something more involved?

1 Like

Let’s check the current configuration:

grep -v -e "^#" -e "^$" /etc/fstab
sudo vgs; sudo pvs; sudo lvs
sudo vgdisplay; sudo pvdisplay -m; sudo lvdisplay -m

Here is the output from the commands:
sda 2.7T disk
├─sda1 32.3G part ext4
├─sda2 1K part
├─sda5 16.2G part swap
├─sda6 1.1T part ext4
└─sda7 1.6T part ext4
sdb 232.9G disk
├─sdb1 170.1G part ext4 /homeorg
├─sdb2 37.3G part ext4 /
└─sdb3 13G part swap
sr0 1024M rom
[root@DBServe ~]# grep -v -e “^#” -e “^$” /etc/fstab
UUID=844d78b0-1e46-4d21-abcd-b62061296c87 / ext4 defaults 1 1
UUID=70ce45ad-5bc8-425b-ab83-6018ee1f0139 /homeorg ext4 defaults 1 2
[root@DBServe ~]# sudo vgs; sudo pvs; sudo lvs
[root@DBServe ~]# sudo vgdisplay; sudo pvdisplay -m; sudo lvdisplay -m
[root@DBServe ~]#

I created the mount point /homeorg so that I can at least access the files that are stored there for the restore of the system but that is the one I would like to have as the default /home

Make sure the partition is mounted and the new username matches the old one:

sudo mount -U 70ce45ad-5bc8-425b-ab83-6018ee1f0139 /mnt
ls -l -d /home/${USER} /mnt/${USER}

Fix your home directory ownership and permissions to match the new UID and GID:

sudo chown -R "$(id -u ${USER}):$(id -g ${USER})" /mnt/${USER}
sudo chmod -R "u=rwX,g=,o=" /mnt/${USER}
sudo umount /mnt

Fix /etc/fstab:

sudo sed -i -e "s|\s/homeorg\s| /home |" /etc/fstab

Reboot and access your new home:

sudo mount /dev/sdb2 /mnt
ls -l -a /mnt/home
sudo rmdir /homeorg

Although, reboot is not mandatory if you logout and run the commands in a text VT or via SSH, but it may require some additional actions.

1 Like

Probably you’ve just haven’t pointed out to installer that you already have a /home you want to reuse. You’ve said to it to make new root (you have formatted new root, haven’t you) and no other partitions, so /boot and /home were created just as subfolders on your root partition.

That’s judging from your /etc/fstab.

By the way, you’re nor using UEFI boot, as far as I can see. Is it intentional an are you ok with it? As you’re reinstalling anyway, right now is a good time to decide, it can get much harder to change your decision later.

From what I know – I’m 95% sure it works this way – you can even mount your old home as /home without deleting anything – and it’ll work. It’s still a bad idea though and prone to lead you to confusion in the future, don’t do it.

But it actually works like this.

When you have /dev/sdb1 mounted as /home – you see (change, add/delete, etc) the contents from /dev/sdb1. When you unmount it – you see the contents of the /home folder in the root directory (and now can modify files from this directory). I’ve tested it a bit – not with my /home, of course!Linux is versatile enough to allow such things. But still we won’t do it.

So the short good answer is yes, you can.

To do it properly you need either to to be either (1) chrooted to this install from the Live USB session (you already know how to do it) or (2) to be logged in to your installed Fedora system as root via tty (text console accessible by pressing [Ctrl]-[Alt]-[F3] (or F2, 4, 5, or 6), not via graphical DE, and all the users of the system must be logged out.

You need it this way so that /home directory won’t be in use and can be moved/deleted/manipulated in other ways.

Way (2) is simpler in my opinion, as it doesn’t require rebooting to Live USB and chrooting.

You would need

  1. Login as your user with sudo/admin privileges – either using graphical login or text console, doesn’t matter.

  2. You need to activate root account as it’s disabled by default on new Fedora installations. You do it this way:

    # sudo passwd
    [sudo] password for your_current_user: <enter *your* current password here>
    Changing password for user root.
    New password: <enter new password for *root* account>
    Retype new password: <retype *root* password>
    passwd: all authentication tokens updated successfully.
  3. Now logout as your user, go to tty3 by pressing [Ctrl]-[Alt]-[F3], login there as root.

  4. Rename current /home just to be safe:

    mv -v /home /home_backup
  5. Make a new empty home directory/mountpoint

    mkdir -m 755 /home
  6. Unmount /homeorg and remount it as /home

    umount /homeorg
    mount /dev/sdb1 /home
  7. Check you can actually see what’s inside there – just in case.

  8. Edit your /etc/fstab, change

    UUID=70ce45ad-5bc8-425b-ab83-6018ee1f0139 /homeorg ext4 defaults 1 2


    UUID=70ce45ad-5bc8-425b-ab83-6018ee1f0139 /home ext4 defaults 1 2

    so that your computer knew to mount what was /homeorg as /home on the next boot.

  9. Just to be safe make a chown on you home directory and restore SELinux file contexts for it. Lets say your user account called phild.

    chown -Rv phild:phild /home/phild
    restorecon -Rv /home
  10. I think you should be good to go at this point and can reboot the computer.

After reboot you can check again from tty3 that /home contains your OLD data as it should, and then login as usual using graphical DE.

P.S. And you can now safely delete /home_backup if you’re sure you don’t need any data from it.

1 Like

Thanks for the suggestions - I did try removing (renamed) the new /home and created an entry in the fstab for the old /home and rebooted. It put me into maintenance mode so I backed out those changes. As this was the first time doing a re-install with Fedora, I wasn’t 100% as to what to respond when prompted for the partitions. I realize now I could have referenced the old /home without formating and that would have been the end of my problem. I have come up with a solution which appears to be working - will continue to monitor. The solution was to rename the new /home (/homebkup) and then created a symbolic link between a new /home directory and the old /home directory. All seems to be good with this so far.

As for not creating a UEFI boot - the system is a multi-boot between another OS and Fedora although most of the time its booted in Fedora.

Now onto my network issue with the machine.

You’ve already had that entry, you just have to change it from /homeorg to /home. Along with other preparations, of course. Adding a new entry could be an error.

Me personally – I would still switch them properly. But that’s me :slight_smile:

It’s totally ok if it’s intentional and conscious choice.

Edit: I probably should have said it in case you don’t know. The most obvious and in this particular case most probable reason of dropping to emergency mode is your system being unable to mount one (or more) of the partitions specified in /etc/fstab. I think there was some mistake with the entry you’ve added that led to this.