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

Discussions related to using VirtualBox on Linux hosts.

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

Postby h2o » 11. May 2009, 06:10

[modedit] This is the remains of the howto, which can now be found at 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.
Last edited by h2o on 28. Jun 2010, 01:47, edited 3 times in total.
h2o
 
Posts: 40
Joined: 9. Feb 2009, 04:46

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

Postby dlgroups31 » 9. Jan 2010, 12:10

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
dlgroups31
 
Posts: 1
Joined: 8. Jan 2010, 14:09
Primary OS: Ubuntu 8.10
VBox Version: OSE Debian
Guest OSses: any

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

Postby wireless » 10. Apr 2010, 02:09

Will this work for a dynamically expandable file system as well?
wireless
 
Posts: 3
Joined: 10. Apr 2010, 01:44
Primary OS: Ubuntu other
VBox Version: OSE other
Guest OSses: Windows XP

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

Postby lfloyd » 15. May 2010, 01:09

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.
lfloyd
 
Posts: 1
Joined: 15. May 2010, 00:48
Primary OS: Ubuntu other
VBox Version: OSE other
Guest OSses: Ubuntu

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

Postby fixedwheel » 15. May 2010, 01:51

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
fixedwheel
Volunteer
 
Posts: 1699
Joined: 13. Sep 2008, 02:18

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

Postby penteki » 23. Jun 2010, 19:11

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:~#
penteki
 
Posts: 4
Joined: 2. Oct 2009, 23:23
Primary OS: Ubuntu other
VBox Version: OSE other
Guest OSses: Linux, Windows


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

Postby penteki » 23. Jun 2010, 19:54

stefan.becker wrote:Have you read Top 1) above?

well, at this point, I didn't... sorry :(
penteki
 
Posts: 4
Joined: 2. Oct 2009, 23:23
Primary OS: Ubuntu other
VBox Version: OSE other
Guest OSses: Linux, Windows

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

Postby i8degrees » 3. Jul 2010, 09:28

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
i8degrees
 
Posts: 1
Joined: 3. Jul 2010, 09:13
Primary OS: Ubuntu other
VBox Version: OSE other
Guest OSses: Debian, FreeBSD, Ubuntu

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

Postby jrobiso2 » 20. Jul 2010, 15:10

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!
jrobiso2
 
Posts: 6
Joined: 19. Jul 2010, 01:28
Primary OS: openSUSE
VBox Version: OSE other
Guest OSses: openSuSE

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

Postby MarcoV » 4. Aug 2010, 16:40

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 !!!!
MarcoV
 
Posts: 1
Joined: 4. Aug 2010, 16:17
Primary OS: MS Windows 7
VBox Version: OSE Debian
Guest OSses: Ubuntu 10.0.4

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

Postby sid.mallya » 30. Sep 2010, 16:13

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.
sid.mallya
 
Posts: 1
Joined: 30. Sep 2010, 16:08
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows XP

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

Postby norberto » 4. Apr 2011, 18:07

Code: Select all   Expand viewCollapse view
#!/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

norberto
 
Posts: 1
Joined: 22. Mar 2011, 20:19
Primary OS: Ubuntu other
VBox Version: OSE other
Guest OSses: GNU/Linux many flavours

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

Postby przemoc » 5. May 2011, 13:36

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#mounting_partition_from_vdi_fixed-size_image. Yet information about alleged author and license takes 1/3 of the script. ;)

Just saying. :)
AMD Athlon 64 X2 4600+ (2.4GHz) | GeIL DDR2-800 2x 2x1GB Ultra (4-4-4-12) | Abit KN9 (nForce 4 Ultra) | Palit GeForce GTX460 1024MB GDDR5 | be quiet! Straight Power CM 680W | HD321KJ (320GB) | 2xHD403LJ (400GB) [RAID0] | HD103UJ (1TB) | WD1002FAEX (1TB) | LH20A1H (DVD+RW) | iHBS212 (BD-RE) | MX1000 | Soprano RS 101 | iiyama ProLite B2403WS
przemoc
 
Posts: 30
Joined: 4. Sep 2008, 16:02
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Linux, Windows

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

Postby NeBlackCat » 10. May 2011, 08:31

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.
NeBlackCat
 
Posts: 154
Joined: 3. Aug 2008, 13:37

Next

Return to VirtualBox on Linux Hosts

Who is online

Users browsing this forum: Bing [Bot] and 20 guests