Thursday, April 24, 2008

pvscan and lvcreate

Working with disks on RedHat LVM...
  1. Create a new ext3 FS where room already exists on a physical volume. (RH4)
    [root@here /]# pvscan
      PV /dev/sdb1   VG prod_dg   lvm2 [273.22 GB / 139.44 GB free]
      PV /dev/sda2   VG rootdg    lvm2 [134.66 GB / 106.06 GB free]
      Total: 2 [407.88 GB] / in use: 2 [407.88 GB] / in no VG: 0 [0   ]
    [root@here /]# lvcreate --size 5G -n homeVol -t rootdg             # Minus t for "test"
      Test mode: Metadata will NOT be updated.
      Failed to activate new LV.
    [root@here /]# lvcreate --size 5G -n homeVol rootdg
      Logical volume "homeVol" created
    [root@here /]# mkfs.ext3 -b 1024 -T ext3 /dev/rootdg/homeVol
    mke2fs 1.35 (28-Feb-2004)
    Filesystem label=
    OS type: Linux
    ...
    [root@here /]# vi /etc/fstab
    # add new FS
    [root@here /]# mount /home
    [root@wcidb1 etc]# df -T
    ...
    /dev/mapper/rootdg-homeVol
                  ext3     5159385     11824   4885417   1% /home
    
  2. Free space from the root filesystem (from notes taken while watching someone else -- incomplete and not tested!) - Boot from a rescue CD - ? fdisk -l -- look for "Linux LVM" and note the device path - ? Find out what VG is on that device: pvscan - Find out what LV the root filesystem is on: lvscan - Make the filesystem smaller than the new LV size: resize2fs /dev/whatever newsize, with K/G/M trailer - Activate the LV: lvm lvchange -a y /dev/whatever - Shrink the LV: lvm lvreduce --size -1G --resizefs /dev/whatever

No comments: