1

I recently got a new laptop and have installed Ubuntu 18.04 on it. However, I have an issue: I do not have a lot of storage space.

I want to add an new, larger internal drive to my laptop and use that new drive as my /home directory. I understand this is normally set up during installation. However, I would like to avoid reinstalling because doing that on this laptop IS A HUGE PAIN.

So, my question is: is there a way to set up a system to use another internal drive as /home? I figure I could probably edit a config file somewhere but I'm not well versed in the lower level workings of Linux so I have no idea where to look.

1

I assume all you care about is to get your personal files on the new disk?

If so see ~./config/user-dirs.dirs. That one can be altered to adjust the location of the directories in home. Point them to your new partition and you can keep your system and user settings on the system disk.

Putting /home on its own disk might lead to problems when that disk is not ready when the system expects it to be.

0

You create a new filesystem on the new drive, move everything in /home to the new filesystem, and mount that filesystem on /home. Do this while in maintenance mode or booting from a live CD/DVD/USB distro.

0

To be thorough.

Login as root.

Partition and create a new filesystem on the new drive. Mount the new drive. We'll just give a generic mountpoint of /mnt/newdrive. Use rsync to copy the contents over

rsync -avhH /home/ /mnt/newdrive/ That will preserve modify dates, etc

Edit /etc/fstab and add an entry to mount the new drive in /home. You can just copy the old mount for /home and change the drive that is being mounted to /dev/sdb1 (placeholder for what your new drive is). Comment out the old entry.

Reboot and log in as root.

That will mount the internal drive in /home at boot and ignore the old one as it's been commented out. Once you have verified that it's working, you can remove the old one in /etc/fstab altogether.

All done.

  • The fly in the ointment is things that are using the old /home at the time. These can include in-progress mail delivery, running per-user service managers (systemd and otherwise, with special attention to linger mode), open GUI desktops, and several kinds of actual per-user services that put RPC (special) files in one's home directory. Login as root. is not thorough enough. (-: – JdeBP Sep 12 '18 at 12:33
  • @JdeBP I saw that and added some things that I had forgotten before. By commenting out the entry in /etc/fstab for the old home directory and then rebooting and logging back in, the new drive/partition is mounted in /home at boot and not the old one which avoids the things that you've mentioned. I do this regularly when setting up Linux VMs in Horizion View Manager where I work as they have NFS-mounted home directories which I have to set up after the install and I've not had a single problem. – Nasir Riley Sep 12 '18 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.