1. Check the newly added partition using the command fdisk -l
fdisk -l –List the all partitions with newly added partition, for example /dev/sdd
2. Create a new partition for disk /dev/sdd
root@]fdisk /dev/sdd
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044):
Using default value 1044
Then we need to change the partition type of the Linux LVM by command “t” followed by “8e””
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help):p
Disk /dev/sdd: 8599 MB, 8599934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4fce54ed
Device Boot Start End Blocks Id System
/dev/sdd1 1 1044 8389858+ 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
We have created a new partition called /dev/sdd1
We need to create an LVM uses the 3 logical layers, which consists of PHYSICAL DEVICE (PV), VOLUME GROUP (VG) AND LOGICAL VOLUME (LV). We need to follow these 3 logical layers to configure LVM
3.Use pvcreate to set up the newly created partition
root@] pvcreate /dev/sdd1
Physical Volume “/dev/sdd1” successfully created
We can view the newly created physical volume through “pvdisplay” command
4. Extend existing volume group onto the new partition
The command “vgdisplay” list all the volume groups.
root@]vgdisplay
— Volume group—
VG Name Volgroup01
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 3
Act PV 3
VG Size 43.82 GiB
PE Size 4.00 MiB
Total PE 11218
Alloc PE / Size 5687 / 22.63 GiB
Free PE / Size 5781 / 23.19 GiB
VG UUID ZoXbMV-LtZL-TRT1-MIFi-04xr-CFB3-rYTKxs
5. In the above output we will be extending “Volgroup01” volume group by running
root@]vgextendVolgroup01 /dev/sdd1
6. Extend existing logical volume onto new space
Use “lvdisplay” command sees the logical volumes
root@]lvdisplay
— Logical volume—
LV Name /dev/Volgroup01/root
VG Name Volgroup01
LV UUID UJQUwV-f3rI-Tsd3-dQYO-exIk-LSpq-2qls13
LV Write Access read/write
LV Status available
# open 1
LV Size 43.82
Current LE 1892
Segments 1
Allocation inherit
Read ahead sectors auto
-currentlyset to 256
Block device 254:0
7. Use ‘lvextend’ to use all of the new space.
This command used for extending the existing logical volume with the newly added disk space. Here we have a logical volume (/dev/Volgroup01/root) with 44GB extend with the new added disk (/dev/sdd1) with disk space 8.5 GB
We can extend the LVM with the full disk space of the newly added diskbythe below command
root@]lvextend /dev/Volgroup01/root /dev/sdd1
Extending logical volume rootto8.5G
Also, you can use the partial disk space available in the newly added disk space for extending the LVM through the below command
root@]lvextend –L +5GB /dev/Volgroup01/root /dev/sdd1
It will extend the existing LVM with 5GB free space available in the disk /dev/sdd1
8. Extend File system using command “resize2fs”
This command is usually used for the file system ext3/4.Command will vary according to the file system which you need.
root@]resize2fs /dev/Volgroup01/root
9. Finally, check disk space to see the expanded disk space
root@]df-h
Leave A Comment
You must be logged in to post a comment.