<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>lioks&#039; &#187; Tips &amp; tricks</title>
	<atom:link href="http://lioks.buffout.org/?feed=rss2&#038;tag=tips-tricks" rel="self" type="application/rss+xml" />
	<link>http://lioks.buffout.org</link>
	<description>FreeBSD tutorials &#38; tips for beginners</description>
	<lastBuildDate>Tue, 01 Dec 2009 14:58:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mounting usb drives / iso images in FreeBSD without root privileges</title>
		<link>http://lioks.buffout.org/?p=24</link>
		<comments>http://lioks.buffout.org/?p=24#comments</comments>
		<pubDate>Mon, 02 Nov 2009 21:01:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeBSD Tutorials]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Tips & tricks]]></category>

		<guid isPermaLink="false">http://www.aimxhaisse.com/lioks/?p=24</guid>
		<description><![CDATA[Mounting usb devices is a common task and many system take care of it without user&#8217;s intervention.
Under FreeBSD you can use hald (Hardware Abstraction Layer daemon) which use D-Bus objects for each device and mount your usb devices automatically, but you can also do it directly with the mount command.
Connect your device and take a [...]]]></description>
			<content:encoded><![CDATA[<p>Mounting usb devices is a common task and many system take care of it without user&#8217;s intervention.<br />
Under FreeBSD you can use hald (Hardware Abstraction Layer daemon) which use D-Bus objects for each device and mount your usb devices automatically, but you can also do it directly with the <code>mount</code> command.</p>
<p>Connect your device and take a look to the 10 last lines of your system console:<br />
<code><br />
% dmesg | tail -n 10<br />
</code></p>
<p>You should see something like that:<br />
<code><br />
da0 at umass-sim0 bus 0 target 0 lun 0<br />
da0: <JetFlash TS8GJFV10 8.07> Removable Direct Access SCSI-2 device<br />
da0: 40.000MB/s transfers<br />
da0: 7799MB (15974398 512 byte sectors: 255H 63S/T 994C)<br />
</code></p>
<p>Name of the device node and label may vary but we can see here that an usb device named <code>JetFlash TS8GJFV10 8.07</code> is connected to my machine and referenced as <code>da0</code>.<br />
Next step is to mount the first partition (slice) on the device to your filesystem (i.e. a directory):<br />
<code><br />
# mount -t msdosfs /dev/da0s1 /mnt<br />
</code></p>
<p>The -t option specifies the type of the filesystem to mount, for a FAT flash drive use <code>msdosfs</code>, for a NTFS hard drive you have to specify <code>ntfs</code> and so on. For more informations about exotic filesystems, you should take a look at the mount(8) manpage.<br />
The data on your drive can now be accessed in your filesystem through <code>/mnt</code>.</p>
<p>Reverting the process is quite easy:<br />
<code><br />
# umount /mnt<br />
</code></p>
<p>Mounting iso files can be a bit more tricky, you have to create a  virtual device attached to an iso image and mount it using the <code>mount</code> command:<br />
<code><br />
# mdconfig -a -t vnode -f ~/file.iso -u 1<br />
# mount -t cd9660 /dev/md1 /mnt<br />
</code><br />
The first line creates a device node linked to <code>~/file.iso</code> in <code>/dev</code> named <code>md1</code>.<br />
The second line is a classic mount command specifying a cd9660 filesystem, the filesystem used by cdrom/dvdrom drives.</p>
<p>When you finished using your iso file, you can unmount the device, but don&#8217;t forget to destroy the virtual device:<br />
<code><br />
# umount /mnt<br />
# mdconfig -d -u 1<br />
</code></p>
<p>Ok, now you can mount usb drives or iso images but you have to perform the mount operation as root using <code>su</code> or <code>sudo</code>.<br />
It can be useful to create a group of users able to mount usb and virtual devices:<br />
<code><br />
# pw groupadd mounters<br />
</code></p>
<p>You can now add the users you want to be able to mount to this group:<br />
<code><br />
# pw groupmod mounters -m lioks<br />
</code></p>
<p>Edit <code>/etc/devfs.rules</code> to add these new devices rules:<br />
<code><br />
[localrules=10]<br />
add path 'da*' mode 0660 group mounters<br />
add path 'md*' mode 0660 group mounters<br />
</code></p>
<p>&#8230; and <code>rc.conf</code> to add this ruleset:<br />
<code><br />
devfs_system_ruleset="localrules"<br />
</code></p>
<p>The last thing to do is to tune your kernel to allow any user to use the <code>mount</code> command:<br />
<code><br />
# sysctl vfs.usermount=1<br />
</code></p>
<p>To have this done each time your start your system, add the following line to <code>/etc/sysctl.conf</code>:<br />
<code><br />
vfs.usermount=1<br />
</code></p>
<p>Done ! Next time you will log in as an user member of the mounters group you should be able to use usb devices (and iso images) without any root privileges.<br />
Don&#8217;t forget to make sure you have read/write permissions on the target directory :P</p>
]]></content:encoded>
			<wfw:commentRss>http://lioks.buffout.org/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
