Ubuntu – How to symlink certain directories in /home to an SSD

ssdsymbolic-link

In Is a 40GB SSD practical to use for ' / ' Jorge describes how he symlinks things in his /home that would benefit from being on an SSD. How is this done?

I've figured that I need to do the following:

  1. Create a directory on the SSD to hold what I want to link from /home, e.g. mkdir /var/jorge.
  2. Move the things from /home that should be on the SSD, e.g. mv /home/jorge/.config /var/jorge.
  3. Create the symlinks, e.g. ln -s /var/jorge/.config /home/jorge/.config.

Is this the correct way to proceed? Do I need to do it from a live CD?

Best Answer

You can do it from a Live CD, but if you logout from a graphical session and switch to a virtual console using Ctrl + Alt + F1, you'll be able to move the folders too.

Your steps are correct, some expansion below:

  1. Switch to a virtual console and login
  2. Mount the SSD if needed, that can be as easy as:

    sudo mkdir /media/ssd-store
    sudo mount /dev/disk/by-label/YOUR-SSD-NAME /media/ssd-store
    

    You can use tab-completion after /dev/disk/by-label/. This only works if your partition has a label, otherwise you need to replace it by /dev/sdXY

  3. create a folder that holds the files from home:

    sudo mkdir -p /media/ssd-store/home/jorge
    

    If you've a custom umask setting like 0027, you need to sudo chmod 755 /media/ssd-store. You can check your umask setting by running umask (defaults to 0022)

  4. Change the ownership if needed, so the user can always create more symlinks if needed:

    sudo chown jorge: /media/ssd-store/home/jorge
    
  5. Move the files (add sudo if you do not own /media/ssd-store/home/jorge):

    mv /home/jorge/.config /media/ssd-store/home/jorge/
    
  6. Create the symlink:

    ln -s /media/ssd-store/home/jorge/.config /home/jorge/
    

Notes on the above: you should add an entry in /etc/fstab for automounting the SSD. Use sudo blkid to determine the UUID for your SSD partition and add the next line to /etc/fstab:

UUID=[uuid] /media/ssd-store ext4 relatime,errors=remount-ro,discard 0 2