From owner-freebsd-questions@FreeBSD.ORG Wed Mar 23 19:20:37 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 773831065673 for ; Wed, 23 Mar 2011 19:20:37 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id 388398FC13 for ; Wed, 23 Mar 2011 19:20:37 +0000 (UTC) Received: from r55.edvax.de (port-92-195-86-215.dynamic.qsc.de [92.195.86.215]) by mx02.qsc.de (Postfix) with ESMTP id 7FBF91E539; Wed, 23 Mar 2011 20:20:35 +0100 (CET) Received: from r55.edvax.de (localhost [127.0.0.1]) by r55.edvax.de (8.14.2/8.14.2) with SMTP id p2NJKYuQ001635; Wed, 23 Mar 2011 20:20:34 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Wed, 23 Mar 2011 20:20:34 +0100 From: Polytropon To: Ryan Coleman 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> Organization: EDVAX X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: FreeBSD Mailing List Subject: Re: Automating mounting of ISO images X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Mar 2011 19:20:37 -0000 On Wed, 23 Mar 2011 13:49:46 -0500, Ryan Coleman 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, ...