Page 2 of 13
Posted: 14. Feb 2009, 22:07
by TerryE
I've made my own version which you can get download from
here. It only works with version 2.x. I've included both the source and the binary for Ubuntu x64. I am still playing with it. I can do thinks like:
Code: Select all
>mkdir m m1
>
>./vdfuse -h
DESCRIPTION: This Fuse module uses the VirtualBox access library to open a
VirtualBox supported VD image file and mount it as a Fuse file system. The
mount point contains a flat directory containing the files EntireDisk,
Partition1 .. PartitionN. These can then be loop mounted to access the
underlying file systems
USAGE: %s [options] -f image-file mountpoint
-h help
-r readonly
-t specify type (VDI, VMDK, VHD, or raw; default: auto)
-f VDimage file
-a allow all users to read disk
-w allow all users to read and write to disk
-g run in foreground
-v verbose
-d debug
>./vdfuse -f temp.vdi m
>ls m
EntireDisk Partition1
>sudo mount m/Partition1 m1 -t ext3 -o loop=/dev/loop0
>ls m1
total 68
drwxr-xr-x 2 root root 4096 2009-01-23 06:51 backups
drwxr-xr-x 8 root root 4096 2008-05-28 17:15 cache
drwxr-xr-x 3 root root 4096 2008-07-10 01:30 home
drwxr-xr-x 22 root root 4096 2008-10-24 22:39 lib
...
It works fine. However I need to play with the supported functions because I want to be able to do things like
Code: Select all
dd if=s/EntireDisk of=d/EntireDisk bs=512 count=1
but at the moment this requires me to add setaddr support. Still, it's a start.
Posted: 15. Feb 2009, 03:52
by TerryE
I've ran a tiny perl script against various files to stat them.
Code: Select all
perl -e '@x=stat("s/Partition1");map {printf "%08X\n",$_;} @x;'
and here are tabulated results:
Code: Select all
/dev/sda /dev/sda1 s s/EntireDisk s/Partition1 aFile aDir
0 dev device number of filesystem 0000000E 0000000E 00000018 00000018 00000018 00000801 00000801
1 ino inode number 0000170C 00001739 00000001 00000002 00000003 00096D33 000422AC
2 mode file mode (type and permissions) 000061B0 000061B0 000041C0 000081B0 000081B0 000081A4 000041ED
3 nlink number of (hard) links to the file 00000001 00000001 00000000 00000001 00000001 00000001 00000002
4 uid numeric user ID of file's owner 00000000 00000000 00000000 000003E8 000003E8 000003E8 000003E8
5 gid numeric group ID of file's owner 00000006 00000006 00000000 000003E8 000003E8 000003E8 000003E8
6 rdev the device identifier 00000800 00000801 00000000 00000000 00000000 00000000 00000000
7 size total size of file, in bytes 00000000 00000000 00000000 38000000 37FC0200 000052DD 00001000
8 atime last access time in secs since epoch 4996C240 4996C235 00000000 00000000 00000000 49971248 49977267
9 mtime last modify time in secs since epoch 4996C227 4996C235 00000000 00000000 00000000 49971238 49977267
10 ctime inode change time in secs since epoch 4996C232 4996C235 00000000 00000000 00000000 49971238 49977267
11 blksize preferred block size 00001000 00001000 00001000 00001000 00001000 00001000 00001000
12 blocks actual number of blocks allocated 00000000 00000000 00000000 00000000 00000000 00000030 00000008
You will see from this I have a problem with the file attributes and the size of the EntireDisk pseudo-file.
Posted: 15. Feb 2009, 09:04
by h2o
echo6 wrote:Tried with the fuse version which compiled fine but I can't mount the vdi image.
Code: Select all
root@toshiba:/home/echo6/.VirtualBox/VDI# /home/echo6/vdifuse -v -r -t VDI -f /home/echo6/.VirtualBox/VDI/disk1.vdi /media/test/
Partition 1:
Offset: 32256 bytes
Size: 106896384 bytes
Partition 2:
Offset: 106928640 bytes
Size: 1011709440 bytes
Partition 3:
Offset: 1118638080 bytes
Size: 4244244480 bytes
fuse: mount failed: Invalid argument
Code: Select all
./vdimount -v -f /home/echo6/.VirtualBox/VDI/disk1.vdi partition-number=raw /media/test
ERROR: invalid partition number 0 or port number 0
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>.
Posted: 15. Feb 2009, 15:06
by TerryE
echo6 wrote:./vdimount -v -f /home/echo6/.VirtualBox/VDI/disk1.vdi partition-number=raw /media/test
ERROR: invalid partition number 0 or port number
I've highlighted the relevant argument: this format isn't supported by the current utility. H2O and I are still getting to grips with the fuse system. I am going to sort out this other stuff today so that things like
dding to the
/EntireDisk work
Posted: 15. Feb 2009, 22:10
by TerryE
There are some subtleties here and some issues that I need to bottom out. For example in a test I do a
Code: Select all
VDI=/var/images/VirtualBox/VDIs #
VBoxManage -nologo createhd -filename dest.vdi -size 1920 -format VDI
mkdir s sp d dp
./vdfuse -f $VDI/src.vdi s
ls -l s
then
s correctly shows up with permissions
dr-xr-x---. The reason for this is that you clearly can't create new partitions in
s by writing to it. Also the files in s (
Partition1 etc.) are not block mounted files so if you try to do a
dd if=s/EntireDisk of=d/EntireDisk bs=512 count=1, this will fail because dd will try to create a new file. However you can clone a disk structure as the following terminal extract shows:
Code: Select all
> mkdir s sp d dp
> ./vdfuse -f $VDI/source.vdi s
> ./vdfuse -f $VDI/dest.vdi d
> ls s
EntireDisk Partition1 Partition2 Partition3
> ls d
EntireDisk
>
> cat copyMBR.pl
# Note that this only copies the MBR so doesn't work for extented partitions
open INMBR, shift or die;
open OUTMBR, '+<'.shift or die;
binmode INMBR; binmode OUTMBR;
sysread INMBR,$buf,512,0;
syswrite OUTMBR,$buf,512,0;
exit;
> perl copyMBR.pl s/EntireDisk d/EntireDisk
>
># Need to unmount and remount dest.vdi to reread the partition table
>
> sudo umount d
> ./vdfuse -f dest.vdi d
> ls d
EntireDisk Partition1 Partition2 Partition3
> sudo mount s/Partition1 sp -t ext3 -o loop=/dev/loop0
> mkfs.ext3 -F d/Partition1
mke2fs 1.40.8 (13-Mar-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
75840 inodes, 302896 blocks
15144 blocks (5.00%) reserved for the super user
First xdata block=0
Maximum filesystem blocks=310378496
10 block groups
32768 blocks per group, 32768 fragments per group
7584 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
> mkswap d/Partition2
Setting up swapspace version 1, size = 440741 kB
no label, UUID=c4470a25-0ab3-4762-b2af-1aadb1e1a1d3
> mkfs.ext3 -F d/Partition3
mke2fs 1.40.8 (13-Mar-2008)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
80960 inodes, 323568 blocks
16178 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
40 block groups
8192 blocks per group, 8192 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
and I have now configured the VDI from the host! Unfortunately the next step which is to clean copy the system partition:
Code: Select all
sudo mount s/Partition1 sp -t ext3 -o loop=/dev/loop0,ro
sudo mount d/Partition1 dp -t ext3 -o loop=/dev/loop1
cd dp; sudo mkdir sys proc dev
cd ../sp; sudo cp -a $(ls | egrep -v '^sys|^proc|^lost|^dev') ../dp
usually hangs the PC in such a way that I need to reboot! I haven't bottomed this out yet, but I have posted an updated version of source and Ubuntu-x64 binary here:
http://files.ellisons.org.uk/VBox/vdfuze_TE_20.tar.gz
Upwards on onwards
32 bit version
Posted: 15. Feb 2009, 23:57
by fgleich
Do you have a 32 bit version of this ? I need to mount a vdi file that I had archived before I reinstalled a newer version of pclos. I can't get vdfuse to compile, get errors. I'm pretty sure this is a 32 bit version.
thanks !
Posted: 16. Feb 2009, 00:21
by TerryE
No I haven't. Sorry. Have you installed libfuse-dev and the VBox OSE source?
Re: 32 bit version
Posted: 16. Feb 2009, 01:30
by h2o
fgleich wrote:Do you have a 32 bit version of this ? I need to mount a vdi file that I had archived before I reinstalled a newer version of pclos. I can't get vdfuse to compile, get errors. I'm pretty sure this is a 32 bit version.
thanks !
Can you please show us the error?
Posted: 16. Feb 2009, 03:19
by TerryE
fgleich, sorry, but I just compiled it on another 32bit Ubuntu system it compiled fine so you haven't read the instructions in the program. I then did the following:
Code: Select all
> ./vdfuse -f /media/NewE/VirtualBox/VDIs/sysCv4.vdi s
> sudo mount s/Partition1 sp -t ntfs-3g -o loop=/dev/loop0
> ls -l sp
total 1547893
-rwxrwxrwx 1 root root 0 2005-10-18 21:41 AUTOEXEC.BAT
-rwxrwxrwx 1 root root 211 2005-10-18 21:34 boot.ini
-rwxrwxrwx 1 root root 0 2005-10-18 21:41 CONFIG.SYS
drwxrwxrwx 1 root root 4096 2005-10-19 01:37 Documents and Settings
-rwxrwxrwx 1 root root 0 2005-10-18 21:41 IO.SYS
-rwxrwxrwx 1 root root 0 2008-08-14 16:41 Log.txt
-rwxrwxrwx 1 root root 0 2005-10-18 21:41 MSDOS.SYS
-rwxrwxrwx 1 root root 47564 2004-08-04 13:00 NTDETECT.COM
-rwxrwxrwx 1 root root 250048 2008-06-14 18:35 ntldr
-rwxrwxrwx 1 root root 1584635904 2008-08-14 16:41 pagefile.sys
drwxrwxrwx 1 root root 16384 2008-08-11 16:40 Program Files
drwxrwxrwx 1 root root 4096 2005-10-19 22:21 RECYCLER
drwxrwxrwx 1 root root 4096 2005-10-18 21:46 System Volume Information
drwxrwxrwx 1 root root 4096 2008-08-14 20:50 Temp
drwxrwxrwx 1 root root 69632 2008-08-13 17:30 WINDOWS
> df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda7 21811412 4088708 16623460 20% /
...
gvfs-fuse-daemon 21811412 4088708 16623460 20% /home/terry/.gvfs
/dev/loop0 16000708 7009484 8991224 44% /home/terry/fuse/sp
> ls -l /media/NewE/VirtualBox/VDIs/sysCv4.vdi
-rw------- 1 terry terry 7457538048 2009-02-16 01:07 /media/NewE/VirtualBox/VDIs/sysCv4.vdi
So here I have a 1.6Gb dynamic VDI which contains an NTFS system partition which actually occupies ~740Mb and contains about 700Mb of files.
Actually, I'm getting this error when I try to compile:
Posted: 16. Feb 2009, 04:20
by fgleich
vdfuse.c:91:30: error: VBox/VBoxHDD-new.h: No such file or directory
I can't find that file anywhere in the VBox dirs. Is it from an older version of VBox ?
thanks
Re: Actually, I'm getting this error when I try to compile:
Posted: 16. Feb 2009, 04:58
by h2o
fgleich wrote:vdfuse.c:91:30: error: VBox/VBoxHDD-new.h: No such file or directory
I can't find that file anywhere in the VBox dirs. Is it from an older version of VBox ?
thanks
No, you need the header files. Go download the virtualbox ose tarball and unpack it. Then run this:
Code: Select all
gcc vdfuse.c -o vdfuse `pkg-config --cflags --libs fuse` -l:/path/to/virtualbox/VBoxDD.so -Wl,-rpath,/path/to/virtualbox -I/unpacked/ose/tarball/include
Replace /path/to/virtualbox with your virtualbox install (it has a file named VBoxDD.so) and /unpacked/ose/tarball with the path to your unpacked tarball.
Posted: 16. Feb 2009, 05:01
by fgleich
OK, I don't have the OSE sources. I'll try that. Thanks for the help !
OK, got it to compile
Posted: 16. Feb 2009, 08:08
by fgleich
now when I try to mount the vdi file, I get a segmentation fault. This happens even on a vdi file I know to work correctly. What do you think ?
sorry, it's late, I'm tired
Posted: 16. Feb 2009, 08:19
by fgleich
it gives me the error of invalid argument again. What could be causing this ? BTW, thanks for your help
Posted: 16. Feb 2009, 11:25
by Technologov
Looks like an interesting effort...