Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
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

2 Answers 2

up vote 2 down vote accepted

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)

share|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

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
share|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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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