Page 1 of 2

Discuss: Mount any VBox-compatible disk image on the host

Posted: 11. May 2009, 06:10
by h2o
[modedit] This is the remains of the howto, which can now be found at http://forums.virtualbox.org/viewtopic.php?f=26&t=33355.[/modedit]

Note that this is a restricted topic. If you want to discussion vdfuse then see the vdfuse discussion.

Re: HOWTO: Mount any VBox-compatible disk image on the host

Posted: 9. Jan 2010, 12:10
by dlgroups31
it shows only for mounting vdi files when linux is running
How to mount vdi files on linux while booting
means that how to boot from vdi files on linux hosts

Re: HOWTO: Mount any VBox-compatible disk image on the host

Posted: 10. Apr 2010, 02:09
by wireless
Will this work for a dynamically expandable file system as well?

Re: HOWTO: Mount any VBox-compatible disk image on the host

Posted: 15. May 2010, 01:09
by lfloyd
My ubuntu.vdi won't boot because of grub error 17. So this thread is useless to a non-bootable linuxbox. I had made a backup, but it is a backup with the grub error. I'm trying to mount it so I can fix it. Need suggestions that don't include reinstalling an OS that I spent weeks working on. This whole problem started just trying to backup the ubuntu installation. Reinstalling a whole OS opens up a whole nother can of worms that could have been prevented if virtualbox had an easy to use backup sysyem compatible with virtualbox.

Re: HOWTO: Mount any VBox-compatible disk image on the host

Posted: 15. May 2010, 01:51
by fixedwheel
h2o wrote:Note that this is a restricted topic. If you want to discussion vdfuse then see the vdfuse discussion.
my answer here is an exception, some admin please move this to its own or the discussion thread...
lfloyd wrote:My ubuntu.vdi won't boot because of grub error 17. So this thread is useless to a non-bootable linuxbox. I had made a backup, but it is a backup with the grub error. I'm trying to mount it so I can fix it.
:?: how to loopback mount the vdi on the host is what this thread is about
lfloyd wrote:Need suggestions that don't include reinstalling an OS that I spent weeks working on. This whole problem started just trying to backup the ubuntu installation. Reinstalling a whole OS opens up a whole nother can of worms that could have been prevented if virtualbox had an easy to use backup sysyem compatible with virtualbox.
if you need another solution w/o compiling vdfuse.c ... here is what i would do

boot your virtual machine with your ubuntu install CD .iso, select live CD option (not install)
when live CD up and running get a terminal, be root, mount your ubuntu .vdi filesystem (probably /dev/sda1) somewhere and chroot somewhere
then running update-grub could fix your problem

Re: HOWTO: Mount any VBox-compatible disk image on the host

Posted: 23. Jun 2010, 19:11
by penteki
Hello, I'm unable to compile vdfuse-v70.c under Ubuntu 10.04 LTS (lucid). It seems like there's no package shipping VBoxHDD.h or VBoxHDD-new.h:
root@most:~# apt-file search VBoxHDD
root@most:~# apt-file search VBoxHDD.h
root@most:~# apt-file search VBoxHDD-new.h
root@most:~#

Re: HOWTO: Mount any VBox-compatible disk image on the host

Posted: 23. Jun 2010, 19:36
by stefan.becker
Have you read Top 1) above?

Re: HOWTO: Mount any VBox-compatible disk image on the host

Posted: 23. Jun 2010, 19:54
by penteki
stefan.becker wrote:Have you read Top 1) above?
well, at this point, I didn't... sorry :(

Re: HOWTO: Mount any VBox-compatible disk image on the host

Posted: 3. Jul 2010, 09:28
by i8degrees
Awesome! I just used your script to complete the preparation of my customized OS disk for imaging on over to its real home -- a 2GB CF-II card w/ adapter for IDE use. Computating offsets, while good practice, becomes awfully annoying when you are just trying to get a project quickly under wraps ... thank you for providing this script & saving me time! :-)

Virtualbox, whereas it was a tid bit slow due to my aging hardware, greatly simplified the testing process for bootstrapping a couple disk array nodes across RAID10 and glusterfs. Eight virtual disk drives over software RAID, including LVM volumes and all via virtualization on a close-to identical physical hardware platform. Gotta love it...! :-D

Re: HOWTO: Mount any VBox-compatible disk image on the host

Posted: 20. Jul 2010, 15:10
by jrobiso2
What's the chance that this procedure will allow me to somehow fix a bad snapshot? The CloneVDI tool tells me that one of my earliest snapshots has a bad block map. If the snap were a normal disk, I'd try to fsck it somehow, but being a snap, it's not the same :-(

My users have lost 6 months of emails from this, so any help fixing this snap (so that CloneVDI can fix/rebuild properly) would be greatly appreciated!

Re: Discuss: Mount any VBox-compatible disk image on the host

