Pages

Tuesday, September 13, 2011

add disk to lvm


Suppose the Disk is /dev/sdb, the second scsi disk,

  fdisk /dev/sdb
  create as many partitions as you need using command n
  Label them with command t as 8e for making it Linux LVM
  Write and Exit with the command w.

Format the partitions you require using mkfs command

  mkfs -t ext3 -c /dev/sdb1

LVM commands

  pvcreate /dev/sdb1
  vgextend VolGroup00 /dev/sdb1
  lvextend -L 15G /dev/VolGroup00/LogVol00 ;for extending LogVol to 15GB
  lvextend -L+1G /dev/VolGroup00/LogVol00 ;for adding one more GB to Logical Volume LogVol01
  resize2fs /dev/VolGroup00/LogVol00 ;for resizing the Logical Volumes

To increase the storage capacity while keeping the server online, add the disk and then rescan scsi:  

echo "- - -" > /sys/class/scsi_host/host0/scan

2 comments:

  1. Here's my process to hot-add a Virtual Hard Disk (VHD) on ESX. My installation is using ESX 4.0 with CentOS5 guests.

    1. Add the new hardware using the ESX(i) vSphere utility
    2. Take note of the SCSI ID assigned to the new VHD
    3. On the running VM:
    a. echo "scsi add-single-device" 0 0 1 0 > /proc/scsi/scsi (change the "1" to the SCSI ID you took notice of in step 2)
    b. cat /proc/scsi/scsi
    c. /sbin/fdisk /dev/sdb
    d. /sbin/mkfs.ext3 /dev/sdb1
    e. Mount as you see fit.

    ReplyDelete
  2. Hi Joe,

    your steps are correct.
    What I could comments is:

    steps 2&3: it's easier and less error prone to trigger an iscsi rescan then to manually input the information
    step e. : while mounting in the desired location is good enough, if the system already uses lvm I find it more convenient to take advantage of that and increase LVM. That way the increase in storage is transparent.

    Thanks for the comment,
    Laura

    ReplyDelete