Automatic disk mount and dismount

Turkannodland
Posts: 19
Joined: Thu Feb 26, 2009 3:36 pm

Automatic disk mount and dismount

Postby Turkannodland » Tue Nov 16, 2010 1:58 pm

First of all would like to express my appreciation for the great work done by the Amahi team for making the HAD server package. I’ve been using it for nearly 2 years now and I have become enthusiastic.
I would like to share with you something haven’t seen earlier posts about, namly using the autofs program to automatic mount and dismount disk shares.
It is particular useful if you have a HDD HotSwap cage. Then you can remove or swap disks in no time.

To set it up you have to do following steps:
1) Install autofs
On your Fedora desktop go to System-Administartion-Add/Remove software
Type autofs in the search box and install the most recent version for Fedora 12

2) Grant the system permission to mount internal disks without password authorization
Open file “org.freedesktop.devicekit.disks.policy” in /usr/share/polkit-1/actions
for edit in gedit and change “allow active” from “auth_admin_keep” to “yes”. Save and close.

Code: Select all

<action id="org.freedesktop.devicekit.disks.filesystem-mount-system-internal"> <description>Mount a system-internal device</description> <description xml:lang="da">Montr en intern enhed</description> <message>Authentication is required to mount the device</message> <message xml:lang="da">Autorisering er pkrvet for at montere et fil system</message> <defaults> <allow_any>no</allow_any> <allow_inactive>no</allow_inactive> <allow_active>yes</allow_active> </defaults> </action>
3) Make a “hotswap” directory in /var/hda/
Use Terminal or browse to /var/hda/ and make a new directory “hotswap” .( without quotes ).

4) Make a HDA share for the disk you want to automount
Create share ”swapvol1” in the hotswap directory, ie /var/hda/hotswap/swapvol1
When you create a share in your HDA the path will default to /var/hda/files/. Just edit and change “files” to “hotswap”.


5) Prepare and insert your disk
For a automount “disk share” it is easy to take the disk out and bring it with you.
This is why I prefer to format my disk with the ntfs file system. Then I can insert my disk in
a Windows machine if I like to.
Actually I format my “ hotswap” disk in a windows machine and at the same time I give it an unique label . The label I have used in this example is “WD2T04”. The label will be used to simplify the automounting in HDA.
Now insert your prepared disk to the HDA and check that it is recognized by the system and is ready to be mounted. It should appear in “Application – System Tools - File browser, side pane” and it will be listed in the “Application – System Tools – Disk Utility”. The Disk utility will also confirm the label you given to the disk.

6) Configure autofs by editing the configuration files
Open the Auto.master file in /etc/ for edit. Add the line:
/var/hda/hotswap /etc/auto.hotswap --timeout=60
In the Auto.master file:

Code: Select all

# # Sample auto.master file # This is an automounter map and it has the following format # key [ -mount-options-separated-by-comma ] location # For details of the format look at autofs(5). /var/hda/hotswap /etc/auto.hotswap --timeout=60 /misc /etc/auto.misc # # NOTE: mounts done from a hosts map will be mounted with the # "nosuid" and "nodev" options unless the "suid" and "dev" # options are explicitly given. # /net -hosts # # Include central master map if it can be found using # nsswitch sources. # # Note that if there are entries for /net or /misc (as # above) in the included master map any keys that are the # same will not be seen as the first read key seen takes # precedence. # +auto.master
Save and close the file.

Still in /etc/, open the “auto.misc “ file and save this with the new name ”auto.hotswap” . Open the auto.hotswap for edit and change it to look like this:


Auto.hotswap file:

Code: Select all

# # This is an automounter map and it has the following format # key [ -mount-options-separated-by-comma ] location # Details may be found in the autofs(5) manpage swapvol1 -fstype=ntfs-3g :LABEL=WD2T04 # the following entries are samples to pique your imagination #linux -ro,soft,intr ftp.example.org:/pub/linux #boot -fstype=ext2 :/dev/hda1 #floppy -fstype=auto :/dev/fd0 #floppy -fstype=ext2 :/dev/fd0 #e2floppy -fstype=ext2 :/dev/fd0 #jaz -fstype=ext2 :/dev/sdc1 #removable -fstype=ext2 :/dev/hdd
Save and close the file.

Finally open the file autofs in /etc/sysconfig/ for editing.
Enable browsing and logging mode as follows:

Code: Select all

# # BROWSE_MODE - maps are browsable by default. # BROWSE_MODE="yes" # # MOUNT_NFS_DEFAULT_PROTOCOL - specify the default protocol used by # mount.nfs(8). Since we can't identify # the default automatically we need to # set it in our configuration. This will # only make a difference for replicated # map entries as availability probing isn't # used for single host map entries. # #MOUNT_NFS_DEFAULT_PROTOCOL=3 # # APPEND_OPTIONS - append to global options instead of replace. # #APPEND_OPTIONS="yes" # # LOGGING - set default log level "none", "verbose" or "debug" # LOGGING="verbose" #
Save and close the file.
Finally check that files you have been editing have permission 0644 set. If not “chmod 0644 file”

Thats all. The final thing to do is to restart autofs. In terminal as root type “service autofs restart” and press enter. Confirm service is restarted OK. Close the terminal
Now you should be able to open your new share swapvol1. The mounting and dismounting actions can also be monitored in Amahi dashboard setup- debug – logs:

Code: Select all

Nov 15 23:19:44 localhost automount[13798]: expired /var/hda/hotswap/swapvol1 Nov 15 23:19:44 localhost ntfs-3g[9426]: Unmounting /dev/sdd1 (WD2T04) Nov 15 23:19:44 localhost automount[13798]: unmounting dir = /var/hda/hotswap/swapvol1 Nov 15 23:19:44 localhost automount[13798]: expiring path /var/hda/hotswap/swapvol1 Nov 15 23:19:33 localhost automount[13798]: 3 remaining in /var/hda/hotswap Nov 15 23:18:48 localhost automount[13798]: 1 remaining in /var/hda/hotswap Nov 15 23:18:44 localhost automount[13798]: 1 remaining in /var/hda/hotswap Nov 15 23:18:36 localhost automount[13798]: mounted /var/hda/hotswap/swapvol1 Nov 15 23:18:36 localhost automount[13798]: mount(generic): mounted LABEL=WD2T04 type ntfs-3g on /var/hda/hotswap/swapvol1 Nov 15 23:18:36 localhost ntfs-3g[9426]: Ownership and permissions disabled, configuration type 1 Nov 15 23:18:36 localhost ntfs-3g[9426]: Mount options: rw,allow_other,nonempty,relatime,fsname=/dev/sdd1,blkdev,blksize=4096 Nov 15 23:18:36 localhost ntfs-3g[9426]: Cmdline options: rw Nov 15 23:18:36 localhost ntfs-3g[9426]: Mounted /dev/sdd1 (Read-Write, label "WD2T04", NTFS 3.1) Nov 15 23:18:36 localhost ntfs-3g[9426]: Version 2010.10.2 integrated FUSE 27 Nov 15 23:18:34 localhost automount[13798]: attempting to mount entry /var/hda/hotswap/swapvol1

User avatar
bigfoot65
Project Manager
Posts: 11924
Joined: Mon May 25, 2009 4:31 pm

Re: Automatic disk mount and dismount

Postby bigfoot65 » Tue Nov 16, 2010 8:18 pm

Awesome stuff. Would it be possible for you to add this to the wiki? We can put a link on the main page so more users will see it.

We greatly appreciate your contribution!
ßîgƒσστ65
Applications Manager

My HDA: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz on MSI board, 16GB RAM, 1TBx1+2TBx2+4TBx2

Turkannodland
Posts: 19
Joined: Thu Feb 26, 2009 3:36 pm

Re: Automatic disk mount and dismount

Postby Turkannodland » Fri Nov 19, 2010 3:44 am

Sure I can add this to the WIKI. But how do I get access to make a WIKI contribution?

User avatar
moredruid
Expert
Posts: 791
Joined: Tue Jan 20, 2009 1:33 am
Location: Netherlands
Contact:

Re: Automatic disk mount and dismount

Postby moredruid » Fri Nov 19, 2010 4:25 am

login on the wiki with your amahi.org credentials, you get an "Edit" button somewhere in the right row
echo '16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D2173656C7572206968616D41snlbxq' | dc
Galileo - HP Proliant ML110 G6 quad core Xeon 2.4GHz, 4GB RAM, 2x750GB RAID1 + 2x1TB RAID1 HDD

Who is online

Users browsing this forum: No registered users and 28 guests