LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-04-2012, 03:55 PM   #1
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 131

Rep: Reputation: 1
How to mount DOS img file?


Hello,

I need to alter some old DOS image file and to do this
I need to mount it first. But the "mount"fails with the "wrong
fs type" even I'm quite sure I'm using the correct type
(and another, just to test). Here's the attempt:

Code:
<root localhost>.../kvm_files>mount -t vfat -o loop dos_6.22_template.img /media/dos_c
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
<root localhost>.../kvm_files>mount -t msdos -o loop dos_6.22_template.img /media/dos_c
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
<root localhost>.../kvm_files>file dos_6.22_template.img
dos_6.22_template.img: x86 boot sector, Microsoft Windows XP mbr; partition 1: ID=0x6, active, starthead 1, startsector 63, 203553 sectors, code offset 0x33
The last lines of "dmesg" during few last mount attempts:

Code:
[ 7251.326506] FAT-fs (loop0): invalid media value (0x01)
[ 7251.326513] FAT-fs (loop0): Can't find a valid FAT filesystem
[ 7291.979855] EXT4-fs (loop0): VFS: Can't find ext4 filesystem
[ 7291.984521] EXT4-fs (loop0): VFS: Can't find ext4 filesystem
[ 7291.993459] EXT4-fs (loop0): VFS: Can't find ext4 filesystem
[ 7292.005402] ISOFS: Unable to identify CD-ROM format.
[ 7292.016884] FAT-fs (loop0): invalid media value (0x01)
[ 7292.016890] FAT-fs (loop0): Can't find a valid FAT filesystem
[ 7292.039848] hfs: can't find a HFS filesystem on dev loop0.
[ 7292.060316] hfs: unable to find HFS+ superblock
[ 7292.076242] FAT-fs (loop0): invalid media value (0x01)
[ 7292.076245] FAT-fs (loop0): Can't find a valid FAT filesystem
[ 7844.091366] FAT-fs (loop1): invalid media value (0x01)
[ 7844.091371] FAT-fs (loop1): Can't find a valid FAT filesystem
[ 8180.064294] EXT4-fs (loop0): VFS: Can't find ext4 filesystem
[ 8180.070363] EXT4-fs (loop0): VFS: Can't find ext4 filesystem
[ 8180.076035] EXT4-fs (loop0): VFS: Can't find ext4 filesystem
[ 8180.086089] ISOFS: Unable to identify CD-ROM format.
[ 8180.094033] FAT-fs (loop0): invalid media value (0x01)
[ 8180.094036] FAT-fs (loop0): Can't find a valid FAT filesystem
[ 8180.100959] hfs: can't find a HFS filesystem on dev loop0.
[ 8180.109935] hfs: unable to find HFS+ superblock
[ 8180.125880] FAT-fs (loop0): invalid media value (0x01)
[ 8180.125885] FAT-fs (loop0): Can't find a valid FAT filesystem
[ 8315.623977] EXT4-fs (loop0): VFS: Can't find ext4 filesystem
[ 8315.629942] EXT4-fs (loop0): VFS: Can't find ext4 filesystem
[ 8315.634944] EXT4-fs (loop0): VFS: Can't find ext4 filesystem
[ 8315.643041] ISOFS: Unable to identify CD-ROM format.
[ 8315.649982] FAT-fs (loop0): invalid media value (0x01)
[ 8315.649985] FAT-fs (loop0): Can't find a valid FAT filesystem
[ 8315.657861] hfs: can't find a HFS filesystem on dev loop0.
[ 8315.665847] hfs: unable to find HFS+ superblock
[ 8315.681785] FAT-fs (loop0): invalid media value (0x01)
[ 8315.681787] FAT-fs (loop0): Can't find a valid FAT filesystem
[ 8568.337745] FAT-fs (loop0): invalid media value (0x01)
[ 8568.337750] FAT-fs (loop0): Can't find a valid FAT filesystem
[ 8584.874445] FAT-fs (loop0): invalid media value (0x01)
[ 8584.874450] FAT-fs (loop0): Can't find a valid FAT filesystem
What am I missing? Digging the net didn't find anything different
from what I do...

TIA for any ideas,
 
Old 10-04-2012, 04:06 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,566
Blog Entries: 2

Rep: Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035
It seems that you have an image of a harddisk, not a partition. You need to find out at which place in the image the actual partition begins. To do that post the output of
Code:
fdisk -l dos_6.22_template.img
 
Old 10-04-2012, 05:31 PM   #3
jefro
Guru
 
Registered: Mar 2008
Posts: 11,380

Rep: Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395
I might be tempted to boot it in a qemu vm if all else fails.
 
Old 10-04-2012, 05:50 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,566
Blog Entries: 2

Rep: Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035
Quote:
Originally Posted by jefro View Post
I might be tempted to boot it in a qemu vm if all else fails.
Should work also, but once you know the offset (which is quite easy to get) it is no problem to mount the partitions on that image.
 
