Mount separate /home partition after fresh install (SOLVED)

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
Rich J
Level 1
Level 1
Posts: 37
Joined: Wed Feb 01, 2012 12:14 pm
Location: United Kingdom

Mount separate /home partition after fresh install (SOLVED)

Post by Rich J »

Hi - I hope this is the correct place to post this query and please move it if not. Excuse the long post.........

The situation so far -
I installed Mint 18.3 64bit on a 160GiB HDD with 2 separate user logins, self and wife. On this install, and following the tutorial from this site, I decided to partition manually to keep the /home partition (and user data) separate in case of future problems - in the past I'd let the installer just 'do it's thing'. The install went well and everything worked flawlessly until I got to the Meltdown/Spectre issue and upgraded to the patched kernel. Then I started to get a series of 'kernel panics' which seemed to stem from interference with either/or Grub and MBR files. (I accept this may not have been the cause of the 'panics' of itself but they happened exactly at the same time and then repeated after each update (via Update Manager) even though kernel updates were not allowed. This suggested that something, somewhere was amiss with my config so I decided to do a fresh install.

Keeping to the original partition scheme, I reverted to Mint 18.1 64bit and installed to the / partition. (I did this in case my copy of 18.3 was perhaps corrupted). The installation went well and everything appears to be as it should and the system boots (and has been upgraded to a patched kernel with no problem). Now the nub -

I had assumed (as there was no apparent reason not to) that the fresh OS would use the separate /home partition as before but it doesn't. It is there of course, but it appears as a separate device in 'Computer' (the same as plugging in a usb device) and can be mounted manually. The problem is, both logins can 'see' the other's container folder and access them. Is there a way to mount each user's part of /home (the original) automatically on login without access to the other? On the Desktop, there appears a 'Username Home' folder which is empty, of course, as it is the one generated by the fresh install. I could transfer the data files to this folder on each login separately but it defeats the object of keeping the data away from the system files and it is on a relatively small area on the disk.

This is the current partitioning scheme -

Code: Select all

Disk /dev/sda: 149.1 GiB, 160041885696 bytes, 312581808 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0001ba51

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048   3905535   3903488   1.9G 83 Linux
/dev/sda2         3907582 312580095 308672514 147.2G  5 Extended
/dev/sda5         3907584  42966177  39058594  18.6G 83 Linux
/dev/sda6       304769024 312580095   7811072   3.7G 82 Linux swap / Solaris
/dev/sda7        42969088 304752639 261783552 124.8G 83 Linux
- where /sda1 is boot, /sda5 the system and /sda7 the /home partition.

If this is not possible (or difficult) to achieve, could I move the 'new' /home/username folder to the existing /home partition post-install and then copy over the data to that? And repeat for each login?

Any advice would be very welcome - thanks in advance!

Rich
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Rich J
WharfRat

Re: Mount separate /home partition after fresh install

Post by WharfRat »

Rich,

I used this procedure to retrofit a home partition.

I left out the step to copy the current home content to the new home partition since you already have one

If /dev/sda7 is not formatted ext4 then change FMT to the correct file system e.g., FMT=ext3

Enter one line at a time:

Code: Select all

PART=sda7
FMT=ext4
sudo cp -a /etc/fstab /etc/fstab.old
sudo mkdir /mnt/newhome
sudo mount -t $FMT /dev/$PART /mnt/newhome
sudo chown $USER:$USER /mnt/newhome
cd /home
sudo umount /mnt/newhome
sudo mv /home /old_home
sudo mkdir /home
sudo mount /dev/$PART /home
echo -e "# /dev/$PART \n$(blkid|grep $PART|grep -wo "UUID=\"[^\"]*\""|tr -d '"')  /home   $FMT   errors=remount-ro,noatime  0 2" |sudo tee -a /etc/fstab
If all is good after rebooting then you can sudo rm -r /old_home and sudo rm /etc/fstab.old
User avatar
Rich J
Level 1
Level 1
Posts: 37
Joined: Wed Feb 01, 2012 12:14 pm
Location: United Kingdom

Re: Mount separate /home partition after fresh install

Post by Rich J »

WharfRat wrote: Thu Apr 12, 2018 7:26 am Rich,

