<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>lvm on loopback mount problems</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2 FACE="Arial">I've seen a few things about using lvm on a loopback filesystem, but nothing concrete, so I tried it myself.  Most everything works okay until I get to acutally mounting the filesystem.  Here are the steps I did:</FONT></P>

<P><FONT SIZE=2 FACE="Courier New">[root@klmontg tmp]# dd if=/dev/zero of=fake_disk.img bs=1M count=500</FONT>
<BR><FONT SIZE=2 FACE="Courier New">500+0 records in</FONT>
<BR><FONT SIZE=2 FACE="Courier New">500+0 records out</FONT>
<BR><FONT SIZE=2 FACE="Courier New">[root@klmontg tmp]# losetup /dev/loop0 fake_disk.img</FONT>
<BR><FONT SIZE=2 FACE="Courier New">[root@klmontg tmp]# pvcreate /dev/loop0</FONT>
<BR><FONT SIZE=2 FACE="Courier New">pvcreate -- physical volume "/dev/loop0" successfully created</FONT>
</P>

<P><FONT SIZE=2 FACE="Courier New">[root@klmontg tmp]# vgcreate /dev/vgtest /dev/loop0</FONT>
<BR><FONT SIZE=2 FACE="Courier New">vgcreate -- INFO: using default physical extent size 4 MB</FONT>
<BR><FONT SIZE=2 FACE="Courier New">vgcreate -- INFO: maximum logical volume size is 255.99 Gigabyte</FONT>
<BR><FONT SIZE=2 FACE="Courier New">vgcreate -- doing automatic backup of volume group "vgtest"</FONT>
<BR><FONT SIZE=2 FACE="Courier New">vgcreate -- volume group "vgtest" successfully created and activated</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">[root@klmontg tmp]# lvcreate --name lv_one --size 200M /dev/vgtest</FONT>
<BR><FONT SIZE=2 FACE="Courier New">lvcreate -- doing automatic backup of "vgtest"</FONT>
<BR><FONT SIZE=2 FACE="Courier New">lvcreate -- logical volume "/dev/vgtest/lv_one" successfully created</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">[root@klmontg tmp]# mke2fs /dev/vgtest/lv_one</FONT>
<BR><FONT SIZE=2 FACE="Courier New">mke2fs 1.32 (09-Nov-2002)</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Filesystem label=</FONT>
<BR><FONT SIZE=2 FACE="Courier New">OS type: Linux</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Block size=1024 (log=0)</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Fragment size=1024 (log=0)</FONT>
<BR><FONT SIZE=2 FACE="Courier New">51200 inodes, 204800 blocks</FONT>
<BR><FONT SIZE=2 FACE="Courier New">10240 blocks (5.00%) reserved for the super user</FONT>
<BR><FONT SIZE=2 FACE="Courier New">First data block=1</FONT>
<BR><FONT SIZE=2 FACE="Courier New">25 block groups</FONT>
<BR><FONT SIZE=2 FACE="Courier New">8192 blocks per group, 8192 fragments per group</FONT>
<BR><FONT SIZE=2 FACE="Courier New">2048 inodes per group</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Superblock backups stored on blocks:</FONT>
<BR><FONT SIZE=2 FACE="Courier New">        8193, 24577, 40961, 57345, 73729</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">Writing inode tables: done</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Writing superblocks and filesystem accounting information: done</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">This filesystem will be automatically checked every 26 mounts or</FONT>
<BR><FONT SIZE=2 FACE="Courier New">180 days, whichever comes first.  Use tune2fs -c or -i to override.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">[root@klmontg tmp]# e2fsck /dev/vgtest/lv_one</FONT>
<BR><FONT SIZE=2 FACE="Courier New">e2fsck 1.32 (09-Nov-2002)</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Couldn't find ext2 superblock, trying backup blocks...</FONT>
<BR><FONT SIZE=2 FACE="Courier New">e2fsck: Bad magic number in super-block while trying to open /dev/vgtest/lv_one</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">The superblock could not be read or does not describe a correct ext2</FONT>
<BR><FONT SIZE=2 FACE="Courier New">filesystem.  If the device is valid and it really contains an ext2</FONT>
<BR><FONT SIZE=2 FACE="Courier New">filesystem (and not swap or ufs or something else), then the superblock</FONT>
<BR><FONT SIZE=2 FACE="Courier New">is corrupt, and you might try running e2fsck with an alternate superblock:</FONT>
<BR><FONT SIZE=2 FACE="Courier New">    e2fsck -b 8193 <device></FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">[root@klmontg tmp]# e2fsck -b 8193 /dev/vgtest/lv_one</FONT>
<BR><FONT SIZE=2 FACE="Courier New">e2fsck 1.32 (09-Nov-2002)</FONT>
<BR><FONT SIZE=2 FACE="Courier New">e2fsck: Bad magic number in super-block while trying to open /dev/vgtest/lv_one</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">The superblock could not be read or does not describe a correct ext2</FONT>
<BR><FONT SIZE=2 FACE="Courier New">filesystem.  If the device is valid and it really contains an ext2</FONT>
<BR><FONT SIZE=2 FACE="Courier New">filesystem (and not swap or ufs or something else), then the superblock</FONT>
<BR><FONT SIZE=2 FACE="Courier New">is corrupt, and you might try running e2fsck with an alternate superblock:</FONT>
<BR><FONT SIZE=2 FACE="Courier New">    e2fsck -b 8193 <device></FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">[root@klmontg tmp]# mount /dev/vgtest/lv_one /mnt</FONT>
<BR><FONT SIZE=2 FACE="Courier New">mount: you must specify the filesystem type</FONT>
<BR><FONT SIZE=2 FACE="Courier New">[root@klmontg tmp]# mount -t ext2 /dev/vgtest/lv_one /mnt</FONT>
<BR><FONT SIZE=2 FACE="Courier New">mount: wrong fs type, bad option, bad superblock on /dev/vgtest/lv_one,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">       or too many mounted file systems</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">As you can see, one the filesystem was made, nothing else works. I can't fsck the filesystem on the new logical volume, or mount it.  This is obviously a problem since, well, it's useless unless I can mount it.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">I'm using RedHat 9 with the  2.4.20-20.9 kernel.  I've also tried this on RedHat 8 on another box.  I got the latest version of util-linux which is 2.11z and compiled that (in case it was a possible bug in mount 2.11y which comes with redhat).  I'm using lvm 1.0.3-12 that comes with redhat 9.  I have not tried getting the latest lvm tools.  That's my next step...</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Anyone else had this problem, or tried doing this?  The reason I wanted to do this in the first place is so I can test snapshots.  I want to be able to have a filesystem which is static, that I will then take a snapshot of, then change things on it, and then use the snapshot to bring it back to it's original form.  I know there is some work on union filesystems or translucent filesystems, and such things, but none of it seems mature enough, so this solution seemed like it might work until I hit this snag.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Is anyone else doing this (lvm on loopback)?  Does anyone have it working correctly?  Am I doing something wrong?  Do I need a different version of something?</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Thanks in advance for any help.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Kendal.</FONT>
</P>

</BODY>
</HTML>