I-Appliance BBS
The Official Source for Internet Appliance Upgrades and Mods

Click Here!
BBS Main List | Sign In | Sign Up | Search | Help | Linux-Hacker.netReply to Thread | Printer |

Home / Other I-Appliances / MSN Companion
loopback mounting success!
Able to loopback mount directly from an image file

New Messageloopback mounting success! (modified 0 times) Rasmus
Profile | Email
I have been hacking away at trying to figure out how to loopback mount a Linux image file directly. I finally figured it out. Here are the steps.

1. Grab an image. I will use my linux-2.img file here.

2. od -x linux-2.img | grep "d45 28cd 0000 0001"
Which gives you something like:

0001000 3d45 28cd 0000 0001 0000 0000 0000 0000
14140000 3d45 28cd 0000 0001 0000 0000 0000 0000
17540000 3d45 28cd 0000 0001 0000 0000 0000 0000
23740000 3d45 28cd 0000 0001 0000 0000 0000 0000
25440000 3d45 28cd 0000 0001 0000 0000 0000 0000
25540000 3d45 28cd 0000 0001 0000 0000 0000 0000

Those are the offsets in octal inside the image.

3. You can see the matching filesystems using fdisk:

fdisk linux-2.img

gives you:

Device Boot Start End Blocks Id System
linux-2.img1 33 6208 3088 83 Linux
linux-2.img2 6209 31360 12576 5 Extended
linux-2.img5 6241 8000 880 83 Linux
linux-2.img6 8033 10176 1072 83 Linux
linux-2.img7 10209 11072 432 83 Linux
linux-2.img8 11105 30720 9808 83 Linux

4. Therefore, to create a loopback device for the first partition, do:

losetup -o 512 /dev/loop1 linux-2.img

(octal 1000 = decimal 512, the second partition would be decimal 3194880)

5. Then mount it somewhere:

mount /dev/loop1 /mnt

There you go. This of course assumes that you have CONFIG_BLK_DEV_LOOP and CONFIG_CRAMFS in your kernel. This is pretty cool because you can now mount your image without killing your CF card and poke around in it as much as you want. Should also be able to point vmware at these. That's my next bit of fiddling.

12-20-2001 20:57:16

New MessageRE:loopback mounting success! (modified 0 times) Rasmus
Profile | Email
And here are a couple of shell scripts that will mount/unmount your jailbait image:

::jbmount::
#!/bin/bash
losetup -o 512 /dev/loop1 $1
losetup -o 3194880 /dev/loop2 $1
losetup -o 4112384 /dev/loop3 $1
losetup -o 5226496 /dev/loop4 $1
losetup -o 5652480 /dev/loop5 $1
mount /dev/loop1 $2
mount /dev/loop2 $2/bin
mount /dev/loop3 $2/lib
mount /dev/loop4 $2/sbin
mount /dev/loop5 $2/usr

::jbumount::
#!/bin/bash
umount $1/usr
umount $1/sbin
umount $1/lib
umount $1/bin
umount $1
losetup -d /dev/loop1
losetup -d /dev/loop2
losetup -d /dev/loop3
losetup -d /dev/loop4
losetup -d /dev/loop5

Usage:
jbmount linux-2.img /mnt
jbumount /mnt

12-21-2001 01:25:33

New MessageRE:loopback mounting success! (modified 0 times) foresto
Profile
Rasmus,

I'm using your modified linux-2.img, and your jbmount script, to examine the contents of the image file. (I haven't looked at the original jailbait, nor have I installed any image on my IA-1, since I'm still awaiting shipment of my compactflash card.)

Why do some of the symlinks in this image point to nothing at all? I'm not talking about a symlink that points to a nonexistent file, but one that doesn't seem to point to anything. For example, try this:
ls -l /home /var /usr/sbin/cron
The output shows those symlinks pointing at nothing, and running "file" on each of them reports "unreadable symlink".

What's going on? Do those links behave that way when the image is installed on an IA-1? cpio refuses to read them.

(My host OS is Red Hat 7.2 / kernel 2.4.9)

12-21-2001 21:56:28

Reply to Thread | Printer |
All times are PSTPowered by UltraBoard v1.62



Copyright © 2000, Netmake Inc. All Rights Reserved.
See Terms and Conditions for more information.




i-opener opener laptop notebook computer help drivers dll free windows dos repair fix linux mac macintosh 2000 95 98 nt pc configure hardware software sound video netscape explorer network networking lan wan software cmos fat bios printer card mouse modem ide scsi cd rom controllers scanner tape hard drive cgi scripts source code mp3