I used this procedure to retrofit a home partition.

I left out the step to copy the current home content to the new home partition since you already have one

If /dev/sda7 is not formatted ext4 then change FMT to the correct file system e.g., FMT=ext3

Enter one line at a time:

Code: Select all

PART=sda7
FMT=ext4
sudo cp -a /etc/fstab /etc/fstab.old
sudo mkdir /mnt/newhome
sudo mount -t $FMT /dev/$PART /mnt/newhome
sudo chown $USER:$USER /mnt/newhome
cd /home
sudo umount /mnt/newhome
sudo mv /home /old_home
sudo mkdir /home
sudo mount /dev/$PART /home
echo -e "# /dev/$PART \n$(blkid|grep $PART|grep -wo "UUID=\"[^\"]*\""|tr -d '"')  /home   $FMT   errors=remount-ro,noatime  0 2" |sudo tee -a /etc/fstab
If all is good after rebooting then you can sudo rm -r /old_home and sudo rm /etc/fstab.old
Hi WharfRat and thank you for the swift reply! /dev/sda7 is indeed formatted to ext4 :wink:

I (think) I can follow the logic of what will be achieved by using your method but I have a couple of other questions first, if I may?

As can be seen from the current partition info, after allocating space for boot, / and Swap, the whole of the remaining space has been given over to /home partition. If a 'newhome' partition is created, where will it be? Will it overwrite the 'old' /home? Would I first have to shrink the existing original /home partition, create a 'new' /newhome' partition, transfer the data and then wipe the 'old /home' and then resize? (Possibly got this totally wrong but I've never attempted anything like this before, so please understand my caution!) Also, would your method then return things to normal, i.e. Mint would then treat the new partition as if it had been created at install with all user logins separated?

Rich
Rich J
WharfRat

Re: Mount separate /home partition after fresh install

Post by WharfRat »

This is the procedure I used to create a new home partition in which I had to transfer my original home folder content to the new home partition.

Code: Select all

PART=sda6
FMT=ext4
sudo cp -a /etc/fstab /etc/fstab.old
sudo mkdir /mnt/newhome
sudo mount -t $FMT /dev/$PART /mnt/newhome
sudo chown $USER:$USER /mnt/newhome
cd /home
# You're not doing this -> find . -depth -print0 | cpio --null --sparse -pvd /mnt/newhome/
sudo umount /mnt/newhome
sudo mv /home /old_home
sudo mkdir /home
sudo mount /dev/$PART /home
sudo rm -r /old_home
echo -e "# /dev/$PART home\n$(blkid|grep $PART|grep -wo "UUID=\"[^\"]*\""|tr -d '"')  /home   $FMT   errors=remount-ro,noatime  0 2" |sudo tee -a /etc/fstab
As I stated earlier I left out the step to transfer the home content find . -depth -print0 | cpio --null --sparse -pvd /mnt/newhome/ since your intended home partition sda7 is already populated.

I'm mounting /dev/sda7 to /mnt to make sure the owner:group is set correctly.

You're going to move the original home to old_home, recreate the home folder for the mountpoint and then mount /dev/sda7 to /home.

Later when all is good you will remove old_home.
User avatar
Rich J
Level 1
Level 1
Posts: 37
Joined: Wed Feb 01, 2012 12:14 pm
Location: United Kingdom

Re: Mount separate /home partition after fresh install

Post by Rich J »

Hi WharfRat - apologies for the delayed reply but I had trouble logging to the site earlier - no idea why!

Many thanks for your advice - the commands worked perfectly and all is as it should be. For the time being, I'll hang on to old/home just in case but I don't anticipate problems! I'll now mark this as solved.

Best wishes and thanks again!

Rich
Rich J
User avatar
AZgl1800
Level 20
Level 20
Posts: 11178
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes Sweeping down the Plains
Contact:

Re: Mount separate /home partition after fresh install (SOLVED)

Post by AZgl1800 »

This is a wonderful Tutorial and I bookmarked it for myself as such.

I intend to add a 2nd HDD and want to do the same.

Thank you WharfRat :)
LM21.3 Cinnamon ASUS FX705GM | Donate to Mint https://www.patreon.com/linux_mint
Image
Locked

Return to “Other topics”