[TriLUG] Problem with LVM
Rick DeNatale
rick.denatale at gmail.com
Mon May 1 11:47:37 EDT 2006
On 4/30/06, T. Bryan <tbryan at python.net> wrote:
> On Sunday 30 April 2006 04:12 pm, Rick DeNatale wrote:
>
> > Well here's some more information on my setup. I've got my root fs
> > and a swap "volume" as logical volumes on a raid1 array
> >
> > $ cat /proc/mdstat
> > Personalities : [raid1]
> > md0 : active raid1 sda5[0] sdb5[1]
> > 8634816 blocks [2/2] [UU]
> >
> > unused devices: <none>
> >
> > $ sudo lvmdiskscan -v
> > /dev/md0 [ 8.23 GB] LVM physical volume
>
> Thanks for the comparison. That's pretty much what I expected to see. I just
> wish that I had run and captured the output from these commands when it
> looked like things were working.
>
> > I'm a little suspicious about those lines in your output:
> > > /dev/hde1 [ 111.79 GB] LVM physical volume
> > > Found duplicate PV 7LOs90S2Ff8W7Tq8ZGRsT41lphbExsLh: using /dev/hdg1
> > > not /dev/hde1
> > > /dev/hdg1 [ 111.79 GB] LVM physical volume
>
> Me, too. :)
>
> > To me this looks like, instead of building a raid array with two
> > physical partitions and then making that a PV, you tried to make a
> > raid array from two LVM PVs.
>
> That's not what I attempted. My journal says that I set this up with
>
> mke2fs -j /dev/hde1
> mke2fs -j /dev/hdg1
> mdadm --create --verbose /dev/md0 --level=1 \
> --raid-devices=2 /dev/hde1 /dev/hdg1
> mdadm -S /dev/md0
> mdadm -As /dev/md0
>
> pvcreate /dev/md0
> vgcreate localvg /dev/md0
> lvcreate -L20G -nlv_local1 localvg
> mke2fs -j /dev/localvg/lv_local1
>
> I wasn't sure whether I needed to mke2fs both on the underlying device and on
> the logical volumes, but it seemed to work well for a while, and I was
> reading and writing data to the logical volume. It would be nice to get it
> working again. :)
Here are the steps I took to move my root to an LVM on top of raid.
I've copied this from the ticket I created for the job in request
tracker, and have edited it slightly. I was quite cautious with this
plan since I was migrating the root filesystem, which I don't think
you are doing.
1) Partition /dev/sdb like /dev/sda
2) Create the raid array with a missing drive
$mdadm --create /dev/md0 --level 1 --raid-devices=2 missing /dev/sdb5
3) Create a PV on the raid array
$pvcreate /dev/md0
4) create a VG
$vgcreate MainVG /dev/md0
5) Create the LVs
$lvcreate -l 2013 MainVG -n root
$lvcreate -l 95 MainVG -n swap_1
6) Format the LVs
$mkfs.ext3 /dev/MainVG/root
$mkswap /dev/MainVG/swap_1
7) Mount the new root LV
$sudo mkdir /mnt/root
$sudo mount /dev/MainVG/root /mnt/root
8) Copy the root partition
$cp -dpRx / /mnt/root
9) Mount the boot partition and copy it. This shouldn't be necessary
in your case.
10) Install grub on the new drive Neither should this
11) Edit /mnt/root/etc/fstab to use the md device. Of course your
/etc/fstab would
be different.
/dev/sdb1 /boot ext3 defaults 0 2
/dev/mapper/MainVG-root / ext3 defaults,errors=remount-ro
0 1
/dev/mapper/MainVG-swap_1 none swap sw 0 0
12) edit /mnt/boot/grub/menu.lst to change Ubuntu to MainVG This
shouldn't apply to you since you aren't changing the root filesystem
to raid/LVM.
13) Planned hold <G> (To avoid an actual step 13)
14) touch /mnt/root/home/rick/newvg so that we can see that we actually
get the new setup. Again, not applicable in your case, I wanted to
make sure that I'd actually gotten the right root filesystem after the
reboot.
15) Cross fingers and reboot
16) Look for /home/rick/newvg see #14
17) Test the new config to make sure it's the same system!
18) Now add /dev/sda5 to the raid
$sudo mdadm --add /dev/md0 /dev/sda5
This wipes the contents of /dev/sda5 and syncs it with /dev/sdb
19) $watch cat /proc/mdstat
looking for sync to complete status will be [UU]
> > My setup has LVM on top of raid. I know that way works, I'm not sure
> > whether or not raid on top of LVM does.
>
> Another question. What is your partition type for /dev/sda5 and /dev/sdb5?
$sudo fdisk -l /dev/sda /dev/sdb
...
/dev/sda5 32 1106 8634906 8e Linux LVM
Disk /dev/sdb: 9173 MB, 9173114880 bytes
...
/dev/sdb5 32 1106 8634906 fd Linux raid autodetect
> None of the HOWTOs mentioned changing it, but I notice that partition type 8e
> is Linux LVM, but mine is 83 (Linux) for ext3.
I didn't do anything to explicitly change the partition type with
fdisk/sfdisk. I beleive that they got that way as a side-effect of
the mdadm and pvcreate commands. Given your symptoms I suspect that
the problem isn't the 83 vs 8e, but the 83 vs fd partition types.
--
Rick DeNatale
Visit the Project Mercury Wiki Site
http://www.mercuryspacecraft.com/
More information about the TriLUG
mailing list