Re: having trouble mounting disk image on loopback device



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
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

.



Relevant Pages

  • RE: Change Tracks Per Sector on system Partition
    ... mirroring system partitions of a cluster to an offsite SAN due to differing ... We cannot physically read the file system boot sector usually at ... If your software mirror a Windows NT/2000/2003 operating system partition ... another disk that is translated as 32spt, ...
    (microsoft.public.windows.server.setup)
  • Re: grub error 18
    ... because I thought the EXTEND partition would be the second partition in ... the disk using CHS addressing (that is: telling the BIOS a head number, ... The problem with CHS is that the way the head number, cylinder number, ... Note that fdisk says that your disk has 30515 cylinders ... ...
    (uk.comp.homebuilt)
  • Re: [opensuse] raid question
    ... i partition here the new disk (maybe with fdisk, ... The number of cylinders for this disk is set to 4865. ... Command: m ...
    (SuSE)
  • RE: Change Tracks Per Sector on system Partition
    ... >Subject: RE: Change Tracks Per Sector on system Partition ... We cannot physically read the file system boot sector usually at ... >another disk that is translated as 32spt, ...
    (microsoft.public.windows.server.setup)
  • Re: [opensuse] fdisk calculations
    ... I'm revising the partition HOWTO, ... Disk identifier: 0x04030201 ... The Cylinder / Head / Sector concept is an anachronism from the 1980's ... hard drives configured in the factory to have one alignment or the ...
    (SuSE)