1

I am entirely new to Ubuntu and my question here touches the somewhat confusing (at least for me) theme of disc partitioning.

I've recently bought a new laptop with 250GB SSD and 1TB HDD hard drives with the simple idea of installing all the applications and OS onto the SSD, and put all my files (documents, music, videos...) onto HDD. This is simple to do in Windows, since the disks are displayed, however in Ubuntu, that is not the case.

I am aware there are a ton of similar questions on this site relating to partitioning, but these are for a newbee user, like myself, too complicated (seeing that I do not seek to dual boot with Windows and related questions..). I have recently copied all my files (about 150GB) to /home/Documents and upon executing the df -h command, this was the result:

Filesystem      Size  Used Avail Use% Mounted on
udev            7,8G     0  7,8G   0% /dev
tmpfs           1,6G  9,6M  1,6G   1% /run
/dev/nvme0n1p3  198G  179G  9,0G  96% /
tmpfs           7,8G   16M  7,8G   1% /dev/shm
tmpfs           5,0M  4,0K  5,0M   1% /run/lock
tmpfs           7,8G     0  7,8G   0% /sys/fs/cgroup
/dev/loop4       87M   87M     0 100% /snap/core/4917
/dev/loop0      141M  141M     0 100% /snap/skype/45
/dev/loop2      133M  133M     0 100% /snap/skype/41
/dev/loop1      194M  194M     0 100% /snap/firefox/103
/dev/loop3      194M  194M     0 100% /snap/firefox/107
/dev/loop5      144M  144M     0 100% /snap/gnome-calendar/28
/dev/nvme0n1p1  746M   25M  722M   4% /boot/efi
tmpfs           1,6G   88K  1,6G   1% /run/user/1001

Not seeing a HDD disk anywhere in addition to 179GB of used space on a 198GB partition then means, that /home/Documents directory is located on SSD. This, I assume, is also true for /home/Music, /home/Pictures, etc.

To see, where exactly is my HDD, I executed the lsblk command:

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 931,5G  0 disk 
loop0         7:0    0   140M  1 loop /snap/skype/45
loop1         7:1    0 193,6M  1 loop /snap/firefox/103
loop2         7:2    0 132,1M  1 loop /snap/skype/41
loop3         7:3    0 193,7M  1 loop /snap/firefox/107
loop4         7:4    0  86,9M  1 loop /snap/core/4917
loop5         7:5    0 143,5M  1 loop /snap/gnome-calendar/28
nvme0n1     259:0    0 238,5G  0 disk 
├─nvme0n1p1 259:1    0   750M  0 part /boot/efi
├─nvme0n1p2 259:2    0     5G  0 part 
├─nvme0n1p3 259:3    0   201G  0 part /
└─nvme0n1p4 259:4    0  31,8G  0 part [SWAP]

And there it is (sda)! Since there is no mountpoint, I think my problem translates into "how to set sda mountpoint to /home/Documents, /home/Music, /home/Pictures directories, etc.?" Is that really the case (I am asking this in order to clarify the nomenclature)?

If so, my problem then boils down to two questions:

  1. How can you set these /home directories to be located on HDD and
  2. how can you be sure that all the applications will be installed on SSD (provided, you are not installing into the above directories).

I realize this question might have been answered elsewhere already, but I think it is useful to clarify the nomenclature and basic principles here for completely new users, such as myself.

I thank you all kindly for your help and apologize, if the questions seem repeated.

  • 1
    For a newer user that wants separate partition for /home, you use the Something Else install option and create an ext4 partition on HDD for /home. Once installed you can move it. Details: https://help.ubuntu.com/community/Partitioning/Home/Moving A bit more advanced (what I do) is to have a data partition at /mnt/data and link folders from that data partition back into /home. Then the mostly hidden user files in /home are still on faster SSD. https://askubuntu.com/questions/1013677/storing-data-on-second-hdd-mounting – oldfred Jul 23 '18 at 19:55
  • Thank you for pointing me in the right direction, @oldfred! Just to clarify something - you were mentioning the Something Else install option. I take it this means when installing Ubuntu. Is it possible to avoid re-installation of Ubuntu with the first procedure (having set everything up just recently I am reluctant to having to do it all over again)? – Nejc Kejzar Jul 23 '18 at 21:19
  • Did you look at the two links? Either is after an install and moving data to HDD on separate partition. But you should have backups, multiple. With Ubuntu usually easier just to reinstall & restore /home and/or /mnt/data. Best to also export list of installed apps & any system wide settings you do in /etc, like grub, NFS, SSD or server apps folders. Then anytime you can reinstall and not worry about the inevitable HDD or SSD failure. – oldfred Jul 23 '18 at 21:52
  • Ok, understood. I decided to follow your second procedure. However, after inputting my HDD UUID into fstab, the following errors occurred: (gedit:6824): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files, ** (gedit:6824): WARNING **: Set document metadata failed: Setting attribute metadata::gedit-spell-enabled not supported and ** (gedit:6824): WARNING **: Set document metadata failed: Setting attribute metadata::gedit-encoding not supported. Any ideas why? – Nejc Kejzar Jul 24 '18 at 09:55
  • https://askubuntu.com/questions/798935/set-document-metadata-failed-when-i-run-sudo-gedit] this link presumably states, that these warnings can be ignored. I therefore continued with your procedure and when I completed the first move with ln -s /mnt/data/Desktop, the Desktop link was marked as broken, since apparently /mnt/data/Desktop target does not exits. Clearly, the /mnt/data file was created (if I check under Folders), yet indeed, there is no copied Desktop in it. – Nejc Kejzar Jul 24 '18 at 10:30
  • I do not move Desktop as that is not part of my files. It is just the icons on desktop & anything in /home that is configuration, I want on SSD for speed of loading. Main exception I have is .mozilla & .thunderbird as I also move those profiles and in /home edit profile.ini to find profile in /mnt/data. – oldfred Jul 24 '18 at 15:02

1 Answers1

3

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.