/[sysadmin-cookbook]/recepies/kvm/image-device.sh
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /recepies/kvm/image-device.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 56 - (hide annotations)
Tue May 12 15:52:05 2009 UTC (15 years ago) by dpavlin
File MIME type: application/x-sh
File size: 528 byte(s)
kill existing image, mount all partitions

1 dpavlin 52 #!/bin/sh -x
2    
3     test -e $1 || ( echo echo "Usage: $0 image.qcow2" ; exit 1 )
4    
5     image=$1
6 dpavlin 56
7     test -e $image.pid && kill `cat $image.pid`
8    
9     running=`ps ax | grep kvm-nbd | grep -v grep | wc -l`
10 dpavlin 52 port=`expr 10000 + $running`
11    
12     kvm-nbd --port $port $image &
13     echo $! > $image.pid
14    
15 dpavlin 56 sleep 1
16    
17 dpavlin 52 nbd-client localhost $port /dev/nbd$running || exit
18    
19     fdisk -l /dev/nbd$running
20 dpavlin 56
21     fdisk -l /dev/nbd1 | grep ^/dev/nbd | cut -d" " -f1 | sed 's!/dev/!!' | xargs -i sh -x -c "mkdir -p /mnt/$image/{} ; mount -v /dev/{} /mnt/$image/{}"
22    
23     df -h /mnt/$image/*

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26