LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-29-2018, 11:17 PM   #16
Presto
LQ Newbie
 
Registered: Oct 2018
Posts: 1

Rep: Reputation: Disabled

Quote:
Originally Posted by TobiSGD View Post
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


Many years ago I had made an image file for backup purpose from my entirely 2.0 GByte pendrive using the 'dd' bash command. The pendrive was bootable, It had a bootable live-Devian version on it. Yesterday I was able to mount the image file by simply using the "mount" command without any offset at all and it worked pretty well. The other option that I had to access the image file content was to use again the 'dd' command to restore the image back to the original pendrive, but since the original pendrive has new content now, this option was discarded and I mounted the image file using:

user~$ sudo mount -o loop /path/traveldata2gb.img /mnt/tmp [enter]

My conclusion then is that apparently the "offset" statement (computed by using fdisk information on the image file) is not always mandatory.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Mounting .img file (chromiumos.img); can't mount it?? Help please? linus72 Linux - General 2 11-27-2009 08:11 PM
How to mount/extract a .img ? linus72 Linux - General 11 08-06-2009 11:49 AM
How to mount .IMG CD? PhillipHuang Linux - General 2 08-10-2007 12:21 PM
Mount *.img file - What fs type tobiasw Linux - General 14 10-17-2006 03:43 PM
Mount initrd.img? sti2envy Linux - General 3 02-12-2006 08:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration