I’ve got a number of external USB hard drives connected to my ubuntu server that need to mount to a predictable directory.
When you log into Gnome, the desktop environment does it’s nifty thing and mounts any drive you’ve got plugged in — but if the box reboots, the drives won’t be mounted until the next person logs into the computer.
I needed something that happens at boot time to do this task.
There’s a superuser post that asks this question, but none of the answers were helpful. The highest-rated post relies on a command that doesn’t exist.
So first off, make sure your external drives have a label. The label will be the name of the directory that is the mount point. To edit the label, go to “System > Administration > Disk Utility”, find the drive, unmount it, and click “Edit filesystem label.”
Then, as root, edit your /etc/rc.local and add these lines:
for dev in $(ls -1 /dev/disk/by-label/* | grep -v EFI) ; do label=$(basename $dev) mkdir -p /media/$label $(mount | grep -q /media/$label) || mount $dev /media/$label done
All done!
Related posts:
- Preventing an external hard drive from idling on ubuntu
I got a Seagate FreeAgent Pro external hard drive for backups (JWZ has a very straightforward article about this). It happily reformatted to ext3, and I kicked off an rsync...... - HOWTO install etherpad on ubuntu 9.10
Etherpad was opensourced by google, and has some generic installation instructions. Here’s the translation for Ubuntu Karmic Koala (release 9.10): Install the prerequisites: sudo apt-get install mysql-server-5.1 mercurial sun-java6-jdk sun-java6-jre...... - Recursive sort-by-modification-time
This certainly isn’t rocket science, but it also is certainly not something you want to type more than once. find . -type f -printf '%T@\t%p\n' | sort -n | cut...... - Installing Ubuntu from a USB Drive
I just bought a new green server (25-30 watts at full load!) and wanted a brand-new Jaunty experience. The MSI Wind Nettop doesn’t come with an optical disk drive, nor......