public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* accessing loopback filesystem+partitions on a file
@ 2005-06-28 23:33 Luke Kenneth Casson Leighton
  2005-06-29  0:30 ` Jason Lunz
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Luke Kenneth Casson Leighton @ 2005-06-28 23:33 UTC (permalink / raw)
  To: linux-kernel

[if you are happy to reply at all, please reply cc'd thank you.]

hi,

i'm really sorry to be bothering people on this list but i genuinely
don't what phrases to google for what i am looking for without getting
swamped by useless pages, which you will understand why when you see
the question, below.

background:

	i'm sort-of helping test a xen install project where a
	block device is presented as the DRIVE - not, i repeat
	not, the partitions on the drive which is the quotes
	normal quotes way of doing xen installes

	(yes there are good reasons for doing this).

	the thing is that the install is failing, and we'd duh
	like to analyse what's going on (access the log files -
	no, sshd hasn't been installed yet) after terminating
	the xen session [because afaik in xen guest sessions
	there's no way i know of to access virtual consoles 2-6]

the question is, therefore:

	* how the hell do you loopback mount (or lvm mount
	  or _anything_! something!)  partitions that have
	  been created in a loopback'd file!!!!

	  [aside from booting up a second pre-installed xen
	  guest domain and making the filesystem-in-a-file
	  available as /dev/hdb of course.]

answers of the form "work out where the partitions are, then use
hexedit to remove the first few blocks" will win no prizes here.

l.

-- 
--
<a href="http://lkcl.net">http://lkcl.net</a>
--

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accessing loopback filesystem+partitions on a file
  2005-06-28 23:33 accessing loopback filesystem+partitions on a file Luke Kenneth Casson Leighton
@ 2005-06-29  0:30 ` Jason Lunz
  2005-06-29  0:35 ` Grzegorz Kulewski
  2005-06-29 10:52 ` P
  2 siblings, 0 replies; 11+ messages in thread
From: Jason Lunz @ 2005-06-29  0:30 UTC (permalink / raw)
  To: linux-kernel

lkcl@lkcl.net said:
> 	* how the hell do you loopback mount (or lvm mount
> 	  or _anything_! something!)  partitions that have
> 	  been created in a loopback'd file!!!!

use the offset option when mounting.

Jason


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accessing loopback filesystem+partitions on a file
  2005-06-28 23:33 accessing loopback filesystem+partitions on a file Luke Kenneth Casson Leighton
  2005-06-29  0:30 ` Jason Lunz
@ 2005-06-29  0:35 ` Grzegorz Kulewski
  2005-06-29  1:37   ` Luke Kenneth Casson Leighton
  2005-06-29  1:50   ` Luke Kenneth Casson Leighton
  2005-06-29 10:52 ` P
  2 siblings, 2 replies; 11+ messages in thread
From: Grzegorz Kulewski @ 2005-06-29  0:35 UTC (permalink / raw)
  To: Luke Kenneth Casson Leighton; +Cc: linux-kernel

On Wed, 29 Jun 2005, Luke Kenneth Casson Leighton wrote:

> [if you are happy to reply at all, please reply cc'd thank you.]
>
> hi,
>
> i'm really sorry to be bothering people on this list but i genuinely
> don't what phrases to google for what i am looking for without getting
> swamped by useless pages, which you will understand why when you see
> the question, below.
>
> the question is, therefore:
>
> 	* how the hell do you loopback mount (or lvm mount
> 	  or _anything_! something!)  partitions that have
> 	  been created in a loopback'd file!!!!
>
> 	  [aside from booting up a second pre-installed xen
> 	  guest domain and making the filesystem-in-a-file
> 	  available as /dev/hdb of course.]
>
> answers of the form "work out where the partitions are, then use
> hexedit to remove the first few blocks" will win no prizes here.

The bad news: it was impossible (or at least very hard to do).

The good news: it is possible now. The anwser is:
- figure where the partitions are (possibly using some simple script),
- use device-mapper to create block devices covering partitions,
- mount them.

I do not know if this anwser will win your price but it is IMHO far better 
than hexedit... :-) And probably this is the only anwser.

(IIRC if you have one partition you can skip partition table with offset 
option to losetup. But this will only work in this special case...)


Grzegorz Kulewski


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accessing loopback filesystem+partitions on a file
  2005-06-29  0:35 ` Grzegorz Kulewski
