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

Discussions related to using VirtualBox on Linux hosts.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

@fgleich, there really isn't any point in saying you get segmentation fault or invalid argument unless you give use more context, e.g. what commands you typed and what the exact error response was.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
fgleich
Posts: 10
Joined: 15. Feb 2009, 08:03

Post by fgleich »

The segmentation fault error happened because the vdi file was located in my user home dir, and I tried to mount it as root and used the ~ in the path without thinking. When I did use the correct path by trying to mount it like this:

" /home/fgleich/fuse/vdfuse/vdfuse -f WinXP2.vdi vdi "

I got this error:

" fuse: mount failed: Invalid argument "
fgleich
Posts: 10
Joined: 15. Feb 2009, 08:03

Post by fgleich »

Here are all the compilation data I used:

Code: Select all

gcc vdfuse.c -o vdfuse -L/lib -lfuse -L/usr/lib/virtualbox -lVBoxDD -Wl,-rpath,/usr/lib/virtualbox -I/home/fgleich/vbox/VirtualBox-2.1.2_OSE/include -D_FILE_OFFSET_BITS=64 
The compiler insisted I put that -D_FILE_OFFSET_BITS=64 thing in there, or it wouldn't work.

I'm only doing this because I can't make a virtual image to work with that old vdi file so I can start it to extract some data that's locked up in there. If I could get it running with virtualbox, I'd prefer that way. When I do try to start it ( after hooking it up to a virtual machine I create for it ), windows tries to start but shuts down and gives a blue screen with some error codes

I'll post that URL with the error codes pics here if you want.
fgleich
Posts: 10
Joined: 15. Feb 2009, 08:03

Post by fgleich »

here's some photos of win trying to start:

http://www.flickr.com/photos/gleichf/32 ... 8/sizes/l/
,
http://www.flickr.com/photos/gleichf/32 ... 4/sizes/o/

when I created the virtual machine, I went through the old vdi file's xml file and looked at the video memory and the base memory, and used the same numbers for the new virtual machine. Is there something else I should set ?

Since I couldn't get the above to work, I thought I would be able to mount the vdi file somehow and then extract my data.

ok, thanks for all your help !
echo6
Posts: 9
Joined: 13. Oct 2007, 19:07

Post by echo6 »

What version of fuse are you using? If you have the strace command, I would also like to know the output of strace <mount command>.
fusermount 2.7.2 I'm using the latest kernel 2.6.28.5

You really want all the strace output from mount?
h2o
Posts: 40
Joined: 9. Feb 2009, 04:46

Post by h2o »

echo6 wrote:
What version of fuse are you using? If you have the strace command, I would also like to know the output of strace <mount command>.
fusermount 2.7.2 I'm using the latest kernel 2.6.28.5

You really want all the strace output from mount?
Yes, it might help.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

fgleich wrote:Here are all the compilation data I used:

Code: Select all

gcc vdfuse.c -o vdfuse -L/lib -lfuse -L/usr/lib/virtualbox -lVBoxDD -Wl,-rpath,/usr/lib/virtualbox -I/home/fgleich/vbox/VirtualBox-2.1.2_OSE/include -D_FILE_OFFSET_BITS=64 
The compiler insisted I put that -D_FILE_OFFSET_BITS=64 thing in there, or it wouldn't work.
I am not sure what your problem is here on my Ubuntu Hardy 32bit system, here is the command that I use:d

Code: Select all

gcc vdfuse.c -o vdfuse `pkg-config --cflags --libs fuse` -l:/usr/lib/virtualbox/VBoxDD.so -Wl,-rpath,/usr/lib/virtualbox -pthread -I ~/VBox/include

I also check the sizing of various types such as the type off_t which is used for filesystem sizing and offsets and is 8bytes on both 32bit and 64b Ubuntu systems.

What I don't understand is why you are showing us copies of VMs starting or BSODing. The whole point of this thread is to be able to manipulate the content of VDIs within the host OS and going nowhere near a VM; you need to post those issues on a separate product.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
fgleich
Posts: 10
Joined: 15. Feb 2009, 08:03

@ Terry

Post by fgleich »

