LVM Expansion/Extend the File System in Linux
Note: Current Size of VG (Volume
Group) DISKVG08907 is 59.99G & we have to extend upto 80G
There are two methods to expand file system online in Linux: (recommended
on LVM Version 2)
======================================================
#lvm version (command to check LVM Version)
#lvextend -L 79.99G /dev/DISKVG08907/app (do not
mention any sign while rounding up)
(Above command will round up the logical volume app to 79.99 GB)
#resize2fs /dev/DISKVG08907/app
(Above command will resize the logical
volume app)
Or
#lvextend -L +20G /dev/DISKVG08907/app (please
remember to mention + sign while adding)
(Above command will add 20GB more in logical volume app)
#resize2fs /dev/DISKVG08907/app
(Above command will resize the logical
volume app)
======================================================
Below is the example to extend file system online
bash-3.2# hostname
LinuxServer1
(Status before expanding /app file system)
======================================================
bash-3.2# df –HT /app
Filesystem Type Size
Used Avail Use% Mounted on
/dev/mapper/DISKVG08907-app ext3 64G
461M 60G 1% /app
bash-3.2# fdisk -l
Disk /dev/sda: 16.1 GB, 16106127360
bytes
255 heads, 63 sectors/track, 1958
cylinders
Units = cylinders of 16065 * 512 =
8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sda1 *
1 33 265041
83 Linux
/dev/sda2 34 1958
15462562+ 8e Linux LVM
Disk /dev/sdb: 85.8 GB, 85899345920
bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 =
8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sdb1 1 7832
62910508+ 8e Linux LVM
bash-3.2#
bash-3.2# pvs
PV VG Fmt
Attr PSize PFree
/dev/sdb1 DISKVG08907
lvm2 a- 59.99G 0
bash-3.2# vgs
VG #PV #LV #SN Attr VSize
VFree
DISKVG08907 1
1 0 wz--n- 59.99G 0
bash-3.2# lvs
LV VG Attr LSize Origin
Snap% Move Log Copy% Convert
app DISKVG08907 -wi-ao 59.99G
======================================================
bash-3.2# fdisk /dev/sdb
The number of cylinders for this
disk is set to 10443.
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)
Command (m for help): p
Disk /dev/sdb: 85.8 GB, 85899345920
bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 =
8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sdb1 1 7832
62910508+ 8e Linux LVM
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (7833-10443, default 7833): (press enter)
Using default value 7833
Last cylinder or +size or +sizeM or
+sizeK (7833-10443, default 10443): (press enter)
Using default value 10443
Command (m for help): p
Disk /dev/sdb: 85.8 GB, 85899345920
bytes
255 heads, 63 sectors/track, 10443
cylinders
Units = cylinders of 16065 * 512 =
8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sdb1 1 7832
62910508+ 8e Linux LVM
/dev/sdb2 7833 10443
20972857+ 83 Linux
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to
8e (Linux LVM)
Command (m for help): p
Disk /dev/sdb: 85.8 GB, 85899345920
bytes
255 heads, 63 sectors/track, 10443
cylinders
Units = cylinders of 16065 * 512 =
8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sdb1 1 7832
62910508+ 8e Linux LVM
/dev/sdb2 7833 10443
20972857+ 8e Linux LVM
Command (m for help): w
The partition table has been
altered!
Calling ioctl() to re-read partition
table.
WARNING: Re-reading the partition
table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the
next reboot.
Syncing disks.
bash-3.2# partprobe /dev/sdb
(Partprobe is a program that informs
the operating system kernel of partition table changes, by requesting that the
operating system re-read the partition table)
bash-3.2# fdisk -l
Disk /dev/sda: 16.1 GB, 16106127360
bytes
255 heads, 63 sectors/track, 1958
cylinders
Units = cylinders of 16065 * 512 =
8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sda1 *
1 33 265041
83 Linux
/dev/sda2 34 1958
15462562+ 8e Linux LVM
Disk /dev/sdb: 85.8 GB, 85899345920
bytes
255 heads, 63 sectors/track, 10443
cylinders
Units = cylinders of 16065 * 512 =
8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sdb1 1 7832
62910508+ 8e Linux LVM
/dev/sdb2 7833 10443
20972857+ 8e Linux LVM
bash-3.2# pvcreate /dev/sdb2
Physical volume "/dev/sdb2" successfully created
bash-3.2# pvs
PV VG Fmt
Attr PSize PFree
/dev/sda2 vg00 lvm2 a- 14.62G
5.88G
/dev/sdb1 DISKVG08907 lvm2
a- 59.99G 0
/dev/sdb2 lvm2 a-
20.00G 20.00G
bash-3.2# vgs
VG #PV #LV #SN Attr VSize
VFree
DISKVG08907 1
1 0 wz--n- 59.99G 0
vg00 1 5 0
wz--n- 14.62G 5.88G
bash-3.2# vgextend -v DISKVG08907 /dev/sdb2
Checking
for volume group "DISKVG08907"
Archiving volume group "DISKVG08907" metadata (seqno 2).
Wiping cache of LVM-capable devices
Adding physical volume '/dev/sdb2' to volume group 'DISKVG08907'
Volume group "DISKVG08907" will be extended by 1 new physical
volumes
Creating volume group backup "/etc/lvm/backup/DISKVG08907"
(seqno 3).
Volume group "DISKVG08907" successfully extended
bash-3.2# lvextend -L 79.99G /dev/DISKVG08907/app
Rounding up size to full physical extent 79.99 GB
Extending logical volume app to 79.99 GB
Logical volume app successfully resized
bash-3.2# resize2fs /dev/DISKVG08907/app
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/DISKVG08907/app is
mounted on /app; on-line resizing required
Performing an on-line resize of /dev/DISKVG08907/app
to 20969472 (4k) blocks.
The filesystem on /dev/DISKVG08907/app
is now 20969472 blocks long.
(Status after expanding /app file system)
======================================================
bash-3.2# df –HT /app
Filesystem Type Size
Used Avail Use% Mounted on
/dev/mapper/DISKVG08907-app ext3
85G 465M 80G
1% /app
bash-3.2# pvs
PV VG Fmt
Attr PSize PFree
/dev/sda2 vg00 lvm2 a- 14.62G
5.88G
/dev/sdb1 DISKVG08907 lvm2
a- 59.99G 0
/dev/sdb2 DISKVG08907 lvm2 a- 20.00G 20.00G
bash-3.2# vgs
VG #PV #LV #SN Attr VSize
VFree
DISKVG08907 2 1 0
wz--n- 79.99G 20.00G
bash-3.2# lvs
LV VG Attr LSize
Origin Snap% Move Log Copy% Convert
app DISKVG08907 -wi-ao 79.99G
======================================================
bash-3.2# cd /app
bash-3.2# du -sh * (check
& confirm /app data)
16K lost+found
259M file1
bash-3.2# cat /etc/fstab (check
entry in /etc/fstab for /app file system)
/dev/DISKVG08907/app /app ext3 defaults 0 0
Created by: Yogesh Anuvadia
No comments:
Post a Comment