LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to mount .img file (https://www.linuxquestions.org/questions/linux-general-1/how-to-mount-img-file-882386/)

linuxboy2008 05-24-2011 12:49 AM

how to mount .img file
 
hi,
i want to install arch-live-usb from harddisk instead of usb ;but i have occured a problem :

# file arch-live-usb_201105070115.img arch-live-usb_201105070115.img: x86 boot sector; partition 1: ID=0x83, starthead 32, startsector 2048, 591872 sectors, extended partition table (last)\011, code offset 0x0

from ID=0x83 we it's ext3

# mount -t ext3 -o loop arch-live-usb_201105070115.img /mnt/
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

# dmesg | tail
[13986.478722] VFS: Can't find ext3 filesystem on dev loop0.

# losetup -f arch-live-usb_201105070115.img
# losetup -a
/dev/loop0: [0809]:262025 (/home/sense/software/test/arch-live-usb_201105070115.img)
# mount /dev/loop0 /mnt/
mount: you must specify the filesystem type
# mount -t ext3 /dev/loop0 /mnt/
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
# dmesg | tail
[13986.478722] VFS: Can't find ext3 filesystem on dev loop0.

thank you.

business_kid 05-24-2011 02:37 AM

.img files are often compressed with gzip or cpio or both. To gather a distro into one file needs cpio or tar, cpio being preferred as it offers some compression.

run file on it.

TobiSGD 05-24-2011 04:37 AM

The problem is that the .img files are not images of a partition, but of a whole disk. That means they start with a bootloader and a partition table. You have to find out the offset of the partition and mount it with the offset option of mount.
If you do a
Code:

fdisk -l /path/to/image
it will show you the block-size and the start-block of the partition. You can use that to calculate the offset.
For example, I have an image of a bootable stick with a 4GB FAT32 partition. The output of the fdisk command is
Code:

Disk Stick.img: 3984 MB, 3984588800 bytes
249 heads, 6 sectors/track, 5209 cylinders, total 7782400 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: 0x0004bfaa

    Device Boot      Start        End      Blocks  Id  System
Stick.img1  *        128    8015999    4007936    b  W95 FAT32

So I have a block-size of 512 bytes and the start-block is 128. The offset is 512 * 128 = 65536.
So the mount command would be
Code:

mount -o loop,offset=65536 Stick.img /mnt/tmp

linuxboy2008 05-24-2011 05:04 AM

Quote:

Originally Posted by TobiSGD (Post 4365399)
The problem is that the .img files are not images of a partition, but of a whole disk. That means they start with a bootloader and a partition table. You have to find out the offset of the partition and mount it with the offset option of mount.
If you do a
Code:

fdisk -l /path/to/image
it will show you the block-size and the start-block of the partition. You can use that to calculate the offset.
For example, I have an image of a bootable stick with a 4GB FAT32 partition. The output of the fdisk command is
Code:

Disk Stick.img: 3984 MB, 3984588800 bytes
249 heads, 6 sectors/track, 5209 cylinders, total 7782400 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: 0x0004bfaa

    Device Boot      Start        End      Blocks  Id  System
Stick.img1  *        128    8015999    4007936    b  W95 FAT32

So I have a block-size of 512 bytes and the start-block is 128. The offset is 512 * 128 = 65536.
So the mount command would be
Code:

mount -o loop,offset=65536 Stick.img /mnt/tmp


thank you

that is the info on my computer:
# fdisk -l arch-live-usb_201105070115.img
You must set cylinders.
You can do this from the extra functions menu.

Disk arch-live-usb_201105070115.img: 0 MB, 0 bytes
248 heads, 19 sectors/track, 0 cylinders
Units = cylinders of 4712 * 512 = 2412544 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xff978785

Device Boot Start End Blocks Id System
arch-live-usb_201105070115.img1 1 127 295936 83 Linux
Partition 1 has different physical/logical beginnings (non-Linux?):
phys=(0, 32, 33) logical=(0, 107, 16)
Partition 1 has different physical/logical endings:
phys=(36, 247, 19) logical=(126, 10, 18)

# mount -o loop,offset=512 arch-live-usb_201105070115.img /mnt
mount: you must specify the filesystem type
# mount -t ext3 -o loop,offset=512 arch-live-usb_201105070115.img /mnt
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

# dmesg |tail
VFS: Can't find ext3 filesystem on dev loop0.

now i don't know how to do

TobiSGD 05-24-2011 05:53 AM

OK, the the image has a format unknown to me. Sorry, I can't help you with that.

linuxboy2008 05-24-2011 06:05 AM

Quote:

Originally Posted by TobiSGD (Post 4365461)
OK, the the image has a format unknown to me. Sorry, I can't help you with that.

Thank you for the same

tredegar 05-24-2011 08:56 AM

Quote:

VFS: Can't find ext3 filesystem on dev loop0.
You do not know for sure that the partition is formatted as ext3

The partition type of 0x83 just means "linux", and although that can mean ext3, it ain't necessarily so.

Try reading this post by David the H. where he is using the -t auto option to mount, to mount a partition within an image.

linuxboy2008 05-24-2011 09:07 PM

Quote:

Originally Posted by tredegar (Post 4365629)
You do not know for sure that the partition is formatted as ext3

The partition type of 0x83 just means "linux", and although that can mean ext3, it ain't necessarily so.

Try reading this post by David the H. where he is using the -t auto option to mount, to mount a partition within an image.

thank you very much!

it's work good now

# fdisk -lu arch-live-usb_201105070115.img
You must set cylinders.
You can do this from the extra functions menu.

Disk arch-live-usb_201105070115.img: 0 MB, 0 bytes
248 heads, 19 sectors/track, 0 cylinders, total 0 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: 0xff978785

Device Boot Start End Blocks Id System
arch-live-usb_201105070115.img1 2048 593919 295936 83 Linux
Partition 1 has different physical/logical beginnings (non-Linux?):
phys=(0, 32, 33) logical=(0, 107, 16)
Partition 1 has different physical/logical endings:
phys=(36, 247, 19) logical=(126, 10, 18)

# mount -t auto -o loop,offset=$((2048*512)) arch-live-usb_201105070115.img /mnt/

gopyan 11-27-2014 04:10 AM

Many, many thanks. All work perfectly.

onebuck 12-04-2014 09:00 AM

Moderator response
 
@gopyan
Please do not resurrect necro threads without adding constructive information to thread via posts. If you wish to honor the help then just press 'Did you find this post helpful?' Yes to find the post helpful. Or you can give Rep by pressing the scales icon under the members profile.

Yakooza 09-07-2018 05:08 AM

Quote:

Originally Posted by TobiSGD (Post 4365399)
The problem is that the .img files are not images of a partition, but of a whole disk. That means they start with a bootloader and a partition table. You have to find out the offset of the partition and mount it with the offset option of mount.
If you do a
Code:

fdisk -l /path/to/image
it will show you the block-size and the start-block of the partition. You can use that to calculate the offset.
For example, I have an image of a bootable stick with a 4GB FAT32 partition. The output of the fdisk command is
Code:

Disk Stick.img: 3984 MB, 3984588800 bytes
249 heads, 6 sectors/track, 5209 cylinders, total 7782400 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: 0x0004bfaa

    Device Boot      Start        End      Blocks  Id  System
Stick.img1  *        128    8015999    4007936    b  W95 FAT32

So I have a block-size of 512 bytes and the start-block is 128. The offset is 512 * 128 = 65536.
So the mount command would be
Code:

mount -o loop,offset=65536 Stick.img /mnt/tmp

I just wanted to thank you. It just solved my problem.

jefro 09-07-2018 03:07 PM

Yakooza, hello and welcome to LQ.

Glad it still works.
Be sure you watch the age of the threads. A lot can change in 7 years.

Yakooza 09-09-2018 08:02 PM

Quote:

Originally Posted by jefro (Post 5901002)
Yakooza, hello and welcome to LQ.

Glad it still works.
Be sure you watch the age of the threads. A lot can change in 7 years.

Thank you for your welcome.
Yes, I have noticed that but I had to thank him :)

Thanks

hydrurga 09-10-2018 04:06 AM

Quote:

Originally Posted by Yakooza (Post 5901653)
Thank you for your welcome.
Yes, I have noticed that but I had to thank him :)

Thanks

The chances are the poster in question doesn't even post on here any more. So, I'm afraid to say that, like this post, your post added noise, not signal.

allend 09-10-2018 09:58 AM

Quote:

The chances are the poster in question doesn't even post on here any more.
Hehehe - Check the badge. Nothing like a good moderator spank to sharpen you up.


All times are GMT -5. The time now is 11:09 AM.