Posted: 4. Aug 2010, 16:40
by MarcoV
Hello all, hope everything doing fine, I have a problem with VM using linux host, VM installed great but when I turn on the machine and ubuntu start running an error appers " Unable to allocate memory the virtual machine will be paused, please close aplications to free up memory or close the vm, ID error HostMemoryLow", I´m using Windows 7 on my laptop with 1GB RAM, 2.16GHz, already tried to change the memory options in the VM to up of 512 a less to 256GB as a recomendation on the web but the error always appers, Can somebody help me with this thinkg :?: , Thanks !!!!

Re: Discuss: Mount any VBox-compatible disk image on the host

Posted: 30. Sep 2010, 16:13
by sid.mallya
Hey .. In the tutorial I could execute all command but the last mount one .. What is the exact equivalent for "./vdfuse-v<version> -f image.vdi /mnt/vdi" ?

I have a vmdk file.

Re: Discuss: Mount any VBox-compatible disk image on the host

Posted: 4. Apr 2011, 18:07
by norberto

Code: Select all

#!/bin/sh
###
#
# Project:      Automounting VirtualBox VDI raw images in GNU/Linux
#
# File name:    vdimount.sh
# Description:  This script automount any mountable filesystem inside
#               any primary partition of a VirtualBox VDI raw image on
#		GNU/Linux. HDD unit is accesible through a loop device
#               like /dev/loop[X]
#   
# author:       Norberto Fernandez (c) 2011.
# version:      0.1.1
#   
# see The GNU Public License (GPL)
# 
# This program is free software; you can redistribute it and/or modify 
# it under the terms of the GNU General Public License as published by 
# the Free Software Foundation; either version 3 of the License, or 
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful, but 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
# for more details.
# 
# You should have received a copy of the GNU General Public License along 
# with this program; if not, write to the Free Software Foundation, Inc., 
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
###
#
# Usage: ./vdimount.sh <path-to-vdi-image> <mount-point> [partition-number]
#
###

vdifile=$1
mountpoint=$2

partition=1
if [ "$3" != "" ]; then
	partition=$3
fi

image_type=`od -j0x004C -N4 -i $vdifile | awk '{print $2}'`

if [ $image_type = 2 ]; then

	offset_data=`od -j0x0158 -N4 -tu4 $vdifile | awk '{print $2}'`
	disk_size=`od -j0x0170 -N8 -tu8 $vdifile | awk '{print $2}'`

	file_size=`ls -la $vdifile | awk '{print $5}'`
	header_size=`echo "scale=0;$file_size-$disk_size" | bc -l`

	if [ $offset_data = $header_size ]; then

		echo "VDI Image is Static and File Size match OK"
		echo "VDI Bytes Offset to HDD raw image is $offset_data"

		loop_device=`sudo losetup -f`
		sudo losetup $loop_device -o $offset_data $vdifile
		part_info=`sudo parted $loop_device unit s print | grep ^.$partition | sed 's/\([0-9]\+\)s/\1/g' | awk '{print $1,$2,$3,$4,$5,$6,$7}'`

		part_type=`echo $part_info | awk '{print $5}'`

		if [ $part_type = 'primary' ]; then

			filesystem=`echo $part_info | awk '{print $6}'`
			part_sect_off=`echo $part_info | awk '{print $2}'`
			part_offset=`echo "scale=0;$part_sect_off*512" | bc -l`

			if [ $part_offset != 0 ]; then

				total_offset=`echo "scale=0;$offset_data+$part_offset" | bc -l`

				echo "HDD Bytes Offset to Partition $partition is $part_offset"
				echo "VDI Bytes Offset to Partition $partition is $total_offset"

				echo "Partition $partition: Primary with Filesystem $filesystem,"
				echo "will be mounted on $loop_device loop device."

				sudo mount -t $filesystem -o offset=$part_offset $loop_device $mountpoint
			
				if [ $? = 0 ]; then
					echo "Partition $partition from VDI $vdifile was succesfully mounted on $mountpoint"
					exit 0
				fi
			fi
		fi
		sudo losetup -d $loop_device
	fi
fi
echo "Partition $partition from VDI $vdifile can't be mounted"
exit 1


Re: Discuss: Mount any VBox-compatible disk image on the host

Posted: 5. May 2011, 13:36
by przemoc
So another version of "boosted" recipe I posted on my wiki 2.5 years ago is floating on the net? This time with losetup (TBH don't remember all previous incarnations, so cannot tell whether losetup was used before).
And again, w/o any origin information pointing to http://wiki.przemoc.net/tips/linux#moun ... size_image. Yet information about alleged author and license takes 1/3 of the script. ;)

Just saying. :)

Re: Discuss: Mount any VBox-compatible disk image on the host

Posted: 10. May 2011, 08:31
by NeBlackCat
Anyone know if it's possible to copy the vdfuse program from an OSE installation to a PUEL one, and use it to mount VHDs?

I'm assuming the libs (not many from a look at what readelf dumps out) it needs are present in both versions.

I'm actually trying it now, but so far it doesn't want to run ("./vdfuse: 1: Syntax error: end of file unexpected"), so I'm wondering if there's some (probably completely obvious) reason why this is a no-go from the outset.