When I start my ubuntu server, my two USB hard disks are typically not automatically mounted. However, if I unplug the disks and and plug them back in, they're detected and mounted. How can I ensure that they are automatically mounted at startup?

There is no entry for these disks in /etc/fstab. Would this be a good starting point?

  • Are there any errors or anything of that sort in /var/log/syslog or /var/log/dmesg that are related? – Sly Oct 3 '12 at 21:45
  • I've had a similar problem, but never in ubuntu, attempt to use different usb ports and report back as I've seen that fix the problem before. – user88311 Oct 3 '12 at 21:58

I use an entry in /etc/fstab but be sure to mount them by uuid and not by device because the USB disks order can change at startup. For example the device can change from sdc to sdb if one of the disks is turned off and you won't be able to mount them in the right place if this happens.

To mount by uuid you can use in /etc/fstab for example:

UUID=39bfe182-225b-44e7-a8f2-982e4b401c4f   /mountpoint ext4    defaults    0 0

To find the uuid of your devices, you can use:

sudo blkid

or ls -la /dev/disk/by-uuid

Graphically you can use gparted (installable from software center), right-click on each partition and select Properties (or information - not sure how is the English menu)

| improve this answer | |
  • This seems to ring a bell =) How exactly do I obtain the UUID? – blz Oct 4 '12 at 8:43
  • @blz - Answer edited to add this part. – laurent Oct 4 '12 at 12:21
  • You should note that your answer wrecks havoc when using a headless server and you suddenly decide to boot without the usb drive plugged in. Your startup will probably pause and wait for you to confirm what to do (like skip or try again) – Jonathan Komar Apr 3 '15 at 20:33

Automation of per-user and system-wide automatic mounting are described in the Ubuntu Wiki. The solution @laurent cited is consistent with one of the system-wide solutions described in the article.

If you prefer a per-user solution that acts as if you dynamically plugged the device in, you can follow the Wiki instructions:

  1. Open a terminal
  2. Type mount and find the device name / partition associated with the removable device:

    /dev/sdb1 on /media/Bleh type vfat ...

  3. Find the UUID of the partition by searching for the device name in the output of ls -la /dev/disk/by-uuid/:

    lrwxrwxrwx 1 root root 10 2012-10-01 02:30 3aafa0c9-52ca-4840-807a-813a4db5be2f -> ../../sdb1

  4. With the UUID, you can kick off udisks to act as if you just plugged in the device:

    /usr/bin/udisks --mount /dev/disk/by-uuid/3aafa0c9-52ca-4840-807a-813a4db5be2f

If you have Gnome installed the Wiki suggests you add this command to your startup applications:

  1. Press Alt-F2 and type gnome-session-properties
  2. Push the Add button
  3. Add the command with a meaningful name and push the Add button
| improve this answer | |
  • Thanks for the response, but I don't have Gnome installed on this server, hence my search for a command-line alternative. – blz Oct 4 '12 at 17:08
  • I believe udisks is also used when automounting on a headless server when you plug your device in. The command should behave as if you just plugged the device in. That said, @laurent's solution is probably better in your case. – Terrance Oct 11 '12 at 14:23

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.