View previous topic :: View next topic |
Author |
Message |
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54577 Location: 56N 3W
|
Posted: Sat Apr 24, 2021 7:27 pm Post subject: Mount a Filesystem from a Sparse Disk Image [Understood] |
|
|
Team,
I have a sparse *vhd file that looks like a HDD but isn't quite.
There is a header for Virtualbx at the start and the real disk image starts at 0xa800.
Code: | losetup -fP -o 0xa800 /home/roy/VirtualBox\ VMs/Gentoo_09-April-2003_i586_root.vhd | does its thing and gets me /dev/loop0 and its two partitions.
Code: | fdisk -l /dev/loop0 | shows me the partition table correctly.
Trying Code: | mount -o ro /dev/loop0p2 /mnt/floppy | fails and dmesg tells me
Code: | [21445.925728] loop0: p1 p2
[21445.925762] loop0: p2 size 41849325 extends beyond EOD, truncated
[21575.692938] EXT4-fs (loop0p2): VFS: Can't find ext4 filesystem |
Decoding the partition table and adding the offset says that
Code: | # mount -t ext3 -o ro,offset=0x2743200 /home/roy/VirtualBox\ VMs/Gentoo_09-April-2003_i586_root.vhd /mnt/floppy
mount: /mnt/floppy: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error. | is the same thing.
Its a disk image in a sparse file. Its not supposed to be all there. What have I missed? _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Last edited by NeddySeagoon on Sun Apr 25, 2021 10:51 am; edited 1 time in total |
|
Back to top |
|
|
molletts Tux's lil' helper
Joined: 16 Feb 2013 Posts: 129
|
Posted: Sun Apr 25, 2021 10:19 am Post subject: |
|
|
Is it an actual proper sparse file or does VirtualBox use some kind of proprietary format for its dynamic disk images?
If it's truly a sparse file, its size as reported by 'ls -l' will be the reported size of the disk plus any headers, not the size of the contained data.
For example, I just created a 1TB sparse file on a 120-odd GB partition:
Code: | $ ls -l /media/alpha/big-sparse-file
-rw-r--r-- 1 stephen users 1099511627776 Apr 25 10:05 /media/alpha/big-sparse-file
$ df /media/alpha
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda4 129232268 63626372 58998220 52% /media/alpha |
If I set up a loop device and create a partition table on it, fdisk reports the full available size despite the disk it's actually on being far smaller:
Code: | # fdisk -l /dev/loop1
Disk /dev/loop1: 1 TiB, 1099511627776 bytes, 2147483648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2ee1f4bb
Device Boot Start End Sectors Size Id Type
/dev/loop1p1 2048 2147483647 2147481600 1024G 83 Linux |
If it's a proprietary format, the easiest solution might be to attach it to a VM (even a temporary one running the minimal install image or something) and copy the data out to a real sparse file using 'dd conv=sparse'.
Hope this is some help!
Stephen |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54577 Location: 56N 3W
|
Posted: Sun Apr 25, 2021 10:51 am Post subject: |
|
|
molletts,
Thank you for that insight.
Code: | $ ls -l /home/roy/VirtualBox\ VMs/Gentoo_09-April-2003_i586_root.vhd -h
-rw------- 1 roy roy 2.6G Apr 20 13:51 '/home/roy/VirtualBox VMs/Gentoo_09-April-2003_i586_root.vhd' |
Its not a real sparse file, That should be about 20G.
I'll fix VirtualBox and do it properly. Copying things out is not trivial. That VB really is a 09-April-2003_i586_root so ssh, and friends no longer work.
Telnet is still good though and nfs ver3 work. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|