2026-03-12 20:51:59
This commit is contained in:
17
bash/quemu-mount.sh
Normal file
17
bash/quemu-mount.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
# usage: qemu-mount {imagefile}
|
||||
# 1st argument: QEMU raw image file
|
||||
|
||||
if [ $# -ne 1 ] ; then
|
||||
echo 'usage: qemu-mount imagefile'
|
||||
echo 'Mounts a QEMU raw image file to /mnt/temp'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
start=$( fdisk -l -o Device,Start ${1} | grep "^${1}1" | gawk '{print $2}' )
|
||||
sectors=$( fdisk -l ${1} | grep '^Units: sectors of' | gawk '{print $(NF-1)}' )
|
||||
offset=$(( $start * $sectors ))
|
||||
|
||||
[ -d /mnt/temp ] || mkdir /mnt/temp
|
||||
sudo mount -o loop,offset=$offset ${1} /mnt/temp
|
||||
|
||||
Reference in New Issue
Block a user