@ 2005-06-29  1:37   ` Luke Kenneth Casson Leighton
  2005-06-29  1:48     ` Peter Chubb
  2005-06-29  1:50   ` Luke Kenneth Casson Leighton
  1 sibling, 1 reply; 11+ messages in thread
From: Luke Kenneth Casson Leighton @ 2005-06-29  1:37 UTC (permalink / raw)
  To: Grzegorz Kulewski; +Cc: linux-kernel

oh, bugger :)

xen guest OSes manage it fine - the xen layer provides a means to
present any block device as a "disk".

that loopback filesystems cannot be presented as block devices
by the linux kernel (with no involvement of xen) seems to be
a curious omission.

... loopbackblock.ko, anyone?

btw the [as yet formally-unannounced] project is at
http://hands.com/d-i.  try the xen0 install and then follow
the instructions for creating a guest domain [by booting debian
installer in a guest domain, as opposed to running debootstrap,
the "normal" xen recommended method].

fortunately, phil has fixed the xen-guest-install, such that it
completes successfully.

that _still_ leaves a hard-disk-with-its-partitions in an actual LVM
partition which is totally inaccessible.

okay - i _say_ inaccessible: there is always the possibility of finding
a spare hard drive, and then doing "dd if=/dev/vg/xen0hda of=/dev/hdd".

this being 2005 last time i checked, it does seem to me to
be a rather large waste of a) an entire hard drive b) time
spent copying.

*sigh*.

sadly, answers on back of envelope ideally need to involve a
tool or procedure of some sort that can be run by dummies such
as myself on a regular basis without fear of major-cock-up,
rather than something [ending oh say in .pl] that stands a good
chance of being exorcised [or exercised] as voodoo witchcraft.

unmitigated steaming "perl" advocates need not respond.  please.

l.

On Wed, Jun 29, 2005 at 02:35:25AM +0200, Grzegorz Kulewski wrote:

> On Wed, 29 Jun 2005, Luke Kenneth Casson Leighton wrote:
> 
> >[if you are happy to reply at all, please reply cc'd thank you.]
> >
> >hi,
> >
> >i'm really sorry to be bothering people on this list but i genuinely
> >don't what phrases to google for what i am looking for without getting
> >swamped by useless pages, which you will understand why when you see
> >the question, below.
> >
> >the question is, therefore:
> >
> >	* how the hell do you loopback mount (or lvm mount
> >	  or _anything_! something!)  partitions that have
> >	  been created in a loopback'd file!!!!
> >
> >	  [aside from booting up a second pre-installed xen
> >	  guest domain and making the filesystem-in-a-file
> >	  available as /dev/hdb of course.]
> >
> >answers of the form "work out where the partitions are, then use
> >hexedit to remove the first few blocks" will win no prizes here.
> 
> The bad news: it was impossible (or at least very hard to do).
> 
> The good news: it is possible now. The anwser is:
> - figure where the partitions are (possibly using some simple script),
> - use device-mapper to create block devices covering partitions,
> - mount them.
> 
> I do not know if this anwser will win your price but it is IMHO far better 
> than hexedit... :-) And probably this is the only anwser.
> 
> (IIRC if you have one partition you can skip partition table with offset 
> option to losetup. But this will only work in this special case...)
> 
> 
> Grzegorz Kulewski
> 

-- 
--
<a href="http://lkcl.net">http://lkcl.net</a>
--

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accessing loopback filesystem+partitions on a file
  2005-06-29  1:37   ` Luke Kenneth Casson Leighton
