Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Mar 2011 20:20:34 +0100
From:      Polytropon <freebsd@edvax.de>
To:        Ryan Coleman <editor@d3photography.com>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: Automating mounting of ISO images
Message-ID:  <20110323202034.1c6a5fce.freebsd@edvax.de>
In-Reply-To: <21012F71-5038-45F1-98C6-72A0B1239009@d3photography.com>
References:  <21012F71-5038-45F1-98C6-72A0B1239009@d3photography.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 23 Mar 2011 13:49:46 -0500, Ryan Coleman <editor@d3photography.com> wrote:
> I have a folder full of ISOs that we're sharing on the
> network instead of having the discs available (seems 
> like a good idea, right?)

Please use the correct terminology: FreeBSD (as any UNIX
operating systems) calls them DIRECTORIES. "Folders" is
something else, it's not equivalent to a directory, so
"folders" is wrong.



> But I want to automate the process on boot instead of
> having to write a static script  to do the work.
> 
> Disc images are located in /mount/disc_images/ (all are ISOs)
> They need to mount into /mount/office_files/images/FILENAME
> [without the .iso extension]
> 
> How can I do this? I've always been given these types of
> scripts in the past at an old job but I don't have access
> to those examples anymore.

Something like this (not even tested, but quite verbose and
unelegant) should work:

#!/bin/sh
NODE=0
for IMAGE in /mount/disc_images/*.iso; do
	mdconfig -a -t vnode -u $NODE -f $IMAGE
	mount -t cd9660 -o ro /dev/md$NODE /mount/office_files/images/`basename $IMAGE .iso`
	NODE=`expr $NODE + 1`
done

This of course assumes that you have PROPER file names. In
case the ISO file names contain special characters, attention
has to be paid for quoting and escaping. Worth reading:

http://www.dwheeler.com/essays/filenames-in-shell.html

http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html

After reading it, you'll easily recognize that I did it wrong
in the suggestive script. :-)



I'm not sure if you can mount from ISO files directly, but
maybe you can try that too.

Remember unmounting the files when not in use (scripted: umount
and mdconfig -d).




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110323202034.1c6a5fce.freebsd>