Installing all applications on a SSD disk and putting all files on HDD disk

Solution 1:

Ok, I've managed to get everything working (with great help of @oldfred) and I would like to post the answer to this problem in a condensed form for any lost soul (like I was), who will stumble upon this problem. I would also like to clarify the nomenclature (such as the meaning of partitioning, mounting, etc.) as it can be very confusing and difficult to even post the correct question if you are new to Linux and Ubuntu. Additionally, I have written everything in extended form, since only dropping the code into the answer is very unhelpful to first time linux users. If anything in this answer will be untrue I ask you to alert me to the error and I will edit the answer.

1. Partitioning

Upon purchasing a new computer with dual disk setup (smaller SDD and larger HDD), the active disk will by the default be the one, which you install Ubuntu onto (usually SSD unless stated otherwise during the installation process - for the extensive guide on disk partitioning during the installation of Ubuntu see here). This also means, that all the /home directory files, such as Documents, Videos, etc. will be stored on the SSD. However these, "stationary" files (documents, music, videos, pictures) do not need the improved performance of the SSD and it is thus in our best interest to put them onto the HDD (to free space on the SSD for programs and applications).

Ubuntu's treatment of disks might be rather annoying for Windows users, since in Windows you could easily manipulate different disks in the Computer directory (the disks were marked as :C, :D, etc. respectively). To simplify this, I highly recommed GParted (you can easily install it with Terminal command sudo apt-get install gparted). In GParted you can easily see all the disks and their respective partitions and to what percentage are they used. Partitioning in essence means exactly what the word itself implies - cutting the available disk space onto multiple segments for different purposes. Now, our HDD disks are usually marked as /dev/sdX, where X is a letter a, b... (depending on how many internal HDDs you have). In the top right corner of GParted you can switch between all available internal disks (which are also marked by their respective sizes). HDD will usually be grayed out by default and it's space unallocated and unpartitioned. To start using the disk, we first need to partition it:

1.1 First we need to create a partition table under Device/Create Partition Table. The most standard table for Ubuntu is GUID Partition Table or gpt in the dropdown menu, so you can go with that.

1.2 With the table created we can partition the disk. Since our intended use for the HDD is storage, we do not need to split the disk into parts, but create only 1 big partition with the size of the HDD in question. ext4 can be used as standard file format, the size will by default be set to the entire unallocated (free) space and the type of partition is simply primary partition. Read more on different types of partition here.

WARNING Partitioning will delete all the information stored on the disk before partitioning, so be sure, to make relevant backups when doing this. In our case, the disk was new, and therefore empty, so this was not needed.

Also, be sure to apply the formed partition by clicking on the green tick.

2. Mounting

With partitioning we have "activated" the disk for usage, but we still need to make the computer "see" this disk. That is what mounting does - it assigns a directory to a certain disk. Any files saved into this directory will thus be saved on that disk. I've come across 2 preferable mount points (directories/files to which we will now bind/mount the disk): Computer/media or Computer/mnt. Of course these are not directories where you would have to mount the disk, but the community seems intent on these two choices predominately.

2.1 First, we will create a directory within either one of these two directories, where we will then put all our documents (this is advisable as /mnt is being used by the system for other things as well). I will name the directory data and create it like this:

sudo mkdir /mnt/data

2.2 Next, since we are rummaging in system files, we need to gain access to the formed directory /Computer/mnt/data (without this step, the files will appear locked in /home folder). Use the command:

sudo chown $USER:$USER /mnt/data

where $USER is replaced by your own username (if you are unsure of this, type whoami into terminal).

2.3 Next, we would like to keep the disk permanently mounted to (after every system boot). For this we first need to determine the UUID (Universally Unique Identifier) of the disk. Type sudo blkid into terminal. The output should look something like this (remember that HDD disks are marked as sdX#, where X is a letter a, b... and # is the partition number):

/dev/sda1: UUID="9ea774e9-f5d9-4fd0-9466-dc1447b52402" TYPE="ext4" PARTLABEL="HDD Storage" PARTUUID="c707796f-8bf9-4e11-8841-17adaa79282e"

Copy the number between "" (in this case 9ea774e9-f5d9-4fd0-9466-dc1447b52402). With this, we will edit the fstab document by typing this into terminal:

sudo -H gedit /etc/fstab

A new document will pop open, and on the end of the document simply add:

UUID=XXXX /mnt/data ext4 relatime 0 2

The first column identifies the disk (replace XXXX with the number you copied previously), the second determines the disk mount point, the third the format of data on the disk (be sure to change this if you chose any other format options during disk partitioning) and subsequent columns are now not so important. Then save the document and close it. If any warnings of the following type are afterwards displayed in the terminal, you can ignore them, as is explained in the link.

2.4 To finish mounting the disk, execute the following command into the terminal:

sudo mount -a

To see if your disk is now mounted, go to Disks in Ubuntu Applications, orient yourself to the disk in question and on the bottom in the Contents section the mount point should be stated.

3. Creating links in /home folder

Now it's time to move all our "stationary" files to the newly mounted HDD. I chose to move the Desktop, Documents, Music, Videos, Pictures and Downloads directories. This ensures that only these documents will be moved and not any applications installed in the /home directory (you can visualize these by pressing ctrl+h), as some guides propose moving the entire /home directory to the HDD disk.

3.1 For each directory you wish to move, simply type into terminal:

mv <dir> <location>

For example, moving Music from /home directory into /mnt/data directory:

mv Music /mnt/data

(Be sure that you are in your /home directory in the terminal, when you are moving. If you are not, type cd ~)

3.2 Lastly, we create links to these files in our /home folder for easy access by writing:

ln -s /mnt/data/<dir> $HOME/<dir>

So, for our example:

ln -s /mnt/data/Music $HOME/Music

Do this for every directory you wish to move and voila. You are done.

This is the easiest solution, that I could find, although there are A LOT of them here (for specific purposes). I hope my exaggerated clarity will keep future new linux users from giving up too soon on this, at first sight overly annoying, but then immensely satisfying OS.