Well, here we can use the same trick that fstab
uses for Optical media (aka CD's and DVD's):
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
The first column indicates the file system, I'm sure your USB's will have fixed values, so lets presume that everything after sda
is a USB, and since you can only have 4 USB's at the same time, the list goes from sdb
, sdc
, sdd
and sde
.
$ ls /dev/sd*
/dev/sda /dev/sdb /dev/sdb3 /dev/sdb6 /dev/sdc /dev/sdf
/dev/sda1 /dev/sdb1 /dev/sdb4 /dev/sdb7 /dev/sdd
/dev/sda2 /dev/sdb2 /dev/sdb5 /dev/sdb8 /dev/sde
(In my case I use a memory reader, so my USB drivers start from sdg
but lets continue.)
Now, we assume each USB have one and only one partition, so the lines we need, for our fstab
, are:
/dev/sdb1
/dev/sdc1
/dev/sdd1
/dev/sde1
Then you said your mount points has to be fixed, so after you have created your directories, lets add them:
/dev/sdb1 /media/HDD1
/dev/sdc1 /media/HDD2
/dev/sdd1 /media/HDD3
/dev/sde1 /media/HDD4
Since you can have almost all type of file systems, lets use the auto
so fstab guess the file type to use:
/dev/sdb1 /media/HDD1 auto
/dev/sdc1 /media/HDD2 auto
/dev/sdd1 /media/HDD3 auto
/dev/sde1 /media/HDD4 auto
Ok, now lets boil down to the options, which will be the very same for CD's with the plus of read/write permissions:
/dev/sdb1 /media/HDD1 auto rw,users,noauto,allow_other,umask=0
/dev/sdc1 /media/HDD2 auto rw,users,noauto,allow_other,umask=0
/dev/sde1 /media/HDD3 auto rw,users,noauto,allow_other,umask=0
/dev/sde1 /media/HDD4 auto rw,users,noauto,allow_other,umask=0
rw
tells that we want read and write permission, users
allows any user to mount a device, noauto
prevents that the driver gets mounted automatically when mount -a
is called, like it does at boot, preventing boot ERRORS and WARNINGS, allow_other
allows other but the user that mounted the driver to have the same permissions, and umask=0
prevents the defaults umask from being applied.
Now the only 2 left fields are pretty much just about the dump
order and fsck
order, which could be in 0
both, leaving us with the final result:
/dev/sdb1 /media/HDD1 auto rw,user,noauto,allow_other 0 0
/dev/sdc1 /media/HDD2 auto rw,user,noauto,allow_other 0 0
/dev/sdd1 /media/HDD3 auto rw,user,noauto,allow_other 0 0
/dev/sde1 /media/HDD4 auto rw,user,noauto,allow_other 0 0
With this, each time that you plug a USB device it will being automagically mounted in the mount point without the intervention of the user. You should modify according to your necessities.
root
normount
nor restart. – Braiam Aug 12 '13 at 01:24