I showed those things because I thought they might jog someones memory about some issue related to what the problem is with this. Having that in a separate thread just makes the troubleshooting problem harder than it has to be.

That said, how do you check those sizes ? Please show me, thank you.

and here is the output running it through strace:

Code: Select all

strace /home/fgleich/fuse/vdfuse/vdfuse -f WinXP2.vdi vdi
execve("/home/fgleich/fuse/vdfuse/vdfuse", ["/home/fgleich/fuse/vdfuse/vdfuse"..., "-f", "WinXP2.vdi", "vdi"], [/* 67 vars */]) = 0
brk(0)                                  = 0x804d000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f07000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/usr/lib/virtualbox/tls/i686/sse2/libfuse.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/virtualbox/tls/i686/libfuse.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/virtualbox/tls/sse2/libfuse.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/virtualbox/tls/libfuse.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/virtualbox/i686/sse2/libfuse.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/virtualbox/i686/libfuse.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/virtualbox/sse2/libfuse.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/virtualbox/libfuse.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=89198, ...}) = 0
mmap2(NULL, 89198, PROT_READ, MAP_PRIVATE, 4, 0) = 0xb7ef1000
close(4)                                = 0

**** plus similar Load path searches and maps for ****

open("/lib/libfuse.so.2", O_RDONLY)     = 4
open("/usr/lib/virtualbox/VBoxDD.so", O_RDONLY) = 4
open("/lib/i686/libc.so.6", O_RDONLY)   = 4
open("/usr/lib/virtualbox/VBoxDDU.so", O_RDONLY) = 4
open("/lib/i686/librt.so.1", O_RDONLY)  = 4
open("/lib/libdl.so.2", O_RDONLY)       = 4
open("/lib/i686/libpthread.so.0", O_RDONLY) = 4
open("/usr/lib/virtualbox/VBoxVMM.so", O_RDONLY) = 4
open("/usr/lib/virtualbox/VBoxRT.so", O_RDONLY) = 4
open("/usr/lib/virtualbox/VBoxDD2.so", O_RDONLY) = 4
open("/usr/lib/libstdc++.so.6", O_RDONLY) = 4
open("/lib/libgcc_s.so.1", O_RDONLY)    = 4
open("/usr/lib/virtualbox/VBoxREM.so", O_RDONLY) = 4
open("/lib/i686/libm.so.6", O_RDONLY)   = 4


