Replace the home directory with /home
Hello,
I just installed KDE Neon, a distribution based on Ubuntu, after encountering numerous problems with Zorin OS.
The fact is that my disk contains a /home partition with my personal files, which was directly linked to my user home folder on Zorin OS.
Now, I find myself with an empty home folder and a /home partition that needs to be mounted but is not part of my installation.
I would like to replace my home folder with this /home partition, how can I do that?
Thank you in advance.
2 réponses
Hello,
"There, I find myself with an empty personal folder and a /home partition that needs to be mounted but isn't part of my installation."
Don't be mistaken, there are hidden files in your personal folder. Type the command ls -a in the terminal and you'll see there's a lot going on! Mainly configuration files.
If you replace the /home of KDE neon with that of Zorin OS, you will encounter errors when running your session since some configuration files will be replaced by a version that doesn’t fit.
The easiest thing in your case is to mount said partition and simply copy/paste from the file browser into your /home the folders you want to recover, but do not copy any folders or files that start with a dot (.config, for example). The only folders that will be useful to you are the Documents, Images, Videos (and possibly Downloads) folders.
Hello,
I agree with jns55 that your home contains all the user profiles that your applications have recorded. By convention, these files are prefixed with a "." and are not displayed in your file explorer (unless you explicitly request to show them) or with the ls command (unless you use the -a option).
I also agree that potentially, the profile files from Zorin and KDE Neon may be incompatible, but that remains unlikely, and in case of malfunction, it will always be time to delete them on a case-by-case basis.
So, to return to the initial question, you need to reference your /home partition in the /etc/fstab file. To do this, you need to find the name of the device that corresponds to this partition. I will now demonstrate how to proceed on my own machine, but you will obviously need to adapt what I explain to your case.
1) List the partitions of your hard drive(s)
For this, we will use parted. It should be installed by default on Ubuntu, but if that is not the case :
sudo apt update sudo apt install parted
Let's list the partitions :
sudo parted -l
Example :
(mando@aldur) (~) $ sudo parted -l [sudo] Password for mando: Model: WDC PC SN520 SDAPNUW-512G-1002 (nvme) Disk /dev/nvme0n1: 512GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 274MB 273MB fat32 EFI system partition boot, esp 2 274MB 290MB 16.8MB Microsoft reserved partition msftres 3 290MB 406GB 405GB ntfs Basic data partition msftdata 4 406GB 407GB 1041MB ntfs hidden, diag, no_automount 5 407GB 411GB 3999MB linux-swap(v1) swap 6 411GB 441GB 30.0GB ext4 7 441GB 511GB 70.9GB ext4
We can see here that the disk is named /dev/nvme0n1 and its partitions are listed as /dev/nvme0n1p1, /dev/nvme0n1p2, etc, as shown :
ls /dev/nvme0n1*
If you have a SATA disk, it will probably be named /dev/sda (for the first disk, /dev/sdb for the second disk, etc.) and its partitions are listed as /dev/sda1, /dev/sda2, etc., as shown :
ls /dev/sda* The /home partition is generally formatted as ext4, and in my example, it is either the 6th or the 7th partition. The size suggests that it is likely the 7th.
We could already use this device name to fill in /etc/fstab. However, the naming of disks and partitions is subject to change (especially if you install a new hard drive), which is why it is better to use the UUID of the partition instead.
2) Find the UUID of the partition
There are two methods.
- With blkid:
sudo blkid
- By examining the symbolic links constructed in /dev/disks/by-uuid:
ls -l /dev/disk/by-uuid/
Example :
(mando@aldur) (~) $ ls -l /dev/disk/by-uuid/ | grep nvme0n1p7 lrwxrwxrwx 1 root root 15 20 Dec 11:30 892fe57c-d4fa-4375-8dbc-9c11c3008208 -> ../../nvme0n1p7 Here we see that the UUID is 892fe57c-d4fa-4375-8dbc-9c11c3008208.
3) Correct /etc/fstab
We modify the file with the text editor of our choice and with root permissions. Several equivalent commands:
sudo nano /etc/fstab # With nano, in text mode pkexec kwrite /etc/fstab & # With kwrite, under KDE
The idea now is to add a line to this file to reference the /home partition. Be careful not to delete the existing lines, and ensure that no line already corresponds to /home. In my case, the /etc/fstab file contains:
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/nvme0n1p6 during installation UUID=b9cbe1a9-3263-44d2-ada6-973c29aa0895 / ext4 errors=remount-ro 0 1 # /boot/efi was on /dev/nvme0n1p1 during installation UUID=C093-C3AA /boot/efi vfat umask=0077 0 1 # /home was on /dev/nvme0n1p7 during installation UUID=892fe57c-d4fa-4375-8dbc-9c11c3008208 /home ext4 defaults 0 2 # swap was on /dev/nvme0n1p5 during installation UUID=daeedf2c-bf28-4cde-8721-48e2b6468f77 none swap sw 0 0 # Windows UUID=ECE69594E6955F9E /media/windows ntfs-3g defaults 0 1
Thus, we see that the important line is:
UUID=892fe57c-d4fa-4375-8dbc-9c11c3008208 /home ext4 defaults 0 2
You, of course, need to correct the UUID. If you want more details about the format of this file, you can check what man fstab says.
From there, we can either reboot or directly mount our /home partition. To better understand what is happening, we will take the second option.
4) Mount the partition
We need to ensure that the mount point (the folder where the partition will be mounted) exists.
sudo mkdir -p /home
Ideally, it should be empty.
ls -a /home
If it is not, it's not a big deal, but you need to be aware of what will happen. Indeed, once the /home partition is mounted, the files initially present in the /home folder will be hidden by those from the mounted partition. Therefore, you will no longer have access to the files originally in /home as long as the partition is mounted in this folder.
At this stage, I recommend logging out of your graphical KDE session and switching to text mode (ctrl alt f1, ctrl alt f2), as many files in your /home are in use when KDE is running. You can always exit your session in text mode (ctrl d) and switch back to graphical mode (ctrl alt f7) later.
Since our /home partition is defined in /etc/fstab, we can omit most of the parameters normally expected by the mount command:
sudo mount /home
We can verify that the partition is properly mounted and that its contents now appear in /home:
mount ls /home
All that remains is to log out of your session in text mode (ctrl d) and switch back to graphical mode (ctrl alt f7).
Good luck