Difference between revisions of "Automounter tutorial"
(/etc/init.d/autofs no longer exists) |
|||
(One intermediate revision by one other user not shown) | |||
Line 24: | Line 24: | ||
== Start autofs == | == Start autofs == | ||
− | /etc/init.d/autofs start | + | systemctl start autofs || /etc/init.d/autofs start |
Now you can find your USB disk automatically mounted to /misc/usb. | Now you can find your USB disk automatically mounted to /misc/usb. | ||
== Make it persistent == | == Make it persistent == | ||
− | Now, as soon as you plug in your [[USB]] disk you will find its content under /misc/usb. If you want this setting to | + | Now, as soon as you plug in your [[USB]] disk you will find its content under /misc/usb. If you want this setting to persist after reboots, run the [[command]]: |
[[chkconfig]] autofs on | [[chkconfig]] autofs on | ||
Latest revision as of 14:58, 15 August 2015
autofs, also called automounter or automount, allows you to connect storage media like a USB disk and have it mounted automatically. For example, if you have two USB disks, and you want to have one mounted as usb-120gb and the other as usb-80gb as soon as you plug them in, this is possible with autofs.
Contents
QuickStart
This example assumes you want to plug in a USB disk and have it mounted on /misc/usb.
- Find out your USB disk's UUID:
hwinfo --block [...] Device Files: /dev/sdc1, /dev/disk/by-id/usb-Myson_Century,_Inc._USB_Mass_Stor age_Device_100-part1, /dev/disk/by-path/pci-0000:00:1d.7-usb-0:3:1.0-scsi-0:0:0: 0-part1, /dev/disk/by-uuid/84ff6790-9b69-4401-9ba2-43d044af1d30, /dev/disk/by-la bel/DATALUX
Configure autofs
Have a file /etc/auto.master like this:
/misc /etc/auto.misc --timeout=60 --ghost
This will create all mount points beneath /misc. The mount points will appear even if they are not active ("ghosts").
Create a file /etc/auto.misc like this:
usb -fstype=auto UUID="84ff6790-9b69-4401-9ba2-43d044af1d30"
Start autofs
systemctl start autofs || /etc/init.d/autofs start
Now you can find your USB disk automatically mounted to /misc/usb.
Make it persistent
Now, as soon as you plug in your USB disk you will find its content under /misc/usb. If you want this setting to persist after reboots, run the command:
chkconfig autofs on
TroubleShooting
- You can find log entries from automounter NOT in dmesg but in /var/log/messages.
- If your device is already mounted, automount may not mount it again. This means you will also have to stop other automounters like gnome-volume-manager.