cannot mount .img file - "not a directory" error
I assume that it's true what Bruce said - that it contains whole partition table. Then there isn't anything unusable in that. For the following command you need util-linux
in version 2.21 or higher.
sudo losetup --find --show -P minix203.img
That should attach your image to a loopback device and show you which loop device the image is attached to (eg. /dev/loop0
). Assuming that, fdisk -l /dev/loop0
should show you the partition table and device names for you to be able to mount those. So you'll end up with something like:
sudo mount /dev/loop0p1 -t minix /mnt/myminix
Should work. Note that loop
option is gone, losetup
takes care of that part.
However, if you happen to not have util-linux
package in right version, you can do this manually using fdisk
and losetup
(or better - install the package from external source). You'll just have to do some calculations in that case. First thing is to attach the image of whole drive:
sudo losetup --find --show part.img
That should tell you the device name - let's assume it's /dev/loop0
. Then, try fdisk -l
on it to get the partition layout:
fdisk -l /dev/loop0
For my file I get output like this:
Disk /dev/loop0: 67 MB, 67108864 bytes, 131072 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2645940b
Device Boot Start End Blocks Id System
/dev/loop0p1 2048 63487 30720 83 Linux
/dev/loop0p2 63488 131071 33792 83 Linux
Don't get deceived, these might not be existent device names. You'll have to determine which partition do you want to mount using this table. Size or filesystem type should let you make some assumptions.
Now it's calculation time - you'll need an offset of your partition and it's size. You get that by multiplying sector sizes by unit size, to get result in bytes. You can see fdisk
tells me that my sector size is 512 bytes, so if I want to mount /dev/loop0p1
, it starts at (2048 * 512)-th byte. That is the offset and it's equal to 1048576 (in case of that example of course).
Size in sectors is end_sector_number - start_sector_number + 1
, because these numbers are inclusive (end sector is within that size). Here it equals 61440 sectors == 31457280 bytes. That's what we needed.
You can detach loopback device now and reattach it limiting it's size constraints to the particular partition you'd like to mount (substite those numbers with your own):
sudo loopback -d /dev/loop0
sudo loopback -f --show -o 1048576 --sizelimit 31457280 part.img
It will probably attach it to /dev/loop0
, which you can now safely mount:
mount -t minix /dev/loop0 /mnt/myminix
That should be almost fully operational, except for things that would normally affect the MBR of whole drive (like formatting with mkfs).
How does it work?
MBR partition table has a simple layout - there's 512 bytes of description first, where do partitions start, where they end, and then goes the data. With extended partitions it might be a little more difficult. You can set limits to your partition manually and that's kind of what kernel does for you on it's own, for your regular hard disk drives.
Related videos on Youtube
Comments
-
infoholic_anonymous over 1 year
I try to execute the following command on an ubuntu 12.04 system:
sudo mount minix203.img -o loop -t minix /mnt/myminix/
in order to mount an .img file with minix partition; and get the following error instead:
mount: Not a directory
what is wrong with my command?
-
tink about 11 yearsdoes /mnt/myminix/ exist, and is it in fact a directory?
-
-
infoholic_anonymous about 11 yearsI get:
losetup: invalid option -- 'P'
-
TNW about 11 yearsTry to install loop-aes-utils package.
-
infoholic_anonymous about 11 years
losetup: invalid option -- '-'
, now it doesn't understand any of the options provided :/ -
TNW about 11 years@infoholic_anonymous I've done a little research, seems that the package containing right
losetup
is util-linux version >= 2.21. Your Ubuntu doesn't contain that, so I'll revise my main answer on how to do that manually. I think you can uninstall that previous packagesudo apt-get purge loop-aes-utils
. -
infoholic_anonymous about 11 yearsthanks. I used the new package and now I get
mount: wrong fs type, bad option, bad superblock on /dev/loop2, missing codepage or helper program, or other error
. the file .img is though ok, I run it on bochs with .bochsrc file given to me. Should I post it, would it help to guess the proper settings? -
TNW about 11 yearsIf you used new
util-linux
and-P
works for you, then your partition is one of/dev/loop2p1
,/dev/loop2p2
and so on. You can view them usingfdisk -l /dev/loop2
. -
infoholic_anonymous about 11 yearsyes, I did that. there is only one partition on /dev/loop0p1 of type "Minix / old Linux" and as I said the mount command fails. I installed the new losetup from source and followed the first method.
-
TNW about 11 years@infoholic_anonymous That's odd. Could you possibly share the image file? I'll try to reproduce the error.