@ 2005-06-29  1:48     ` Peter Chubb
  2005-06-29 10:00       ` Luke Kenneth Casson Leighton
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Chubb @ 2005-06-29  1:48 UTC (permalink / raw)
  To: Luke Kenneth Casson Leighton; +Cc: Grzegorz Kulewski, linux-kernel

>>>>> "Luke" == Luke Kenneth Casson Leighton <lkcl@lkcl.net> writes:


Luke> xen guest OSes manage it fine - the xen layer provides a means
Luke> to present any block device as a "disk".

You can do this witht he loop device, but you need to get the
partition info out first.

Use parted or fdisk to get the partition info.
Then use losetup with the appropriate offset.

Luke> that loopback filesystems cannot be presented as block devices
Luke> by the linux kernel (with no involvement of xen) seems to be a
Luke> curious omission.

But they can!  But a loopback device can't be partitioned.  So do it
one partition at a time.

You'll probably only have a few real filesystems on the disk image
anyway.



-- 
Dr Peter Chubb  http://www.gelato.unsw.edu.au  peterc AT gelato.unsw.edu.au
The technical we do immediately,  the political takes *forever*

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accessing loopback filesystem+partitions on a file
  2005-06-29  0:35 ` Grzegorz Kulewski
  2005-06-29  1:37   ` Luke Kenneth Casson Leighton
@ 2005-06-29  1:50   ` Luke Kenneth Casson Leighton
  2005-06-29 13:27     ` Jari Ruusu
  1 sibling, 1 reply; 11+ messages in thread
From: Luke Kenneth Casson Leighton @ 2005-06-29  1:50 UTC (permalink / raw)
  To: Grzegorz Kulewski; +Cc: linux-kernel

okay - i should be clearer.

the thing that is missing, that only xen provides, is the presentation
of another block device as a hard drive.

e.g. /dev/volumegroup/volumename --> /dev/loopblocka
or   /dev/loop0 -> /dev/loopblocka

such that it is possible to then subsequently do this:

fdisk /dev/loopblocka and
mkfs.ext2 /dev/loopblocka1
mount /dev/loopblocka1 -t ext2 /mnt/somewhere

you get the gist.