set_thread_area({entry_number:-1 -> 6, base_addr:0xb61836d0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0xb61aa000, 536576, PROT_READ|PROT_WRITE) = 0
mprotect(0xb61aa000, 536576, PROT_READ|PROT_EXEC) = 0
mprotect(0xb7b3a000, 12288, PROT_READ)  = 0
mprotect(0xb7b46000, 155648, PROT_READ|PROT_WRITE) = 0
mprotect(0xb7b46000, 155648, PROT_READ|PROT_EXEC) = 0
mprotect(0xb7b6d000, 458752, PROT_READ|PROT_WRITE) = 0
mprotect(0xb7b6d000, 458752, PROT_READ|PROT_EXEC) = 0
mprotect(0xb7be1000, 1048576, PROT_READ|PROT_WRITE) = 0
mprotect(0xb7be1000, 1048576, PROT_READ|PROT_EXEC) = 0
mprotect(0xb7d04000, 147456, PROT_READ|PROT_WRITE) = 0
mprotect(0xb7d04000, 147456, PROT_READ|PROT_EXEC) = 0
mprotect(0xb7e50000, 4096, PROT_READ)   = 0
mprotect(0xb7e56000, 503808, PROT_READ|PROT_WRITE) = 0
mprotect(0xb7e56000, 503808, PROT_READ|PROT_EXEC) = 0
mprotect(0xb7f21000, 4096, PROT_READ)   = 0
munmap(0xb7ef1000, 89198)               = 0
set_tid_address(0xb6183718)             = 11970
sendto(-1239927008, umovestr: Input/output error
0xc, 3083808756, MSG_PROXY|MSG_EOR|MSG_ERRQUEUE|MSG_DONTWAIT|MSG_FIN|MSG_SYN|MSG_RST|0xb6180000, ptrace: umoven: Input/output error
{...}, 3212969224) = 0
rt_sigaction(SIGRTMIN, {0xb7ce76e0, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0xb7ce75f0, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
_sysctl({{CTL_KERN, KERN_VERSION}, 2, 0xbf820260, 35, (nil), 0}) = 0
futex(0xb7b404dc, FUTEX_WAKE, 2147483647) = 0
brk(0)                                  = 0x804d000
brk(0x806e000)                          = 0x806e000
open("/usr/share/locale/locale-archive", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/locale.alias", O_RDONLY) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=2586, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f06000
read(4, "# Locale name alias data base.\n#"..., 4096) = 2586
read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0xb7f06000, 4096)                = 0
open("/usr/share/locale/en_US.UTF-8/LC_CTYPE", O_RDONLY) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=243680, ...}) = 0
mmap2(NULL, 243680, PROT_READ, MAP_PRIVATE, 4, 0) = 0xb6147000
close(4)                                = 0
open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=26026, ...}) = 0
mmap2(NULL, 26026, PROT_READ, MAP_SHARED, 4, 0) = 0xb7f00000
close(4)                                = 0
futex(0xb7e52a4c, FUTEX_WAKE, 2147483647) = 0
access("WinXP2.vdi", R_OK|W_OK)         = 0
open("WinXP2.vdi", O_RDONLY|O_LARGEFILE) = 4
read(4, "<<< inno", 8)                  = 8
open("WinXP2.vdi", O_RDWR|O_LARGEFILE)  = 5
_llseek(5, 0, [0], SEEK_SET)            = 0
read(5, "<<< innotek VirtualBox Disk Imag"..., 72) = 72
_llseek(5, 72, [72], SEEK_SET)          = 0
read(5, "\220\1\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
_llseek(5, 72, [72], SEEK_SET)          = 0
read(5, "\220\1\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 400) = 400
_llseek(5, 512, [512], SEEK_SET)        = 0
read(5, "\0\0\0\0^\4\0\0\233\6\0\0\301\n\0\0\1\0\0\0\235\0\0\0_"..., 20164) = 20164
_llseek(5, 21502, [21502], SEEK_SET)    = 0
read(5, "U\252", 2)                     = 2
_llseek(5, 21438, [21438], SEEK_SET)    = 0
read(5, "\200\1\1\0\v\376\277\200?\0\0\0\2!\235\0", 16) = 16
_llseek(5, 21454, [21454], SEEK_SET)    = 0
read(5, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 16
_llseek(5, 21470, [21470], SEEK_SET)    = 0
read(5, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 16
_llseek(5, 21486, [21486], SEEK_SET)    = 0
read(5, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 16
geteuid32()                             = 0
getegid32()                             = 0
getcwd("/home/fgleich/.VirtualBox/VDI", 4096) = 30
lstat64("/home/fgleich/.VirtualBox/VDI/vdi", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/dev/null", O_RDWR|O_LARGEFILE)   = 6
close(6)                                = 0
lstat64("/home/fgleich/.VirtualBox/VDI/vdi", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/home/fgleich/.VirtualBox/VDI/vdi", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 6
fstat64(6, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
fcntl64(6, F_SETFD, FD_CLOEXEC)         = 0
getdents64(6, /* 2 entries */, 4096)    = 48
getdents64(6, /* 0 entries */, 4096)    = 0
close(6)                                = 0
open("/dev/fuse", O_RDWR|O_LARGEFILE)   = 6
getgid32()                              = 0
getuid32()                              = 0
mount("", "/home/fgleich/.VirtualBox/VDI/vdi", "fuse.", MS_NOSUID|MS_NODEV, "allow_other,fd=6,rootmode=40000,"...) = -1 EINVAL (Invalid argument)
write(2, "fuse: mount failed: Invalid argu"..., 37fuse: mount failed: Invalid argument
) = 37
close(6)                                = 0
exit_group(1) 
sorry for the length. Looks like it can't find something. I"m not using pkg-config because it didn't come packaged in the repository rpm. Maybe the thing to do is to remove all the repository rpm stuff, and install the virtualbox_OSE thing until I get this problem taken care of ?

Thanks for the help
h2o
Posts: 40
Joined: 9. Feb 2009, 04:46

Post by h2o »

Make sure that /dev/fuse is at mode 0666, then run it again as a REGULAR user (I couldnt get it to run as root either) :roll: Make sure you have permissions to both the image and the mountpoint.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

OK, so what where the arguments to your vdfuse command? Looking at this you barfed on the

Code: Select all

mount("", "/home/fgleich/.VirtualBox/VDI/vdi", "fuse.", MS_NOSUID|MS_NODEV, "allow_other,fd=6,rootmode=40000,"...) = -1 EINVAL (Invalid argument)
write(2, "fuse: mount failed: Invalid argu"..., 37fuse: mount failed: Invalid argument
) = 37
Did you change your /etc/fuse.conf to enable allow_other?
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
fgleich
Posts: 10
Joined: 15. Feb 2009, 08:03

ok, that worked

Post by fgleich »

after I chmoded /dev/fuse, and added a /etc/fuse.conf file, which looks like this:

# Set the maximum number of FUSE mounts allowed to non-root users.
# The default is 1000.
#
#mount_max = 1000

# Allow non-root users to specify the 'allow_other' or 'allow_root'
# mount options.
#
user_allow_other

Thanks for your help, I hope this helps others :D
chungy
Volunteer
Posts: 132
Joined: 26. Jan 2008, 10:27

Post by chungy »

I can't get Terry's utility to actually work:
$ ./vdfuse -f ~/.VirtualBox/HardDisks/Debian\ \"Squeeze\".vdi mnt
$ ls mnt
ls: reading directory mnt: Input/output error

I compile it with: cc -o vdfuse vdfuse.c `pkg-config --cflags --libs fuse` -l:/usr/lib/virtualbox/VBoxDD.so -Wl,-rpath,/usr/lib/virtualbox -I/home/mike/Source/VirtualBox-2.1.4_OSE/include

This is on Debian 5.0/amd64.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

I've uploaded the latest version at http://files.ellisons.org.uk/VBox/vdfuse_TE_30.tar.gz. I've tested this on AMD-64 and AMD-32 Ubuntu. I works OK as long as you dismount the loop mounted partition(s) before the underlying vdfuse mount.

Try running the vdfuse mount in its own command window with the -d -v options. I am not sure but the embedded quotes in the file name is probably the reason, since this passes the parameters down into fuse and
\"Squeeze\".vdi will get read and passed as "Squeeze".vdi. A bit bizarre embedding quotes inside your filenames, eh?
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
chungy
Volunteer
Posts: 132
Joined: 26. Jan 2008, 10:27

Post by chungy »

Doesn't really seem odd to me, but anyhow, the newer version works fine.

Edit: actually, this is weirder, I can't actually read the individual partitions (or mount them); doesn't matter what the source image filename is:

Code: Select all

$ ./vdfuse -f ~/.VirtualBox/HardDisks/Windows\ 95.vdi m
$ ls -l m
total 4193729
-rw------- 1 mike mike 2147483648 2009-02-28 18:35 EntireDisk
-rw------- 1 mike mike 1994162688 2009-02-28 18:35 Partition1
-rw------- 1 mike mike  152732160 2009-02-28 18:35 Partition5
$ file m/*
m/EntireDisk: x86 boot sector, mbr; partition 1: ID=0xb, starthead 1, startsector 63, 3894849 sectors; partition 2: ID=0x5, starthead 0, startsector 3894912, 298368 sectors
m/Partition1: writable, regular file, no read permission
m/Partition5: writable, regular file, no read permission

the debug messages on the console:
open: /Partition1, 0
   unique: 146, error: -2 (No such file or directory), outsize: 16
unique: 147, opcode: LOOKUP (1), nodeid: 1, insize: 51
LOOKUP /Partition5
getattr: /Partition5
   NODEID: 4
   unique: 147, error: 0 (Success), outsize: 136
unique: 148, opcode: OPEN (14), nodeid: 4, insize: 48
open: /Partition5, 0
   unique: 148, error: -2 (No such file or directory), outsize: 16
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

OK, I've got the test case. I'll have a look tomorrow.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
Post Reply