0

My computed had a small 120GB sata SSD and a 1TB HDD, I used to use a partition of the SSD for the / mountpoint, and the HDD cached with bcache by another partition of the SSD for /home

Now I have a 1TB nvme SSD as well, but I'm wondering how to integrate it with the HDD already to keep the extra storage, but using 2 drives for the /home (with some folders going to the HDD like downloads and videos) and some files going to the nvme (like big workfiles or installations with data at /home) is quickly becoming annoying.

How would you combine the two drives into a single volume, without losing much of the performance of the nvme or much of the 2TB total space?

metichi
  • 897

1 Answers1

1

If you would like to have some of your /home directory on the SSD with a few sub-directories on another device, you can do this by partitioning the HDD and mounting those partitions as directories in /home.

For example:

  • you would like to have ~/Downloads and ~/Videos on the HDD
  • you expect ~/Downloads will never exceed 100GB
  • you want ~/Videos to use as much space as possible

To do this:

  1. Create two partitions on the HDD using fdisk or Disks.
    For the sake of this example, we'll call them /dev/sda1 for the downloads, which is 100GB in size, and /dev/sda2 for videos, which is 900GB in size.
  2. Format the partitions:
    sudo mkfs -t ext4 /dev/sda1
    sudo mkfs -t ext4 /dev/sda2
    
  3. Mount the partitions to the appropriate locations:
    sudo mount /dev/sda1 /home/metichi/Downloads
    sudo mount /dev/sda2 /home/metichi/Videos
    
  4. Ensure you have proper permissions on the new locations:
    sudo chown -R metichi:metichi ~/Downloads
    sudo chown -R metichi:metichi ~/Videos
    

So long as everything is good, you can update the /etc/fstab file to auto-mount these locations at boot time:

  1. Make a backup of fstab:
    sudo cp /etc/fstab /etc/fstab.orig
    
  2. Edit the /etc/fstab file as sudo with your preferred text editor. Add these lines:
    /dev/sda1    /home/metichi/Downloads    ext4    defaults    0    0
    /dev/sda2    /home/metichi/Videos       ext4    defaults    0    0
    
  3. Reboot your system and make sure it all works

Be sure to replace metichi in the examples above with your actual username.

Notes: Make sure your existing ~/Downloads and ~/Videos directories are empty when you are doing this, or you may lose access to the files already there.

matigo
  • 22,138
  • 7
  • 45
  • 75
  • 1
    Suggest using UUID or Label in fstab entry. If I plug in a flash drive or external SSD, my drives often change order. Then you will not be mounting correct partition(s). https://help.ubuntu.com/community/Fstab I do like to label all my partitions. I use gparted, disks or command line to set labels. https://askubuntu.com/questions/276911/how-to-rename-partitions – oldfred Apr 27 '21 at 13:56
  • That’s a very good point – matigo Apr 27 '21 at 14:02