Mounting a Partitioned Image

0

I'm having a bit of difficulty mounting some .img files that I myself didn't create (I've been able to mount ones I've created just fine).

This is what parted shows me for one particular file:

(parted) print                                                            
Model:  (file)
Disk /dir/home/name/directory/imageFile: 16.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  16.0GB  16.0GB  primary  ext3         boot

So, I did the following command:

sudo mount -o loop,offset=$((1049000*512)) -t auto imageFile mountTest/

But then I get:

mount: you must specify the filesystem type

What am I doing wrong here?

Ted Desmond

Posted 2016-05-16T14:08:37.960

Reputation: 3

You’re needlessly multiplying by sector size when the offsets displayed are already in bytes. – Daniel B – 2016-05-16T15:12:36.713

I changed $((1049000*512)) to 1049000 but I still get the same message asking to specify filesystem type. – Ted Desmond – 2016-05-16T15:16:56.033

The sizes are probably in binary bytes. ;) – Daniel B – 2016-05-16T15:18:34.497

@DanielB I interpreted that as 1049kB in parted refers to 1049 kibibytes rather than kilobytes. Is that what you mean? Or do you mean the mount command is asking for the size in binary bytes? I'm a bit confused about the conversions here. – Ted Desmond – 2016-05-16T15:44:11.067

Answers

0

In the parted output you provided, the sizes are not in sectors but bytes. That means you don’t multiply by 512. Also, because the sizes are (in contrast to what I said earlier) apparently not in binary bytes and also rounded, they’re not suitable for your requirements. There are two options here:

  • Use a proper tool (fdisk). It displays sizes in sectors by default.
  • Use a different unit in parted, ie. bytes (b)

Either way, you’ll end up with an offset of 1048576 (1 MiB).

So you can use

mount -o loop,offset=1048576 image target

Daniel B

Posted 2016-05-16T14:08:37.960

Reputation: 40 502

That worked, excellent! Thank you! I'm new to this and it would have taken me forever to figure out on my own. One question, what do you mean by "proper tool" when you refer to fdisk? What's wrong with parted? – Ted Desmond – 2016-05-16T17:21:07.353

I just don’t like parted, I feel like it stops me from working efficiently. – Daniel B – 2016-05-16T17:38:04.007