This knowledgebase describes how to extend filesystem online. There 'll 6 steps that you need to follow.
- Ask storage admin for new LUN
- Create a partition for new LUN (optional)
- Create PV
- Extend Volume Group
- Extend LVM
- Resize to Filesystem
Step 1:Check new LUN device
Check disk ID for the new LUN. I 'll use "sdc" .
# cd /dev/disk/by- by-id/ by-label/ by-path/ by-uuid/ [shell]#fdisk /dev/sdc Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. The number of cylinders for this disk is set to 13054. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): p Disk /dev/sdc: 107.3 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-13054, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-13054, default 13054): Using default value 13054 Command (m for help): p Disk /dev/sdc: 107.3 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdc1 1 13054 104856223+ 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
After creating a partition for new disk I recommend to run partprobe to update "/proc/partitions".
#partprobe
#more /proc/partitions major minor #blocks name 8 0 52428800 sda 8 1 104391 sda1 8 2 16779892 sda2 8 3 35543812 sda3 8 16 52428800 sdb 8 17 52428096 sdb1 253 0 35520512 dm-0 253 1 52420608 dm-1 8 32 104857600 sdc 8 33 104856223 sdc1
Step 2:Create Physical Volumes (PV)
#pvcreate /dev/sdc1
Step 3:Extend Volume Group (VG)
#df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg00-lvroot 33G 6.0G 26G 20% / /dev/sda1 99M 13M 82M 14% /boot tmpfs 5.9G 0 5.9G 0% /dev/shm /dev/mapper/vgappdata00-lvappdata00 50G 12G 36G 25% /appdata
#vgdisplay -v vgappdata00 Using volume group(s) on command line Finding volume group "vgappdata00" /dev/cdrom: open failed: No medium found --- Volume group --- VG Name vgappdata00 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size 50.00 GB PE Size 4.00 MB Total PE 12799 Alloc PE / Size 12798 / 49.99 GB Free PE / Size 1 / 4.00 MB VG UUID 6Vr7xk-0pWv-pXZZ-NUKz-XDN5-1m0I-9CfI50 --- Logical volume --- LV Name /dev/vgappdata00/lvappdata00 VG Name vgappdata00 LV UUID oNGKaQ-3Sk5-4kDG-0uTP-3xZk-Opwg-SMICYk LV Write Access read/write LV Status available # open 1 LV Size 49.99 GB Current LE 12798 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 --- Physical volumes --- PV Name /dev/sdb1 PV UUID q83spy-tNZa-9Vhf-XFwx-crTh-yvtp-QzkgAp PV Status allocatable Total PE / Free PE 12799 / 1
#vgextend vgappdata00 /dev/sdc1 /dev/cdrom: open failed: No medium found Volume group "vgappdata00" successfully extended
# vgdisplay -v vgappdata00 Using volume group(s) on command line Finding volume group "vgappdata00" /dev/cdrom: open failed: No medium found --- Volume group --- VG Name vgappdata00 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 2 Act PV 2 VG Size 149.99 GB PE Size 4.00 MB Total PE 38398 Alloc PE / Size 12798 / 49.99 GB Free PE / Size 25600 / 100.00 GB VG UUID 6Vr7xk-0pWv-pXZZ-NUKz-XDN5-1m0I-9CfI50 --- Logical volume --- LV Name /dev/vgappdata00/lvappdata00 VG Name vgappdata00 LV UUID oNGKaQ-3Sk5-4kDG-0uTP-3xZk-Opwg-SMICYk LV Write Access read/write LV Status available # open 1 LV Size 49.99 GB Current LE 12798 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 --- Physical volumes --- PV Name /dev/sdb1 PV UUID q83spy-tNZa-9Vhf-XFwx-crTh-yvtp-QzkgAp PV Status allocatable Total PE / Free PE 12799 / 1 PV Name /dev/sdc1 PV UUID Rhh0hs-C0Zw-xhTJ-RdbS-v28i-Kste-VuzPK2 PV Status allocatable Total PE / Free PE 25599 / 25599
Step 4:Extend Logical Volume
#lvextend -l +25500 /dev/vgappdata00/lvappdata00 /dev/cdrom: open failed: No medium found Extending logical volume lvappdata00 to 149.60 GB Logical volume lvappdata00 successfully resized[/shell] [shell]#lvdisplay /dev/vgappdata00/lvappdata00 --- Logical volume --- LV Name /dev/vgappdata00/lvappdata00 VG Name vgappdata00 LV UUID oNGKaQ-3Sk5-4kDG-0uTP-3xZk-Opwg-SMICYk LV Write Access read/write LV Status available # open 1 LV Size 149.60 GB Current LE 38298 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1
Step 5:Extend Filesystem Online
#df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg00-lvroot 33G 6.0G 26G 20% / /dev/sda1 99M 13M 82M 14% /boot tmpfs 5.9G 0 5.9G 0% /dev/shm /dev/mapper/vgappdata00-lvappdata00 50G 12G 36G 25% /appdata
#resize2fs /dev/vgappdata00/lvappdata00 resize2fs 1.39 (29-May-2006) Filesystem at /dev/vgappdata00/lvappdata00 is mounted on /appdata; on-line resizing required Performing an on-line resize of /dev/vgappdata00/lvappdata00 to 39217152 (4k) blocks. The filesystem on /dev/vgappdata00/lvappdata00 is now 39217152 blocks long.
Step 6:Check filesystem size after resizing.
#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-lvroot
33G 6.0G 26G 20% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 5.9G 0 5.9G 0% /dev/shm
/dev/mapper/vgappdata00-lvappdata00
148G 12G 129G 9% /appdata