How to automount usb external hardisks in ubuntu server 12.04?
When an USB devices is plugged in it gets probed. If you have a modern Linux distributen then the udev rules get triggered. (See /etc/udev/rules.d
& /lib/udev/rules.d
).
You can use those rules to run a script. That script can then read the drives label and take a specific action based on that (e.g. if the label is 'backup_drive_1` then rsync /data to that drive).
However: I have not tried that myself. All I have atm is an interest into how to do that and a few handy links. (in my case the goal was to resync a mdadm mirror to an specific USB drive).
Regardless, these links may set you on the right path, and maybe someone will post a ready made answer.
- http://reactivated.net/writing_udev_rules.html#external-run
- https://unix.stackexchange.com/questions/5623/what-happens-when-a-usb-drive-is-plugged-in
- http://ubuntuforums.org/showthread.php?t=168221
- https://stackoverflow.com/questions/469243/how-can-i-listen-for-usb-device-inserted-events-in-linux-in-python
You should just be able to add them to /etc/fstab
UUID=your-uuid-goes-here /where-to-mount-goes-here ext4 defaults 0 2
NTFS example:
UUID=your-uuid-goes-here /where-to-mount-goes-here ntfs-3g defaults,auto,umask=000,users,rw 0