[linux-lvm] Re: lvm partition on lv

Randall Smith randall at tnr.cc
Tue Aug 8 14:27:15 UTC 2006


Markus Laire wrote:
> On 8/8/06, Markus Laire <malaire at gmail.com> wrote:
> 
>> On 8/8/06, Randall Smith <randall at tnr.cc> wrote:
>> > Let's say on /dev/vg1/test I had one LVM partition and one ext3
>> > partition.  How can I access those separate partitions since it's only
>> > one device (/dev/vg1/test)?  Normally, a partitioned block device
>> > (/dev/hda) would show up like /dev/hda1, dev/hda2, etc.
>>
>> With loop-device, you can use only part of the block-device as new
>> block-device (See options -o and -s in man:losetup)
>>
>> So if you know the positions where the partitions start, and their
>> lengths (both in bytes), you could do something like this: (I havn't
>> tested this, so there might be some errors in these commands. But the
>> basic idea should work)
>>
>> # make LVM partition available at /dev/loop1
>> losetup -o $lvm_start -s $lvm_size /dev/loop1 /dev/vg1/test
>> mkdir /mnt/test
>> # Mount ext3-partition at /mnt/test using loop-device
>> mount -t ext3 -o offset=$ext3_start,sizelimit=$ext3_length
>> /dev/vg1/test /mnt/test
> 
> 
> Well, last command is missing at least "loop" option - i.e. it should be
> 
> mount -t ext3 -o loop,offset=$ext3_start,sizelimit=$ext3_length
> /dev/vg1/test /mnt/test
> 
> or you could use these instead
> losetup -o $ext3_start -s $ext3_length /dev/loop2 /dev/vg1/test
> mount -t ext3 /dev/loop2 /mnt/test
> 
> I hope I didn't make other mistakes...
> 
> ($lvm_size and $ext3_length both means the size of the partition in
> bytes - I should've used 'size' or 'length' for both for consistency)
> 
Thanks.  That's perfect.

Working with Unix is so much fun.  It always seems that anything is 
possible as long as I'm willing to learn something new.

Randall




More information about the linux-lvm mailing list