Practical questions about disk partitioning, moving the /home directory and shrinking the / system directory.

Nils Kassube kassube at gmx.net
Mon Jul 15 20:40:13 UTC 2024


On 15.07.24 Bas G. Roufs wrote:
> Op ma 15 jul. 2024 08:49 schreef Nils Kassube <kassube at gmx.net>:
> > Ah OK, so you made a copy of /home to the new partition. But IMHO that
> > isn't ideal. You want to mount the new partition as /home, so the contents
> > of /home should now be in the top folder of sda5. As an example, your $HOME
> > was /home/bas before . If you now mount sda5 to /home, you would find the
> > bas folder in /home/home-new/bas which is not exactly what you want.
> 
> You might be right...
> 
> Three times, I tried to start the laptop this morning. ...  The first two
> attempts ended up in a complicated emergency mode... Only the third attempt
> was successful. However,  I quickly shut down again. Probably,  the system
> is confused because of the presence of two identical home directories in
> two different partitions.

Certainly the problem is somewhere else, I'll try to explain. The system doesn't care if there are folders named home on several partitions. However the system needs a folder /home with the subfolders for the users registered on the system. First of all the system needs a / folder defined in /etc/fstab. According to your previous mails, / is on sda3, so there should be an entry in /etc/fstab for sda3 to be mounted at /. And you also want to use a separate partition for /home. Therefore you need an additional entry in /etc/fstab for sda5 to be mounted at /home. However that can only work if there is a folder /home on the sda3 partition which will be used as the mount point. So /etc/fstab might look like this:

/dev/sda3 / ext4 defaults 0 1
/dev/sda5 /home ext4 defaults 0 2

Actually sda3 and sda5 are named with LABEL=... or UUID=... but for clarity I used the device names. Now you need the $HOME folders for the registered users in /home and these subfolders should be in the top folder of sda5 which is mounted at /home. If they are in a subfolder of /home it doesn't work, i.e. you can't log in. So if you have a look at /home when everything is mounted there should be a folder /home/bas (or whatever your user name is on the machine). That should suffice if you want to log in as user bas. As you had problems when starting the laptop, I suppose there is something wrong with a missing /home or incorrect location of the $HOME subfolders. Can you send your /etc/fstab file please and the output of the command

ls /home

> > I think you have two options now.
> >
> > 1. Move everything from the home-new folder to the top folder of sda5.
> > Then you need only one fstab entry:
> >
> 
> (...)
> 
> I tend to act according to the possible solution you summarise here
> above....
> 
> Concretely, I think about the following steps in ONE SINGLE  SESSION. Any
> suggestions when reading them?
> 
> Step 1.  «Home-ori» in sda3.
> =====≠=================
> I open the terminal and launch Midnight Commander via sudo mc. Then, I
> navigate to the old home in sda3 at the left side. I navigate to sda5,
> Camino-casa, at the right side. Then, I rename the old home in sda3 to
> home-ori: via the root-command line  down under Midnight Commander.

Sorry, I'm not familiar with MC - I only used it a few times last millenium and I don't remember how it works :)
Anyway, what do you mean when you write navigate to sda3 and sda5? Do you use a live system? After renaming (sda3)/home to home-ori you should also make a new (empty) folder (sda3)/home because that one is needed as the mount point.

> Step 2. «home-new» > «home» @ sda5.
> ================================
> 
> At this stage, I stay in Midnight Commander. I want to deal with
> Camino-casa, sda5 - more then 3 quarter of the 1 TB disk. There, I want to
> rename «home-new» into «home». Like this, «home» will get at the «top
> folder position» of sda5.

I thought you wanted to go with my first option? Then you should not rename that (sda5)/home-new but move the contents from (sda5)/home to (sda5)/ So e.g. (sda5)/home-new/bas should be moved upwards to become (sda5)/bas and likewise for the other users you might have on the machine.

> Step 3. Comparison old and new home.
> ================================
> In this stage, I'll compare the old home folder at sda3 with the new one at
> sda5. Primarily, I wanna do so via sudo mc, Midnight Commander in the
> terminal. However, at some point, I also might invoke Dolphin.

Well, if you follow my description for step 2, here you should rather compare (sda3)/home-ori to (sda5)/.

> Step 4. Delete home-ori @sda3.
> =========================
> In this stage, I still stay with sudo mc, Midnight Commander.  If the
> comparison in step 3 will go well, I'll delete home-ori at sda3.
> 
> Step 5. Adaptation of /etc/fstab
> ==========================
> Midnight Commander allows to quickly find /etc/fstab. It offers several
> possibilities to edit it when using sudo mc. I'll do so according to your
> suggestion. ....
> 
> 
> 
> > LABEL=Camino-casa /home ext4 defaults 0 2
> >
> 
> Do I need to copy-paste EXACTLY this string into fstab?

Yes, that should work if the label of sda5 is correct. But remember, it should be put in a line below the entry for sda3 on /. Please have a look at the fstab manpage [1] if you want to know the details.

> Thanks for all your advise.
> 
> I would appreciate one more reaction from you.

You're welcome. And don't worry, I would also send more replies if necessary.


Nils

[1] https://manpages.ubuntu.com/manpages/xenial/man5/fstab.5.html







More information about the kubuntu-users mailing list