Device file listed by fdisk doesn't exist

Volker Wysk post at volker-wysk.de
Sat Jun 20 13:48:55 UTC 2020


Am Samstag, den 20.06.2020, 15:16 +0200 schrieb Nils Kassube:
> Volker Wysk wrote:
> > I have an image file of an USB stick. It contains a regular MBR and
> > one partition, not just the partition.
> > 
> > I've set up a loop device, like this (*.img part is the image
> > file):
> > 
> > losetup -f "2020-01-09 Wartung 1804.img"
> > 
> > This creates the new loop device /dev/loop23.
> > 
> > Now I wonder how to access the partition inside. I can access the
> > MBR
> > inside /dev/loop23:
> > 
> > -----snip-----
> > desktop ~ % fdisk --list /dev/loop23
> > Festplatte /dev/loop23: 14,3 GiB, 15376318464 Bytes, 30031872
> > Sektoren
> > Einheiten: Sektoren von 1 * 512 = 512 Bytes
> > Sektorgröße (logisch/physikalisch): 512 Bytes / 512 Bytes
> > E/A-Größe (minimal/optimal): 512 Bytes / 512 Bytes
> > Festplattenbezeichnungstyp: dos
> > Festplattenbezeichner: 0x807b71ab
> > 
> > Gerät         Boot Anfang     Ende Sektoren Größe Kn Typ
> > /dev/loop23p1 *      2048 30031871 30029824 14,3G 83 Linux
> 
> The losetup part isn't necessary ...
> 
> file="2020-01-09 Wartung 1804.img"
> fdisk -l "$file"
> sudo mount -oloop,offset=$((2048*512)) "$file" /mnt
> 
> should suffice.

This looks like a very hacky way to do it, to me. I've taken a quick
look at the mount and losetup man pages. If have read correctly, your
solution only applies to the first partition. (Unless you wanted to do
something with that "fdisk -l" output).

I prefer Oliver's solution, which, I think, is much cleaner.

Still thanks,
Volker





More information about the ubuntu-users mailing list