Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: "loopback mount" via vnd feature request



On Mon, Mar 02, 2009 at 10:03:04PM +0900, Toru Nishimura wrote:
> 
> The issue here is that our vnconfig (vnode-config) is
> unable to show off which file is bound with vnd device alive.
> The addition of -l option is not optimal since showing inode
> number is no better than debug'ng feature.  It'd nice to
> provide a straight-and-easy-to-use way for loopback mounting.
> Possible implementations would vary, I suppose.
>

Well, since we are sharing...
 
> /// mount-iso ///

The problem I see with this script is that you assume the number of
vnd devices configured in the kernel.  You can query for a list of vnd
devices and their status buy using "vnconfig -l".  Here is my script I
use to mount my qemu hard disk images - it uses the vnconfig -l
command to use the first available vnd device for the mount.

#!/bin/sh
#
# Mount the HD for the qemu environment for blymn.
#
QEMUHOME=/home/user/blymn/qemu
QEMUHD=${QEMUHOME}/hda
QEMUMNTPT=/mnt
#
EXIT=0
#
VND=`vnconfig -l | grep 'not in use' | head -1 | cut -d':' -f1`
if [ "${VND}" = "" ]
then
        echo "No available vnd devices.  Exiting."
        exit 1
fi
#
if [ "X$1" != "X" ]
then
        if [ -r "${QEMUHOME}/$1" ]
        then
                QEMUHD=${QEMUHOME}/$1
        else
                QEMUMNTPT=$1
        fi
fi
#
if [ "X$2" != "X" ]
then
        QEMUMNTPT=$2
fi
#
vnconfig ${VND} ${QEMUHD}
if [ $? != 0 ]
then
        echo "vnconfig of ${QEMUHD} failed"
        exit 1
fi
#
fsck -y /dev/r${VND}a
mount /dev/${VND}a ${QEMUMNTPT}
if [ $? != 0 ]
then
        echo "mount of /dev/${VND}a on ${QEMUMNTPT} failed"
        vnconfig -u ${VND}
        EXIT=1
fi
exit ${EXIT}


unfortunately - I have not done the equally clever unmount and vnd
clean up.

-- 
Brett Lymn
"Warning:
The information contained in this email and any attached files is
confidential to BAE Systems Australia. If you are not the intended
recipient, any use, disclosure or copying of this email or any
attachments is expressly prohibited.  If you have received this email
in error, please notify us immediately. VIRUS: Every care has been
taken to ensure this email and its attachments are virus free,
however, any loss or damage incurred in using this email is not the
sender's responsibility.  It is your responsibility to ensure virus
checks are completed before installing any data sent in this email to
your computer."




Home | Main Index | Thread Index | Old Index