Searching the web, I found this post about mounting a vdi file in Linux.
- On Fedora 15, you need to install these packages:
- To mount a partition on a hard disk image file:
- To unmount:
# yum install nbd qemu-common
# modprobe nbd
# qemu-nbd -c /dev/nbd0 "file.vdi"
# kpartx -a /dev/nbd0 # creates mapped devices in /dev/mapper/
# mount /dev/mapper/nbd0p1 /some/folder # mounts first partition of the image.
# umount /some/folder
# kpartx -d /dev/nbd0
# qemu-nbd -d /dev/nbd0
Hi!
The device /dev/nbd0p1 is not created automatically. So you should use
# kpartx /dev/nbd0
and
#kpartx -d /dev/nbd0
on the umount side.
I’m sure, at the time of writing this, I never used `kpartx‘. Actually I never heard of it before you mentioning it!
But now, after I tried to mount a vdi file, as you said it, I had to do a “
# kpartx -a /dev/nbd0
” to map the partitions. And the mapped devices are “/dev/mapper/nbd0p?
“.Thank you for your consideration and correction.
I will update the post accordingly!
Graze infinite!! Utilissima! 🙂
Thanks very much!! Usefull!! 🙂
# modprobe nbd
FATAL: Module nbd not found.
# insmod nbd.ko
insmod: can’t read ‘nbd.ko’: No such file or directory
# uname -a
Linux 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
# rpm -qa | grep nbd
nbd-2.9.20-7.el6.x86_64
# locate nbd-server
/usr/bin/nbd-server
/usr/share/man/man1/nbd-server.1.gz
/usr/share/man/man5/nbd-server.5.gz
/var/cache/man/cat1/nbd-server.1.lzma
# locate nbd-client
/usr/sbin/nbd-client
/usr/share/man/man8/nbd-client.8.gz
# rpm -qa | grep qemu
qemu-kvm-0.12.1.2-2.415.el6_5.7.x86_64
qemu-kvm-tools-0.12.1.2-2.415.el6_5.7.x86_64
qemu-guest-agent-0.12.1.2-2.415.el6_5.7.x86_64
qemu-img-0.12.1.2-2.415.el6_5.7.x86_64
gpxe-roms-qemu-0.9.7-6.10.el6.noarch
what to do?
Thanks