add a new disk to LVM

How  to add  new  disk via LVM:

 

Sulutions

 

 

  1. Add new physical disk. Boot.
  2. # pvscan

    This will show you the current physical volumes.

  3. # fdisk /dev/sdb

    Add the disk to your machine as a primary partition. Partition type: “

    8e

    (LVM)”. Obviously

    /dev/sdb

    may be different on your system.

  4. # pvcreate /dev/sdb1

    This creates a new physical LVM volume on our new disk.

  5. # vgextend VolGroup00 /dev/sdb1

    Add our new physical volume to the volume group:

    VolGroup00

    . Again, this group name may by different for you, but this is what Redhat & CentOS assigns by default when you install your system.

  6. # pvscan

    You should see the new physical volume assigned to VolGroup00.

  7. # lvextend -L+40G /dev/VolGroup00/LogVol00

    This increases the size of the logical volume our root partition resides in. Change the

    -L

    flag as appropriate.

We’ve just added 40GB to the logical volume used by the root partition. Sweet as. Now we need to resize the file system to utilize the additional space.

  1. Reboot into rescue mode using your CentOS CDROM.

    From memory this involves typing linux rescue as your boot option.

  2. When prompted, skip the mounting of system partitions.
  3. # lvm vgchange -a y

    This command makes your LVM volumes accessible.

  4. # e2fsck -f /dev/VolGroup00/LogVol00

    Run a file system check, the -f flag seems necessary. No idea what we do if the returns an error?

  5. # resize2fs /dev/VolGroup00/LogVol00

    Without any parameters resize2fs will just increase the file system to the max space available.

Reboot and your root partition is now 40GB lager, spanning multiple disks. Yay.