Software mirgration from Windows for my friend

Sandy Rutherford sandy at krvarr.bc.ca
Mon Jan 17 03:00:36 PST 2005


>>>>> On Sat, 15 Jan 2005 15:20:58 -0600, 
>>>>> Vulpes Velox <v.velox at vvelox.net> said:

 >> Virtual CD is a program to mount iso images if I'm correct ( just
 >> like alcohol or deamontools ) you can just mount .iso files with
 >> FreeBSD : man mount_cd9660

 > Last I checked, it required a bit more... you have to use mdconfig to
 > create a device entry in /dev for the file so you can point mount at
 > it.

Yes, this is true.

Sergei, this should do the job for you and your friend.  I have only
used this up to FreeBSD 4.10.  Therefore, if vnode support is
different in 5.x, it may need some updating.

To install, just put the script anywhere in your path.  umount_iso
should be a link (soft or hard) to mount_iso.  It looks at how it was
called to decide what to do.  I also suggest that you sudo it, so you
do not need to be root to run it.

BTW, this comes with the usual disclaimer.  Should it thrash your file
system, cause your computer to explode, whatever, I am not liable.
However, if anybody hits any bugs in this, I would greatly appreciate
hearing about them.

...Sandy

----------------------------------------------------------------------
#!/bin/sh
#
# File:        mount_iso
# Description: Mounts an iso image file onto a mount point for previewing.
# Usage:       mount_iso iso_file mount_point
#           or umount_iso mount_point
###################################################################
# Works with FreeBSD, Linux and Solaris.  Should work with other BSDs
# too, as long as they have vnode support.
#
# For FreeBSD, the kernel needs to have vnode support compiled in.
# See "man vn".  
#
# For Solaris pre version 8, lofiadm does not exist.
# You need to install the fbk driver and modify the script to use it.
####################################################################
# Installation: Put this script somewhere in your path and make a hard link
# to it called umount_iso.
####################################################################
# Author:   Sandy Rutherford <sandy at krvarr.bc.ca>
# Created:  Thu Dec  5 16:38:43 2002 by sandy on szamoca.uphill.bc.ca
# Modified: Thu Dec  5 19:42:43 2002 by sandy on goethe
#           Mon Jan 17 01:58:52 2005 by sandy on goethe
####################################################################

if [ -z "$OSTYPE" ]
then
  # Get the OS type come hell or high water.
  OSTYPE=`/bin/uname 2>/dev/null || /sbin/uname 2>/dev/null || \
          /usr/bin/uname 2>/dev/null || /usr/sbin/uname 2>/devnull || \
          uname 2>/dev/null || \
          echo "Cannot determine operating system.  Bailing out." 1>&2 ; exit 1`
fi

case $OSTYPE in

  *[Bb][Ss][Dd]*)
    case $0 in
      *umount_iso)
        # Find the device file.
        dev=`/sbin/mount | awk "\\$3 == \"$1\" {print \\$1}"`
        /sbin/umount $1
        /usr/sbin/vnconfig -u $dev
        ;;
      *)
        # Find a free vn device.  Note that this assumes that
	# the device file exists in /dev.  If not, you must create it.
        n=0
        while /sbin/mount | grep -q "^/dev/vn$n"
        do
          n=`expr $n + 1`
        done
        /usr/sbin/vnconfig /dev/vn${n}c $1
	if [ $? != 0 ]
        then
         echo "Could not configure /dev/vn${n}c. Does the device file exist?" 1>&2 
         exit 1 
        fi
        /sbin/mount_cd9660 -o rdonly /dev/vn${n}c $2
        ;;
    esac
    ;;

  *[Ll][Ii][Nn][Uu][Xx]*)
    case $0 in
      *umount_iso)
        /bin/umount $1
        ;;
      *)
        mount $1 -r -t iso9660 -o loop $2
        ;;
    esac
    ;;

  *[Ss][Uu][Nn][Oo][Ss]*|*[Ss][Oo][Ll][Aa][Rr][Ii][Ss]*)
    case $0 in
      *umount_iso)
        dev=`/usr/sbin/mount | awk "\\$1 == \"$1\" {print \\$3}"`
        /usr/sbin/umount $1
        /usr/sbin/lofiadm -d $dev
        ;;
      *)
        dev=`/usr/sbin/lofiadm -a $1`
        /usr/sbin/mount -F hsfs -o ro $dev $2
        ;;
      esac
    ;;

  *) 
    echo "Do not know how to mount an iso image for operating system $OSTYPE." 1>&2
    exit 1
    ;;
esac


More information about the freebsd-questions mailing list