Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- IMAGE="$1"
- DISK="0"
- PARTITION="1"
- MOUNTPOINT="$2"
- print_usage(){
- echo "Usage: mount.qcow <IMAGE> <MOUNTPOINT>"
- }
- if [ "$#" -eq "0" ] # if there is no parameter
- then
- print_usage
- else
- if [ $(id -u) -eq "0" ] # if the user is root
- then
- if file "$IMAGE"|grep -q "QEMU QCOW Image" && [ -d "$MOUNTPOINT" ] # if image is a qcow file and mountpoint is a directory
- then
- modprobe nbd max_part=16
- qemu-nbd -c /dev/nbd${DISK} "$IMAGE"
- mount /dev/nbd${DISK}p${PARTITION} "$MOUNTPOINT"
- else
- print_usage
- fi
- else
- echo "mount.qcow: only root can do that"
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement