Finally found a solution on how to make my Linux (Debian):
A) Remember the unique USB drive(in my case a Western Digital Mirror Edition), and where to mount it
B) Automatically mount it when connected
First you have to identify your usb drive, make sure it is connected and you know the device name, in my case:
NoMore:/home# blkid /dev/sdc1
/dev/sdc1: UUID="6494BFE994BFBC3C" LABEL="My Book" TYPE="ntfs"
NoMore:/home#
As you see my drive has a unique ID. This is what we are gonna use in fstab instead of the device name. Smart huh? :) This way we avoid the problem of changing device names when plugging stuff in and out.
Next in fstab, make a line like this:
UUID=6494BFE994BFBC3C /home/user/DiSK/ ntfs-3g defaults,auto,umask=000,users,rw 0 0
Make the changes you need, but make sure you use your correct UUID(and remove the "") and it is set auto like above.
Next check if it works by typing:
mount -a
The -a parameter means it shall mount everything set to auto in fstab. If it works, umount your drive and let's continue:
Ok, make sure you got udev installed. This is what's gonna automaticly mount our drives when new ones are detected. Make a new file;
NoMore:/home# nano /etc/udev/rules.d/99-mount.rules
And add the following line:
SUBSYSTEM=="block", run+="/bin/mount -a"
Just make sure it uses the correct path to the mount command.
Next restart udev:
NoMore:/home# /etc/init.d/udev restart
Now unmount(umount) your drive, unplug it and try it out.
run should be RUN
ReplyDeletethx!
ReplyDeleteVery smart!. Thanks.
ReplyDeleteI have a USB hard disk which I use as backup. I install the disk only when making a back-up, the other time I store the disk off-site.
ReplyDeleteThis auto mounting prevents forgetting to mount the drive so a back-up is made on the root file system.
So thanks a lot.
jlinkels
Awesome info, thanks for un-obfuscating UUID a bit :)
ReplyDeleteI have found the udev part problematic: mount is executed during boot on all devices including root, and as root is also mounted "rw", fsck aborts the boot process. I found a more elaborate udev config post here: http://www.monperrus.net/martin/automounting+usb+flash+drives+on+linux+with+udev+and+pmount
ReplyDeleteKovács Péter, that's what you get for using desktop'ish approach on a system designed without these spontaneous hotplugs in mind. I doubt that fsck error will hurt any of my laptops/desktops much (Ctrl-D all the way), and there are still no reasons to set something like that on anything acting as mission-critical server.
DeleteCompletely awesome tutorial!
ReplyDeleteJust what I needed but I am using rsnapshot and would like to to run only when the external drive is inserted
ReplyDeleteObat Luka Bakar Kronis
ReplyDeleteObat Radang Paru Paru Anak
Obat Infeksi Pada Luka Lambung
Obat Radang Hati Kronis
Obat Benjolan di Gusi
Obat Pengering Luka
Obat Penyakit Diabetes Kronis
Obat Radang Prostat
Obat Benjolan di Lidah
Obat Epilepsi Anak Dan Dewasa
Obat Benjolan Di Dalam Hidung
Obat Stroke Akut
Obat Penyakit Radang Hidung
Obat luka dalam hidung
This is also a very good post which I really enjoy reading. It is not everyday that I have the possibility to see something like this. Mortgage Brokers in Canary Wharf
ReplyDeleteZaheer Hyder
ReplyDeleteZaheer Hyder
Zaheer Hyder
Zaheer Hyder
Zaheer Hyder
Zaheer Hyder
Zaheer Hyder
Zaheer Hyder
Zaheer Hyder
Great and informative tips very helpful
The Lawyer World
ReplyDeleteThe Lawyer World
The Lawyer World
The Lawyer World
The Lawyer World
The Lawyer World
The Lawyer World
The Lawyer World
The Lawyer World
The Lawyer World
i like that
USA law directory
ReplyDeleteUSA law directory
USA law directory
USA law directory
USA law directory
USA law directory
USA law directory
USA law directory
USA law directory
USA law directory