I have Ubuntu 16.04 installed on a small SSD, and have a separate 500GB hard drive for bulk data.

However, after booting, this separate data drive is invisible when trying to access it from the command line. For instance, if I try to cd to it with:

cd /media/jorn/Data

Bash return a No such file or directory error.

To resolve this, I have to open the files system explorer and go to the drive. Only then does it show up in the terminal (without needing to restart the terminal).

My question is: Is there a way to trigger this 'initialization' automatically? Or perhaps through a terminal command that I can then put into .profile?

I have seen this question about mounting a drive automatically at start up, but that option is already turned on for the drive in question. I'm not sure this is a problem with mounting any ways.

This question seems to ask about the same problem, but it asks about an external hard drive, and the question linked in the comments talks about a corrupted NTFS partition. While my drive is formatted in Ext4.

  1. Use lsblk to determine where your device is mapped. The output is a tree structure that lists each block device. You are looking for the NAME of the partition that you want to auto-mount at startup. For example:

    NAME                   MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
    sda                       8:48   0   2.7T  0 disk  
    ├─sda1                    8:50   0   1.7T  0 part  /media/STORAGE  

    Here I have mounted the device /dev/sda1 (which is really just a drive partition) to mountpoint /media/STORAGE. Note that if your partition is already mounted, you should already see a mount point (in your question, you mention /media/jorn/Data). If your drive isn't mounted, however, you will not see a mountpoint. To make things easier, you may want to use your "filesystem explorer" trick to get the drive to mount. My suspicion is that you will not see a mount point for this drive after startup until you open the drive in file explorer. If you do, then there is likely something else going on.

  2. Use sudo blkid to determine what the UUID of your device is. In the previous step, we determined that the device NAME was sda1. sudo blkid shows the following for me:

    /dev/sda1: LABEL="STORAGE" UUID="70F1E34232C78194" TYPE="ext4"

    Copy that UUID. Also note that the full path to this device is /dev/sda1. And finally, I am assuming that you have formatted your drive as ext4, which you mention in your question. If you haven't, you will see something different for TYPE, perhaps TYPE="ntfs". This is important later on!

  3. Create a new directory where your device should be mounted. For example, here I am using /media/STORAGE. If this directory doesn't already exist, the device will fail to mount there.

    sudo mkdir /media/WHAT_YOU_WANT_TO_NAME_IT
  4. Edit your fstab file: sudo nano /etc/fstab (you may want to make a backup copy of this file first, in case something goes wrong here). See if there is already an entry in this file that starts with either the full device path (/dev/sda1 in my case) or the UUID you found in the last step (UUID="70F1E34232C78194" in my case). If so, then perhaps this entry isn't formatted properly. If not, then add the following line to the end of this file (using your own UUID and mountpoint, of course):

    UUID=70F1E34232C78194 /media/STORAGE ext4 rw,noexec,nosuid,nodev,uhelper=udisks2 0 0

    Remember back in step 2 I mentioned the device type being ext4? Notice that the type in the above line is ext4. If your drive was formatted as something else, like ext3, ntfs, etc., then you will need to use the correct type for your device in fstab! See the documentation for details.

  5. Save that file and reboot. The drive should now auto-mount at startup.

  6. If for some reason your machine fails to boot afterwards, there is likely an issue with the content you added to /etc/fstab. This is easily fixable by rolling back the change you made to this file earlier.

See also the fstab format documentation and the relevant man pages for these commands.

  • 2 things. 1.) I can't find the uhelper option on the Fstab page. What does it do? 2.) If my system fails to boot, how would I roll back the change? Would I have to put the drive into another system? (I'm not running dual-boot). – Jorn Vernee Mar 18 '17 at 15:23
  • @JornVernee The system will likely boot after failing to find the drive for 90 seconds. Even if it doesn't, you will be dumped to a terminal where you can edit the fstab file. This has happened to me several times in my haste, and it's never been an issue. uhelper is an unmount helper option (see the man page for more information. To be honest, I've just always used this without really having a good reason to. You possibly don't need this at all. See also manpages.ubuntu.com/manpages/xenial/man8/umount.udisks2.8.html – user8675309 Mar 18 '17 at 15:27
  • As a note: I accidentally fixed the problem by changing the automatic mount point in the default 'Disks' utility (it was something else than /media/jorn/Data), as I was trying to see if these options would affect the fstab file. The entry: /dev/sda1 /media/jorn/Data auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-name=Data 0 0 appeared in /etc/fstab/ . I will accept this answer since steps 1-4 helped diagnosed the problem. Thanks for the help :) – Jorn Vernee Mar 18 '17 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.