Can a Loopback Filesystem be Partitioned?

Tags
filesystem, knoppix

 
Thread Tools Search this Thread
# 1  
Old 01-11-2006
Can a Loopback Filesystem be Partitioned?

I have a disk image file created for use with the Linux version of the QEMU emulator. It's partitioned. I opened it with fdisk and the partitions show up with some extra messages about physical/logical endings:


Code:
Disk knoppix.img: 0 MB, 0 bytes
16 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

      Device Boot      Start         End      Blocks   Id  System
knoppix.img1   *           1        8074     4069264+  83  Linux
Partition 1 has different physical/logical endings:
     phys=(1023, 15, 63) logical=(8073, 15, 63)
knoppix.img2            8075        8322      124992   82  Linux swap / Solaris
Partition 2 has different physical/logical beginnings (non-Linux?):
     phys=(1023, 15, 63) logical=(8074, 0, 1)
Partition 2 has different physical/logical endings:
     phys=(1023, 15, 63) logical=(8321, 15, 63)

I noticed that the filename of the image file becomes "knoppix.img1" for the first partition and "knoppix.img2" for the second partition. So... is there a way to mount this outside of QEMU? I tried appending the 1 and 2 to the filename but I just get a "no such directory or file" message. Any ideas? Or am I just sunk?
# 2  
Old 01-11-2006
I'm not 100% sure what you are asking. Do you want to just mount the image?

Code:
mount -o loop -t iso9660 filename.iso /mnt/iso

# 3  
Old 01-18-2006
Partitioned Image

I actually want to mount a partition within the image. The image file that QEMU created is paritioned. 'fdisk' can recognize that it is partitioned, but it seems that mount can't if it's not a block device. I know the image file contains partitions because when I run QEMU it gives me /dev/hda1 /dev/hda2 and /dev/hda3 all from that one loopback file.

EDIT 08232007:

SOLVED!

It took almost two years to find an answer to this, and I'm certain the answer was around when I asked the question. But I'm posting this here to hopefully help anyone else in the future who has the same needs. The key to doing what I wanted to do, is to use the 'offset' option for mounting the loopback file. First use 'fdisk' to determine where your partitions within the loopback file start and what their internal names are. You also need to find out what the offset if going to be. To do that, run the following against the original drive:

Code:
localhost ~ # fdisk -l /dev/sdd

Disk /dev/sdd: 2013 MB, 2013265920 bytes
16 heads, 15 sectors/track, 16384 cylinders
Units = cylinders of 240 * 512 = 122880 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               2       16384     1965952+   6  FAT16

Note the number of cylinders your original disk returns and then use that value in the following command:

Code:
localhost ~ # fdisk -l -u -C 16384 microsd.img

Disk microsd.img: 0 MB, 0 bytes
16 heads, 15 sectors/track, 16384 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x00000000

      Device Boot      Start         End      Blocks   Id  System
microsd.img1             255     3932159     1965952+   6  FAT16

Pay attention to the "start" value for each partition in the image. Multiply that "start" value by 512 to calculate the value to pass with the 'offset' option when you mount the image:

Code:
localhost ~ # echo $((255*512))
130560

Here's an example of what it would look like to mount my microsd.img image:

Code:
mount  microsd.img1 /mnt/partition1 -o loop,offset=130560

The full explanation cam from here:

Loopback mountin' a specific partition inside a disk image | Tux in a row

Extended example is available here:
Mounting disks with Linux's loopback device

Last edited by deckard; 04-17-2008 at 06:27 PM.. Reason: Found a solution almost two years later. :)
# 4  
Old 08-23-2007
[SOLVED]: Procedure to mount a partitioned loopback filesystem

See the EDIT 08232007 section in my original comment for details.

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
NAT Loopback and iptables 6765656755 Red Hat 0 04-07-2013 12:18 PM
Loopback thriveforana UNIX Desktop Questions & Answers 6 02-27-2013 09:29 PM
How to Loopback? thriveforana UNIX for Dummies Questions & Answers 0 02-26-2013 06:24 PM
How to find un-partitioned space in a RHEL server? RHCE Red Hat 1 01-24-2013 02:11 AM
Loopback interface doen't appear mabdelmageid Linux 3 07-13-2012 05:36 PM
loopback filesystem disappears after reboot jabberwocky UNIX for Advanced & Expert Users 3 10-26-2011 09:33 AM
Linux partitioned disk mounted on OSOL without formatting michnmi Solaris 5 12-26-2010 05:51 PM
loading the data to the partitioned table using procedure easterraj Shell Programming and Scripting 1 11-03-2009 07:41 AM
Adding Loopback Interface reiklen Solaris 2 03-02-2009 02:24 PM
loopback in 4.1.4.0 AIX server terron79 AIX 0 03-12-2007 06:10 PM
Loopback files on a FAT based Filesystem? deckard Filesystems, Disks and Memory 1 01-25-2007 06:24 PM
Help With Reading Partitioned Tapes dhaverstick HP-UX 2 05-23-2006 11:56 AM
Can I Use Loopback Devices with LVM? deckard Filesystems, Disks and Memory 3 03-09-2005 07:27 AM
Using loopback devices in RAID? deckard Filesystems, Disks and Memory 0 04-16-2003 10:54 PM
Loopback Interface...Vanished??? silvaman UNIX for Advanced & Expert Users 1 09-21-2002 05:38 PM