Ubuntu – Storing data on second HDD, mounting

mountpartitioning

I have a new laptop with SSD + HDD. I already managed to set up a dual boot with Windows 10 preinstalled and Ubuntu 17.10.
Ubuntu root, home and swap directories are all on the SSD. In addition I took 500GB from the HDD and created a partition for my data (I called it /mnt).

Now I want to make the operating system store music, downloads, documents, pictures and videos on the HDD data partition, while maintaining /home on the SSD.

I know it has to do with fstab, so I found the file and a way to edit it, but what am I supposed to do now? The general information is not clear enough for me.

Here is my fstab:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#                
# / was on /dev/sdb6 during installation
UUID=cbdf87b9-ddf0-4242-a6b3-12ea1f13c653 /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sdb1 during installation
UUID=7E53-EFDB  /boot/efi       vfat    umask=0077      0       1
# /home was on /dev/sdb7 during installation
UUID=a78d2329-659f-4d6e-a7e3-c54f08dc5bdb /home           ext4    defaults        0       2
# /mnt was on /dev/sda2 during installation
UUID=193e6f14-a677-4f3e-9373-06f6d12c12f0 /mnt            ext4    defaults        0       2
# swap was on /dev/sdb5 during installation
UUID=e8fe7608-591e-40b2-ab28-603b058c87f9 none            swap    sw              0       0

Can someone guide me step by step?

Best Answer

Best not to use /mnt, but create a new /mnt/data or just /data. You may want other mounts in /mnt and those would remove the data partitions (I have done that in testing a /mnt of something).

After you copy all your data folders like Music to the partition on your other drive. Unmount your temporary mount if it is just temporary.

NOTE: The mount point can be anywhere. If it's in your /home or /media folders it will show up under "Places". If it's directly off "/" or /mnt it will not. I prefer /mnt so I do not see it other than thru the links.

sudo mkdir /mnt/data
sudo chown $USER:$USER /mnt/data
sudo chmod -R a+rwX /mnt/data

Note: The big "X" will also not make files executable unless they were executable to begin with. find your UUID, entry below shows example with UUID, must be yours

sudo blkid

Edit fstab with your UUID, use ext4 or depending on format:

sudo -H gedit /etc/fstab

UUID=a55e6335-616f-4b10-9923-e963559f2b05 /mnt/data ext4 relatime 0 2

Verify entry is ok, if no errors it is, if manually mounted as above unmount first:

sudo mount -a

from home (cd ~ if not at home) so default location of link is in /home/$USER cannot have duplicate entries, so move current to temporary location, repeat for each folder you want to move.

mv Music oldMusic

Music is then also the folder in the partition mounted as /mnt/data

ln -s /mnt/data/Music

Or link all folders with one command:

for i in echo /mnt/data/*;do ln -s $i; done

You can delete oldMusic after you confirm everything is ok.

it then should be this with l as first char for link.

fred@Z170N:~$ ll
lrwxrwxrwx  1 fred fred     15 Jun 10  2017 Music -> /mnt/data/Music/
Related Question