basically, the thing that is missing (or i can't find it)
from linux is a driver with the ability to present [any] block
devices with their major+minor numbers as a [fsck-]recogniseable
block device with its own major number, with the implicit
ability to create minor numbers within it.

lvm is in its own way a sort of mad-cap over-extended version
of the above, if you think about it carefully and can understand
the sentence.

l.


On Wed, Jun 29, 2005 at 02:35:25AM +0200, Grzegorz Kulewski wrote:
> On Wed, 29 Jun 2005, Luke Kenneth Casson Leighton wrote:
> 
> >[if you are happy to reply at all, please reply cc'd thank you.]
> >
> >hi,
> >
> >i'm really sorry to be bothering people on this list but i genuinely
> >don't what phrases to google for what i am looking for without getting
> >swamped by useless pages, which you will understand why when you see
> >the question, below.
> >
> >the question is, therefore:
> >
> >	* how the hell do you loopback mount (or lvm mount
> >	  or _anything_! something!)  partitions that have
> >	  been created in a loopback'd file!!!!
> >
> >	  [aside from booting up a second pre-installed xen
> >	  guest domain and making the filesystem-in-a-file
> >	  available as /dev/hdb of course.]
> >
> >answers of the form "work out where the partitions are, then use
> >hexedit to remove the first few blocks" will win no prizes here.
> 
> The bad news: it was impossible (or at least very hard to do).
> 
> The good news: it is possible now. The anwser is:
> - figure where the partitions are (possibly using some simple script),
> - use device-mapper to create block devices covering partitions,
> - mount them.
> 
> I do not know if this anwser will win your price but it is IMHO far better 
> than hexedit... :-) And probably this is the only anwser.
> 
> (IIRC if you have one partition you can skip partition table with offset 
> option to losetup. But this will only work in this special case...)
> 
> 
> Grzegorz Kulewski
> 

-- 
--
<a href="http://lkcl.net">http://lkcl.net</a>
--

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: accessing loopback filesystem+partitions on a file
@ 2005-06-29  7:12 Ian Pratt
  0 siblings, 0 replies; 11+ messages in thread
From: Ian Pratt @ 2005-06-29  7:12 UTC (permalink / raw)
  To: Luke Kenneth Casson Leighton, Grzegorz Kulewski; +Cc: linux-kernel, ian.pratt


> basically, the thing that is missing (or i can't find it) 
> from linux is a driver with the ability to present [any] 
> block devices with their major+minor numbers as a 
> [fsck-]recogniseable block device with its own major number, 
> with the implicit ability to create minor numbers within it.

The easiest thing to use is the 'lomount' utility that comes with qemu.

http://www.dad-answers.com/qemu/utilities/QEMU-HD-Mounter/lomount/lomoun
t.c

There's also kpartx which is part of device mapper, but its rather
trickier to build.

I think we should pull lomount into our tree until kpartx becomes
ubiquitous.

Ian

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accessing loopback filesystem+partitions on a file
  2005-06-29  1:48     ` Peter Chubb
@ 2005-06-29 10:00       ` Luke Kenneth Casson Leighton
  0 siblings, 0 replies; 11+ messages in thread
From: Luke Kenneth Casson Leighton @ 2005-06-29 10:00 UTC (permalink / raw)
  To: Peter Chubb; +Cc: Grzegorz Kulewski, linux-kernel, xen-devel

On Wed, Jun 29, 2005 at 11:48:40AM +1000, Peter Chubb wrote:

> Luke> that loopback filesystems cannot be presented as block devices
> Luke> by the linux kernel (with no involvement of xen) seems to be a
> Luke> curious omission.
> 
> But they can!  But a loopback device can't be partitioned.  So do it
> one partition at a time.

 ian and mark kindly responded pointing out some programs which
 make that possible.

 i liked the LVM one best.

> You'll probably only have a few real filesystems on the disk image
> anyway.
 
 hi peter, thank you for responding.

 see http://hands.com/d-i, searching for "xen0".

 the key is to be able to test-run debian installations in
 a xen guest domain (with absolute minimal changes to the
 packages or the debian boot installs).

 and of course a debian install expects to see a hard drive, which it
 expects to be able to partition - so it is given one.

 l.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accessing loopback filesystem+partitions on a file
  2005-06-28 23:33 accessing loopback filesystem+partitions on a file Luke Kenneth Casson Leighton
  2005-06-29  0:30 ` Jason Lunz
  2005-06-29  0:35 ` Grzegorz Kulewski
@ 2005-06-29 10:52 ` P
  2 siblings, 0 replies; 11+ messages in thread
From: P @ 2005-06-29 10:52 UTC (permalink / raw)
  To: Luke Kenneth Casson Leighton; +Cc: linux-kernel

Luke Kenneth Casson Leighton wrote:
> 
> 	* how the hell do you loopback mount (or lvm mount
> 	  or _anything_! something!)  partitions that have
> 	  been created in a loopback'd file!!!!

Have a look at http://www.pixelbeat.org/scripts/lomount.sh

Pádraig.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accessing loopback filesystem+partitions on a file
  2005-06-29  1:50   ` Luke Kenneth Casson Leighton
@ 2005-06-29 13:27     ` Jari Ruusu
  2005-06-30  0:38       ` Luke Kenneth Casson Leighton
  0 siblings, 1 reply; 11+ messages in thread
From: Jari Ruusu @ 2005-06-29 13:27 UTC (permalink / raw)
  To: Luke Kenneth Casson Leighton; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

Luke Kenneth Casson Leighton wrote:
> such that it is possible to then subsequently do this:
> 
> fdisk /dev/loopblocka and
> mkfs.ext2 /dev/loopblocka1
> mount /dev/loopblocka1 -t ext2 /mnt/somewhere

Using attached image-mount script that is possible. Like this:

  ln -s image-mount image-losetup
  fdisk filename
       (remember to set correct cyl/head/sect before creating partitions)
  ./image-losetup /dev/loop7 filename 2
  mkfs.ext2 /dev/loop7
  mount /dev/loop7 -t ext2 /mnt/somewhere
  umount /mnt/somewhere
  losetup -d /dev/loop7

or

  ./image-mount filename 2 /mnt/somewhere
  umount /mnt/somewhere

Good news is that image-mount and image-losetup scripts get both size and
offset of the partition right, so mkfs creates correct size file system. Bad
news is that it only works with losetup and mount programs from loop-AES
package. Google for "loop-AES" if you can't find it.

-- 
Jari Ruusu  1024R/3A220F51 5B 4B F9 BB D3 3F 52 E9  DB 1D EB E3 24 0E A9 DD

[-- Attachment #2: image-mount.bz2 --]
[-- Type: application/octet-stream, Size: 572 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accessing loopback filesystem+partitions on a file
  2005-06-29 13:27     ` Jari Ruusu
@ 2005-06-30  0:38       ` Luke Kenneth Casson Leighton
  0 siblings, 0 replies; 11+ messages in thread
From: Luke Kenneth Casson Leighton @ 2005-06-30  0:38 UTC (permalink / raw)
  To: Jari Ruusu; +Cc: linux-kernel

jari, thank you.

there are _loads_ of people with mad and bad solutions - why
are none of them easily accessible via oh say debian packages???

l.


On Wed, Jun 29, 2005 at 04:27:49PM +0300, Jari Ruusu wrote:
> Luke Kenneth Casson Leighton wrote:
> > such that it is possible to then subsequently do this:
> > 
> > fdisk /dev/loopblocka and
> > mkfs.ext2 /dev/loopblocka1
> > mount /dev/loopblocka1 -t ext2 /mnt/somewhere
> 
> Using attached image-mount script that is possible. Like this:
> 
>   ln -s image-mount image-losetup
>   fdisk filename
>        (remember to set correct cyl/head/sect before creating partitions)
>   ./image-losetup /dev/loop7 filename 2
>   mkfs.ext2 /dev/loop7
>   mount /dev/loop7 -t ext2 /mnt/somewhere
>   umount /mnt/somewhere
>   losetup -d /dev/loop7
> 
> or
> 
>   ./image-mount filename 2 /mnt/somewhere
>   umount /mnt/somewhere
> 
> Good news is that image-mount and image-losetup scripts get both size and
> offset of the partition right, so mkfs creates correct size file system. Bad
> news is that it only works with losetup and mount programs from loop-AES
> package. Google for "loop-AES" if you can't find it.
> 
> -- 
> Jari Ruusu  1024R/3A220F51 5B 4B F9 BB D3 3F 52 E9  DB 1D EB E3 24 0E A9 DD


-- 
--
<a href="http://lkcl.net">http://lkcl.net</a>
--

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-06-30  0:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-28 23:33 accessing loopback filesystem+partitions on a file Luke Kenneth Casson Leighton
2005-06-29  0:30 ` Jason Lunz
2005-06-29  0:35 ` Grzegorz Kulewski
2005-06-29  1:37   ` Luke Kenneth Casson Leighton
2005-06-29  1:48     ` Peter Chubb
2005-06-29 10:00       ` Luke Kenneth Casson Leighton
2005-06-29  1:50   ` Luke Kenneth Casson Leighton
2005-06-29 13:27     ` Jari Ruusu
2005-06-30  0:38       ` Luke Kenneth Casson Leighton
2005-06-29 10:52 ` P
  -- strict thread matches above, loose matches on Subject: below --
2005-06-29  7:12 Ian Pratt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox