Re: having trouble mounting disk image on loopback device




Douglas Mayne wrote:
On Sun, 09 Jul 2006 18:13:42 -0700, jasonmbowen wrote:

Here is the output I'm getting when trying to mount a disk image
created by dd that has been assosciate with /dev/loop0

root@ubuntu:~# losetup -d /dev/loop0
root@ubuntu:~# losetup /dev/loop0 ./hdd.dd
root@ubuntu:~# fdisk -l /dev/loop0

Disk /dev/loop0: 4303 MB, 4303290368 bytes
255 heads, 63 sectors/track, 523 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/loop0p1 1 280 2249068+ 83 Linux
/dev/loop0p2 281 523 1951897+ b W95 FAT32
root@ubuntu:~# mount -r -t ext3 /dev/loop1 /mnt/ext3

FWIW, the syntax isn't the same as /etc/fstab reads
Not sure if you did that just to 'distinguish' between the 2 for us...

mount: wrong fs type, bad option, bad superblock on /dev/loop1,
missing codepage or other error
(could this be the IDE device where you in fact use
ide-scsi so that sr0 or sda or so is needed?)
In some cases useful info is found in syslog - try
dmesg | tail or so

I have another image created with dd that I got off a DVD that came
with the book I'm going through and I get the same problem with it.
I'm at a loss as to why this is happening.

Caveat: I have never tried this with a real disk, that is, starting with
a dd image taken from a physical disk.

I agree with the other response that images of partitions are easily
mountable using loopbacks. I thinks that an entire disk image is also
possible, but it is more tricky. To do it, you need to use losetup using
the offset option to indicate the start of each partition. This is a
useful command for getting the correct values for the offset:

# fdisk -lu /dev/loop0

Normally, fdisk specifies cylinders, but the start sector is more useful
in this case. To get the correct value multiply by 512 to get the byte
offset.

To verify this is could work, I setup a test file of 100M with two
partitions, approximately 50M each. Here is the resulting partition
table on the "loopback disk" that I tested:

# losetup /dev/loop0 test.file
# fdisk -lu /dev/loop0

Disk /dev/loop0: 102 MB, 102400000 bytes
255 heads, 63 sectors/track, 12 cylinders, total 200000 sectors
Units = sectors of 1 * 512 = 512 bytes

Device Boot Start End Blocks Id System
/dev/loop0p1 63 96389 48163+ 83 Linux
/dev/loop0p2 96390 192779 48195 83 Linux

Therefore, to mount each partition, I used these commands:
losetup -o 32256 /dev/loop1 test.file
losetup -o 49351690 /dev/loop2 test.file

Final Notes:
Sectors on hard disks were originally addressed by CHS (cylinder,
head, sector), but now LBA is used. LBA should be compatible with
this method, but I am not positive. I'll watch this thread to see
if this is refuted.

I assume these images could be used with VMWare as a "flat" disk.

--
Douglas Mayne

Hi Doug;
I think I learned a little while back that one "mounts" filesystems,
(partitions, not devices) -- hence if one device contains many
*different* filesystem types (ext3, vfat, reiserfs), normally, one
mount command will not suffice...For that matter, even if they are of
the same FS type - I think)

Do I misunderstand ?

I believe your 'offset' option can be of use here, but not sure how to
actually implement it...so

Regards

.



Relevant Pages

  • Re: 200GB IDE disk on old system
    ... the disk so biosroutines can load the kernel? ... Figures below won't work with BIOS for partitions not in cyl 1 ... BIOS sector numbering starts with sector 1 ...
    (comp.unix.bsd.freebsd.misc)
  • Re: [PATCH] make kernel ignore bogus partitions
    ... valid partition table that lists partitions larger than the single disk ... (since the partitions span both disks). ... This causes the kernel to ... a disk because it has a slightly different notion of cylinders that I ...
    (Linux-Kernel)
  • Re: SortMerge avoids thrashing (was: Baileys "two pass" FFT algorithm question)
    ... of size that match the backing store to assure locality of reference. ... For RAM backed by disk, the key thing which takes the most time is ... you need to localize sector reads within that one ... Sweeps your RAM once when you load original data from disk. ...
    (comp.programming)
  • Re: XP Pro Recovery Errors
    ... it turns out that the boot sector, sector 0, of my HDD failed to "read, write, or remove write-protection." ... Hard drives, when they have a problem with a sector, mark it as "pending". ... So if you do something to write to the disk, and write sector zero, ...
    (microsoft.public.windowsxp.general)
  • Re: FUD about CGD and GBDE
    ... > a sector that has been rewritten. ... zone, otherwise it would expose the remaining sectors is the zone. ... contents and regular data written to the disk by the user. ... > possible to determine this fairly quickly using traffic analysis. ...
    (freebsd-hackers)