Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

AHCI is on and I can manually mount but as this device is destined to be a headless device used by people with no clue about the terminal so I need something as idiotproof as possible.

I expect I need to make some udev rules but I've got no idea how to start.

I've managed to get it to automount using fstab but this is unsuitable for hotplugging.

For now all I need is for it to recognize a particular drive with one primary NTFS partition but I'll be ramping this up to include a bunch of drives and even 'never seen by the server before' drives so if there's someone can also help me with that then even better.

share|improve this question
Hotplugged SATA drives behave exactly as USB drives when inserted. So I don't understand what are you trying to achieve here. – Avio Sep 24 '12 at 13:57

On Linux, you can tell the system to rescan an individual SATA port.So to rescan the SATA3 port, just do:

echo "- - -" | sudo tee -a /sys/class/scsi_host/host2/scan

The system will scan the drive and add entries to /dev/ for the drive and its individual partitions (e.g /dev/sdb, /dev/sdb1, /dev/sdb2). Ubuntu will automount any mountable partitions under /media and put an icon on the desktop.

This is a script that may help you in scanning the board.

export SCAN_TEMP=$(mktemp -d)
ls /dev/sd? > ${SCAN_TEMP}/before.txt
for i in /sys/class/scsi_host/host*/scan
  echo "- - -" >> $i
ls /dev/sd? > ${SCAN_TEMP}/after.txt
for i in $(diff ${SCAN_TEMP}/before.txt ${SCAN_TEMP}/after.txt | grep \> | awk -F/ '{print $NF}'); do
  echo Added /dev/$i:
  /sbin/sfdisk -uM -l /dev/$i | grep -E "^/dev/$i" | awk '{print "    "$1" "$4" MiB"}'
rm -rf ${SCAN_TEMP}


share|improve this answer
Hi there. Sorry but it's not putting anything under media. I got the impression that the Ubuntu Server is not configured out of the box to automount USB or hotplug SATA drives. In any case, at no time has anything 'appeared' in my /media folder other than 'cdrom' folder. I've had to add the mount point myself and manually mount the drive or manually add an entry in the /etc/fstab file (which is fine for automounting at boot up but useless for any changes after that). I suppose what I'm trying to do is find out what the desktop version does that the server version doesn't and implement it. – Dale Walker Sep 24 '12 at 19:17

I have used usbmount on Debian for this purpose. It modifies udev rules so they call the usbmount script. It is unmaintained, but is a quite simple script to customize. The problem is that if nobody unmounts the disk before unplugging, you need to mount it with the "sync" option, which makes it quite slow.

share|improve this answer

Your Answer


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.