Hi,

stan <[EMAIL PROTECTED]> wrote:

> I've played with LVM on HP-UX, but only just enough to get a firm 
> handle on the fact that I don't understand the complexities of it,
> and that is easy to screw up, but hard to fix :-)
> 
> So, I find myself building a Debian MytTV machine. In addition
> to the 40G root drive, I installed 2 other drives, a 60G (/dev/hdb), 
> and a 120G (/dev/hdd). 
> 
> What I want to do is create one large "virtual disk" out of these,
> then I will then create a XFS filesystem on and use to store various 
> multimedia files for mythtv. I want the disks to be "striped" if
> that is possible with different size disks? 
> 
> I've installed the lvm (1) packages, and I've read the HOWTO.
> Here is what I came up with:
> 
> fdisk both disks, creating a single partition on each one of type 8e
> 
> pvcreate /dev/hdb1
> pvcreate /dev/hdd1
> 
> vgcreate mythtv /dev/hdb1 /dev/hdd1
> 
> And then I should be ready to create a filesystem on this "virtual 
> disk".

Not quite. You need to run

lvcreate -L <size> -n <name> <vgname> 
e.g.
lvcreate -L 180 GB -n lvol1 mythtv

remember: you create filesystems on *logical volumes*, not on a VG.

The lvcreate ... command creates a Logical Volume for you and makes it
available under /dev/<vgname>/<lvname>, e.g. /dev/mythtv/lvol1

Then you create the filesystem like so

mkfs.xfs /dev/mythtv/lvol1

and mount it. (I assume at this point that you have relevant modules
loaded, a good kernel to support xfs, and the userland xfsprogs installed)


Be sure to exercise the commands
  cat /proc/lvm/global
  vgdisplay -v <vgname>
  lvdisplay -v /dev/<vgname>/<lvname>
a lot!

> 
> Is it really that simple?
> 
> Any advice on pitfalls appreciated!


Good luck!
Erich


PS: as a goodie, I attach a script of mine, which I use a lot just to make
life a bit more simple. READ IT, use at your own risk, report
errors/suggestions/kudos/...

#!/bin/bash

#set -x

Prog=$(basename $0)

tmp_lv=/tmp/$Prog.$$.lv
tmp_pv=/tmp/$Prog.$$.pv
tmp_vg=/tmp/$Prog.$$.vg


L_VG=$(vgdisplay | grep -E '^[ ]*VG Name' | awk '{print $3}')

for vg in $L_VG
do
        vgdisplay $vg > $tmp_vg
        vg_total=$(grep '^[ ]*Total PE' $tmp_vg | awk '{print $3}')
        vg_free=$(grep '^[ ]*Free  PE' $tmp_vg | awk '{print $5}')
        echo "--- $vg ---   free $vg_free of $vg_total"
        L_LV=$(vgdisplay -v $vg | grep -E '^[ ]*LV Name' | awk '{print $3}')
        echo "    lvols"
        for lv in $L_LV
        do      
                lvs=${lv##*/}
                lvdisplay -v $lv > $tmp_lv
                lv_stat=$(grep '^[ ]*LV Status' $tmp_lv | awk '{print $3}')
                lv_size=$(grep '^[ ]*LV Size' $tmp_lv | awk '{print $3,$4}')
                lv_cule=$(grep '^[ ]*Current LE' $tmp_lv | awk '{print $3}')
                lv_alle=$(grep '^[ ]*Allocated LE' $tmp_lv | awk '{print $3}')
                echo "$lv:$lv_alle:$lv_cule:$lv_size:$lv_stat" |\
                awk -F: '{printf "\t%-20s (%s/%s)\t%s\t%s\n",$1,$2,$3,$4,$5}'
                xx=$(df -PT | grep $vg | grep $lvs)
                lv_mountp=$(echo $xx |awk '{print $7}')
                lv_fs_typ=$(echo $xx | awk '{print $2}' )
                if [ "X$lv_mountp" = "X" ]
                then
                        if [ $(grep -c $lv /proc/swaps) = 1 ]
                        then
                                lv_mountp="SWAP"
                        else
                                lv_mountp="RAW"
                        fi
                fi
                echo -e "       $lv_mountp\t\t($lv_fs_typ)"
                sed -n  '/^   PV Name/,/^$/p' $tmp_lv | grep -vE 'PV|^$' | awk 
'{printf "\t  %s %s\n", $1,$2}'
        done
        L_PV=$(vgdisplay -v $vg | grep '^[ ]*PV Name' | awk '{print $3}')
        echo "    pvs"
        for pv in $L_PV
        do
                pvdisplay $pv > $tmp_pv
                pv_total=$(grep '^[ ]*Total PE' $tmp_pv | awk '{print $3}')
                pv_free=$(grep '^[ ]*Free PE' $tmp_pv | awk '{print $3}')
                echo "  $pv     free $pv_free of $pv_total"
        done
done

rm -f $tmp_lv $tmp_pv $tmp_vg

Reply via email to