[aklug] Re: loop devices with partitions...?

From: <jonr@destar.net>
Date: Thu Sep 09 2010 - 10:06:39 AKDT

Quoting Christopher Howard <choward@indicium.us>:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hey, I recently learned you could represent an image file with a loop
> device, which is pretty cool. So, you can create, say, /dev/loop0, and
> then turn it into a file system with mkfs.xfs /dev/loop0 (or whatever
> happens to be your poison).
>
> I noticed I can, instead of turning it into just a file system, run
> fdisk on it to turn it into a disk image with several partitions.
> However, what I'm not sure about yet is, if /dev/loop0 represents the
> disk.img file with several partitions on it, how do "bring out" each of
> those partitions to be its own loop file? (Like, /dev/loop0-part1 or
> something...?)
>
Hi Chris,

Here is another cool trick you can do with these files. I always name
my LV's, which is where my images reside, with the same names. So when
you try to repair the LV's within an LV and you expose it to the
filesystem you now have a conflict with the host LV's and the image
LV's being named the same. Would you like to try a vgscan -ay now? It
wouldn't be an issue if you could tell vgscan to use the uuid of the
LV's but it doesn't.

Ah, but you can just rename the VG and all will be well, right?
Wrong...sort of. You can do this but you will then have to fix the
initrd and the grub stanzas in the boot directory. What a pain in the
ass.

Here is the trick I used to get at my LVs in my xen host without
having to rename and dance with initrd.

virt-install -n FC64DrupalRescue -r 1024 --disk
path=/dev/xenvg/lvLinux-1 --hvm --livecd --cdrom
/mnt/apps/ISO/Fedora-12-x86_64-DVD.iso --force

I created a VM using the --livcd flag in virt-install and pointed at
the "disk" I wanted to repair. When the VM boots it acts just like a
livecd and I can choose to repair a file system. Because I pointed it
at my LV, /dev/xenvg/lvLinux-1, it finds the disk and mounts it under
/mnt/sysimage. I can then go in and repair the file system or whatever
else needs to be done.

Hope that helps someone else that runs into this issue. To really
solve this, I just need to remember to name my LV's for my VM's with
unique LV's that are specific to that image. Which is what I will do
from now on.

Jon

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Thu Sep 9 10:04:28 2010

This archive was generated by hypermail 2.1.8 : Thu Sep 09 2010 - 10:04:29 AKDT