From 6c9e6f2ad186eb5d21df57542a1a16fae5ddb747 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Wed, 25 Mar 2009 20:59:21 +0000 Subject: [PATCH] QEMU: Added a script to auto-mount a .img This script maps a .img to a NBD device and allow mounting it in on swoop. Instructions are in the script. Signed-off-by: Michel Pollet --- mini2440/qemu-local-img-mount.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 mini2440/qemu-local-img-mount.sh diff --git a/mini2440/qemu-local-img-mount.sh b/mini2440/qemu-local-img-mount.sh new file mode 100755 index 0000000000..95e2ca8177 --- /dev/null +++ b/mini2440/qemu-local-img-mount.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Mount a local .img qemi file on the local host via the new qemu-nbd +# The syntax specify the file, the mount point, and the partition + +# example: +# sudo ./mini2440/qemu-local-img-mount.sh mini2440/emdebian_1GB.img /mnt/arm p2 +# +# Mounting mini2440/emdebian_1GB.img - /dev/mapper/nbd1p2 to /mnt/arm +# /dev/mapper/nbd1p2 903024 225196 631848 27% /mnt/arm +# ... +# umount /mnt/arm +# ./qemu-nbd -d /dev/nbd1 +# + +if [ ! -f $1 -o ! -d $2 ]; then + echo "$0 [pX]" + exit 1 +fi + +nbd=nbd1 + +modprobe nbd + +./qemu-nbd -c /dev/$nbd $1 +kpartx -a /dev/$nbd + +if [ -b "/dev/mapper/${nbd}$3" ]; then + part="/dev/mapper/${nbd}$3" +else + part="/dev/mapper/${nbd}p1" +fi + +echo Mounting $1 - $part to $2 + +#ls -l /dev/mapper/${nbd}* + +mount $part $2 + +df -h|grep $part -- 2.11.4.GIT