Software >> OS >> Unix >> Linux >> RHEL >> How to extend file system by adding a new disk

add disk to the vm
check disk is detected by

# fdisk -l

e.g. new disk /dev/sdb added without partition table


create physical volume from physical disk device /dev/sda1
we are using the whole disk => delete any partition table in it by


Create PV

# pvcreate /dev/sdb

# pvs
  PV         VG         Fmt  Attr PSize  PFree
  /dev/sda2  VolGroup00 lvm2 a-   49.88G     0
  /dev/sdb              lvm2 a-   50.00G 50.00G    <==


Extend VG

# vgextend VolGroup00 /dev/sdb
  Volume group "VolGroup00" successfully extended

# vgs
  VG         #PV #LV #SN Attr   VSize  VFree
  VolGroup00   2   2   0 wz--n- 99.84G 49.97G


Extend LV

Before extending the LV, status is

# lvs
  LV       VG         Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  LogVol00 VolGroup00 -wi-ao 45.97G                                    
  LogVol01 VolGroup00 -wi-ao  3.91G    

# lvdisplay /dev/VolGroup00/LogVol00

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                lCQ3pw-cPTl-D4Dq-JRTA-cf9J-OeZS-qb17ER
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                45.97 GB
  Current LE             1471
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
                              
extend it

# lvextend -L +49G /dev/VolGroup00/LogVol00

After extending the LV, status is

[root@vbRH57 ~]# lvdisplay /dev/VolGroup00/LogVol00
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                lCQ3pw-cPTl-D4Dq-JRTA-cf9J-OeZS-qb17ER
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                94.97 GB
  Current LE             3089
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

Resize the filesystem to use the available space

# resize2fs /dev/VolGroup00/LogVol00