Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Mar 2011 19:21:32 +0000
From:      four.harrisons@googlemail.com
To:        editor@d3photography.com
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Automating mounting of ISO images
Message-ID:  <4d8b710e.9104df0a.595e.04b7@mx.google.com>

index | next in thread | raw e-mail

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, ...

_______________________________________________

freebsd-questions@freebsd.org mailing list

http://lists.freebsd.org/mailman/listinfo/freebsd-questions

To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"




help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4d8b710e.9104df0a.595e.04b7>