automount predefined mountpoints in fstab

Hello guys,
I am trying to automount some predefined mountpoints which i wrote in fstab.

The Idea is to auto mount some USB to this different paths:
for example:
USB1 to this path: usbdev/usb1
USB2 to this path: usbdev/usb2

I already enabled autofs in rc.conf with:
Code:
autofs_enable="YES"
After that I created the Directories:
Code:
mkdir usbdev/usb1
mkdir usbdev/usb2
Then I went into fstab and added those mountpoints:
Code:
DEVICE            MOUNTPOINT     FSTYPE       OPTIONS             Dump             PASS
/dev/da0s1      /usbdev/usb1      fat32lba      rw                                                  3

What else do I have to do to get this working?
Kind Regards
 
I just read the Docs and changed the auto_master files to this:
Code:
MOUNTPOINT   MAP
/usbdev/usb1    /dev/da0s1
/usbdev/usb2    /dev/da1s1
the output in df -h is this:
Code:
FILESYSTEM           SIZE         USED        AVAIL       CAPACITY          MOUNTED ON
map /dev/da0s1    0B            0B              0B              100%             /usbdev/usb1
map /dev/da1s1    0B            0B              0B              100%             /usbdev/usb2
if they would be mounted the correct way the size would be the actual size of the USB?
Please correct me if I still have an error

Thanks a lot!
 
You have tell automount that it should mount a msdosfs....

But another problem will arise. If you always want to mount /dev/da0s1 to mount on usbdev/usb1, you could never plug in usb2 first, as it would become/dev/da0s1.

I have been using autofs for years, but it has it's limits and requires a lot of trial and error.
In your case I'd choose a different route: use labels and mount through /etc/fstab
In addition, I wouldn't use /usbdev/usb[1/2] but rather put the directories into /. That will keep typing to a minumum if you mount them. You could of course create an alias for the mount command as well.

The steps:
plug in your usb devices in the right order so /dev/da0s1 is what you want to be named usb1 and /dev/da1s1 accordingly.
become root...
# glabel label usb1 da0s1
# glabel label usb2 da1s1
# mkdir /usb1 /usb2
# chown youruser:youruser /usb1 /usb2
# sysctl vfs.usermount=1
Add the following lines to /etc/devfs.conf:
perm label/usb1 0660
perm label/usb2 0660
Restart devfs:
[S]service devfs restart[/S]
(Please see EDIT below, I made a mistake here)
Edit /etc/fstab and add the following to lines:
/dev/label/usb1 /usb1 msdosfs rw,noauto 0 0
/dev/label/usb2 /usb2 msdosfs rw,noauto 0 0

Now you can simply type
mount /usb2
and/or
mount /usb1
and it doesn't matter which one you plugged in first.
And as you wanted, USB1 will always be mounted on /usb1 while USB2 always on /usb2
And umount via
umount /usb1
umount /usb2

It not 100 percent "auto" but I hope it's convenient enough ;)

If you like that aproach, make usermount permanent and it's done.
# echo vfs.usermount=1 >> /etc/sysctl.conf


EDIT:
Sorry, I discovred I made a mistake. Forget about what I wrote and crossed out about /etc/devfs.conf above, it's just for devices that are present at boot time.
A devfs rule has to be created like the following to make it work. Create /etc/devfs.rules and add the following
Code:
[glabel_usb=10]
add path 'label/*' mode 0660 group youruser

To /etc/rc.conf add
Code:
devfs_system_ruleset="glabel_usb"

Then apply the rules:
# service devfs restart
# devfs ruleset 10
# devfs rule applyset
Now continue above with /etc/fstab...
 
You have tell automount that it should mount a msdosfs....

But another problem will arise. If you always want to mount /dev/da0s1 to mount on usbdev/usb1, you could never plug in usb2 first, as it would become/dev/da0s1.

I have been using autofs for years, but it has it's limits and requires a lot of trial and error.
In your case I'd choose a different route: use labels and mount through /etc/fstab
In addition, I wouldn't use /usbdev/usb[1/2] but rather put the directories into /. That will keep typing to a minumum if you mount them. You could of course create an alias for the mount command as well.

The steps:
plug in your usb devices in the right order so /dev/da0s1 is what you want to be named usb1 and /dev/da1s1 accordingly.
become root...
# glabel label usb1 da0s1
# glabel label usb2 da1s1
# mkdir /usb1 /usb2
# chown youruser:youruser /usb1 /usb2
# sysctl vfs.usermount=1
Add the following lines to /etc/devfs.conf:
perm label/usb1 0660
perm label/usb2 0660
Restart devfs:
[S]service devfs restart[/S]
(Please see EDIT below, I made a mistake here)
Edit /etc/fstab and add the following to lines:
/dev/label/usb1 /usb1 msdosfs rw,noauto 0 0
/dev/label/usb2 /usb2 msdosfs rw,noauto 0 0

Now you can simply type
mount /usb2
and/or
mount /usb1
and it doesn't matter which one you plugged in first.
And as you wanted, USB1 will always be mounted on /usb1 while USB2 always on /usb2
And umount via
umount /usb1
umount /usb2

It not 100 percent "auto" but I hope it's convenient enough ;)

If you like that aproach, make usermount permanent and it's done.
# echo vfs.usermount=1 >> /etc/sysctl.conf


EDIT:
Sorry, I discovred I made a mistake. Forget about what I wrote and crossed out about /etc/devfs.conf above, it's just for devices that are present at boot time.
A devfs rule has to be created like the following to make it work. Create /etc/devfs.rules and add the following
Code:
[glabel_usb=10]
add path 'label/*' mode 0660 group youruser

To /etc/rc.conf add
Code:
devfs_system_ruleset="glabel_usb"

Then apply the rules:
# service devfs restart
# devfs ruleset 10
# devfs rule applyset
Now continue above with /etc/fstab...

Thank you very much!

I'm currently trying to tell the System use this special port for this special device..
for example. Port 1 is only for USB 1 and so on.

If you have any suggestions regarding this topic I would be very grateful to get another opinion on how to get it done.

Kind regards
 
Back
Top