Old 10-04-2012, 07:01 PM   #5
jefro
Guru
 
Registered: Mar 2008
Posts: 11,380

Rep: Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395Reputation: 1395
True, true.
 
Old 10-05-2012, 01:53 AM   #6
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 131

Original Poster
Rep: Reputation: 1
Hello and thanks for the replies,

here's the running of "fdisk":

Code:
<localhost>.../kvm_files>fdisk -l dos_6.22_template.img                                 
                                                                                              
Disk dos_6.22_template.img: 104 MB, 104857600 bytes                                           
16 heads, 63 sectors/track, 203 cylinders, total 204800 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: 0x00000000                                                                             
                                                                                                          
                Device Boot      Start         End      Blocks   Id  System                                    
dos_6.22_template.img1   *          63      203615      101776+   6  FAT16
I assumed that "63" is the offset I'm looking for, read the "man mount", saw
a reference to "offset":

Code:
THE LOOP DEVICE
       One further possible type is a mount via the loop device. For example, the command

              mount /tmp/disk.img /mnt -t vfat -o loop=/dev/loop

       will set up the loop device /dev/loop3 to correspond to the file /tmp/disk.img, and then mount this device on /mnt.

       If  no  explicit  loop  device is mentioned (but just an option `-o loop' is given), then mount will try to find some
       unused loop device and use that, for example

              mount /tmp/disk.img /mnt -o loop

       The mount command automatically creates a loop device from a regular file if a filesystem type is  not  specified  or
       the filesystem is known for libblkid, for example:

              mount /tmp/disk.img /mnt

              mount -t ext3 /tmp/disk.img /mnt

       This  type  of mount knows about four options, namely loop, offset, sizelimit and encryption, that are really options
       to losetup(8).  (These options can be used in addition to those specific to the filesystem type.)
, attempted to use it in "mount" but got the same error:

Code:
<root localhost>.../kvm_files>mount -t msdos -o loop,offset=63 dos_6.22_template.img /media/dos_c
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
, then I tried to use the offset as "losetup" argument but it didn't help:

Code:
<root localhost>.../kvm_files>losetup -o 63 /dev/loop0 dos_6.22_msfs.img
<root localhost>.../kvm_files>mount -t msdos -o loop /dev/loop0 /media/dos_c
mount: wrong fs type, bad option, bad superblock on /dev/loop1,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail or so
Am I right assuming the "63" is the offset I'm looking for?
How should I use this value?

TIA for any ideas,
 
Old 10-05-2012, 05:43 AM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,566
Blog Entries: 2

Rep: Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035
Not directly. The offset is given in bytes to the mount command, while fdisk shows it in sectors. But it also shows that the sector size is 512 Bytes, so the offset is 512*63= 27136. Try it with that number.
 
Old 10-06-2012, 10:41 PM   #8
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 131

Original Poster
Rep: Reputation: 1
Hi TobiSGD, thanks for the correction.

I tried but got the same error:

Code:
<root localhost>.../kvm_files>mount -t msdos -o loop,offset=27136 dos_6.22_template.img /media/dos_c
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
<root localhost>.../kvm_files>losetup -o 27136 /dev/loop0 dos_6.22_msfs.img
<root localhost>.../kvm_files>mount -t msdos -o loop /dev/loop0 /media/dos_c
mount: wrong fs type, bad option, bad superblock on /dev/loop1,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail or so

The problem with this error message that it lists many possible
causes of the problem. I wonder how can I deduce which is the
one that triggers the error?

TIA for ideas,
 
Old 10-07-2012, 04:20 AM   #9
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,566
Blog Entries: 2

Rep: Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035
Try it without the -t option, so that the mount program tries to determine the correct file system.
 
Old 10-08-2012, 12:13 AM   #10
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 131

Original Poster
Rep: Reputation: 1
Hi TobiSGD,

Tried without "-t" but got the same error:

Code:
<root localhost>.../kvm_files>losetup -o 27136 /dev/loop0 dos_6.22_msfs.img
<root localhost>.../kvm_files>mkdir -p /media/dos_c
<root localhost>.../kvm_files>mount -o loop /dev/loop0 /media/dos_c
mount: wrong fs type, bad option, bad superblock on /dev/loop1,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail or so
Looking at the "dmesg" output I see the "mount" attempted few filesystems:

Code:
[  593.918639] EXT4-fs (loop1): VFS: Can't find ext4 filesystem
[  593.923643] EXT4-fs (loop1): VFS: Can't find ext4 filesystem
[  593.931560] EXT4-fs (loop1): VFS: Can't find ext4 filesystem
[  593.939567] ISOFS: Unable to identify CD-ROM format.
[  593.980909] FAT-fs (loop1): bogus number of reserved sectors
[  593.980915] FAT-fs (loop1): Can't find a valid FAT filesystem
[  593.997846] hfs: can't find a HFS filesystem on dev loop1.
[  594.018025] hfs: unable to find HFS+ superblock
It seems the offset calculation is wrong: the value 27136 is in bytes while,
reading the error message in "dmesg" it looks like the "mount" expects sectors.
I attempted to use the value "63" again and this time (with "-t" again), the "dmesg"
error is different:

Code:
[ 1195.335409] FAT-fs (loop1): invalid media value (0xb4)
[ 1195.335414] FAT-fs (loop1): Can't find a valid FAT filesystem
What can we deduce from the change in the error messages?

TIA for any ideas,
 
Old 10-08-2012, 06:30 AM   #11
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,566
Blog Entries: 2

Rep: Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035
Usually the mount/losetup command expects the offset in bytes:
Quote:
-o, --offset offset
the data start is moved offset bytes into the specified file or device
May be you should follow jefro's advice and attach a copy of the image to a virtual machine to access it.
 
Old 10-13-2012, 04:29 PM   #12
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 131

Original Poster
Rep: Reputation: 1
Solved!

That's what happens when making assumptions about what looks like "can't be wrong":

512*63= 27136

I used the value "27136" without checking the math and missed that it's actually:

21136 = 512 * 53 (probably a typo of "5" instead of "6").

The correct value is:

63 x 512 = 32256

and after issuing the corrected command I've got the file mounted:

Code:
<root localhost>.../kvm_files>mount -t msdos -o loop,offset=32256 dos_6.22_template.img /media/dos_c
<root localhost>.../kvm_files>ls /media/dos_c
total 428
drwxr-xr-x. 3 root root  2048 May 21  2010 archive
-rwxr-xr-x. 1 root root 48301 May 20  2010 aspi320.sys
drwxr-xr-x. 2 root root  2048 May 21  2010 autoexec
-rwxr-xr-x. 1 root root   130 May 23  2010 autoexec.bat
drwxr-xr-x. 2 root root  4096 May 21  2010 bat
-rwxr-xr-x. 1 root root 34262 Sep 26  1996 cd1.sys
-rwxr-xr-x. 1 root root 16504 Nov 21  1996 cd2.sys
-rwxr-xr-x. 1 root root 19984 Aug 13  1996 cd3.sys
-rwxr-xr-x. 1 root root 41302 May 11  1998 cd4.sys
-rwxr-xr-x. 1 root root 54645 May 31  1994 command.com
-rwxr-xr-x. 1 root root   482 May 21  2010 config.sys
drwxr-xr-x. 3 root root  2048 May 20  2010 dfsee
drwxr-xr-x. 2 root root  2048 May 20  2010 dos
-r-xr-xr-x. 1 root root 66294 May 31  1994 drvspace.bin
drwxr-xr-x. 2 root root  2048 May 21  2010 duse
drwxr-xr-x. 2 root root  2048 May 21  2010 floppies
drwxr-xr-x. 6 root root  2048 May 21  2010 games
-r-xr-xr-x. 1 root root 40774 May 31  1994 io.sys
-rwxr-xr-x. 1 root root     7 Jul  6  1997 mouse.@@@
-rwxr-xr-x. 1 root root 25361 May 31  1994 mscdex.exe
-r-xr-xr-x. 1 root root 38138 May 31  1994 msdos.sys
drwxr-xr-x. 2 root root  2048 May 21  2010 pkware
drwxr-xr-x. 2 root root  2048 May 21  2010 pqmagic
-rwxr-xr-x. 1 root root   147 Mar 25  2004 readme.1st
drwxr-xr-x. 2 root root  2048 May 21  2010 temp
drwxr-xr-x. 2 root root  2048 May 21  2010 utility

Thanks for everyone who replied,
 
1 members found this post helpful.
Old 10-13-2012, 04:32 PM   #13
kaza
Member
 
Registered: Apr 2010
Distribution: FC17
Posts: 131

Original Poster
Rep: Reputation: 1
Oooops, can't type correctly myself, :-)

Instead of 21136 should be 27136.

It's the hour... :-)
 
Old 10-13-2012, 04:41 PM   #14
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,566
Blog Entries: 2

Rep: Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035Reputation: 4035
Man, sorry for that. I would have never figured that out.
Thanks for the correction!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mount a .img file chaz_d Linux - General 3 09-26-2012 07:46 PM
Mount image-sdb.img with mount? patrick295767 Linux - Newbie 2 03-28-2012 02:09 PM
[SOLVED] how to mount .img file linuxboy2008 Linux - General 7 05-24-2011 09:07 PM
[SOLVED] Mounting .img file (chromiumos.img); can't mount it?? Help please? linus72 Linux - General 2 11-27-2009 08:11 PM
Mount *.img file - What fs type tobiasw Linux - General 14 10-17-2006 03:43 PM


All times are GMT -5. The time now is 02:43 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration