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?

4
  • You’re needlessly multiplying by sector size when the offsets displayed are already in bytes.
    – Daniel B
    Commented May 16, 2016 at 15:12
  • I changed $((1049000*512)) to 1049000 but I still get the same message asking to specify filesystem type. Commented May 16, 2016 at 15:16
  • The sizes are probably in binary bytes. ;)
    – Daniel B
    Commented May 16, 2016 at 15:18
  • @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. Commented May 16, 2016 at 15:44

1 Answer 1

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
2
  • 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? Commented May 16, 2016 at 17:21
  • I just don’t like parted, I feel like it stops me from working efficiently.
    – Daniel B
    Commented May 16, 2016 at 17:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .