2011-01-25

How to automatically mount external hard drive at boot in Ubuntu Lucid Lynx

I have an external USB hard drive connected to my Ubuntu laptop home server that I used to store MythTV recordings and videos.  Ubuntu would mount this USB drive to the mount point I had created when I logged in as my regular user, but not at boot.  I wanted the drive to automatically mount at boot so that after a power failure, or a reboot, I wouldn't have to log in as a user in order to have MythTV work.  After doing some research using Google I tried the following:

  • After logging in as my regular user to make the USB drive mount, I ran mount in a terminal which gave me a listing of all the mounted disks and their mount settings.  I copied down the mount settings for the USB drive and noted which device the USB drive was mounted as (sdb1 in my case).
  • Then I ran ls -l /dev/disk/by-uuid which gave me a listing of the UUID of each mounted partition and I copied down the UUID for the sdb1.  This is the unique identifier for the USB drive.
  • Then I made a backup copy of the fstab file: sudo cp /etc/fstab /etc/fstab.bak
  • Then I opened the fstab file in an editor: sudo nano /etc/fstab
  • Then I added a line to the bottom of the fstab file like this, putting a tab between each value, and using the UUID I noted, the filesystem type I noted, and the mount options I noted:
  • UUID=07955830-0d54-443c-bdba-f111121f6bd3   /media/myth_data    ext4    rw,nosuid,nodev,uhelper=udisks 
  • Then I rebooted and the disk was automatically mounted without me having to log in.