March 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031

Categories

March 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031

DDING DISK SPACE TO AN EXISTING VOLUME GROUP

In the situation where you have exhausted all of the disk space in a volume group, you can add additional disks to the volume group in order to remediate the situation.

Locate the additional disk using the fdisk -l command.

[root@slave ~]# fdisk -l
Disk /dev/sdd: 3221 MB, 3221225472 bytes, 6291456 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
The next step is to create a LVM partition using the above disk (/dev/sdd).

[root@slave ~]# fdisk /dev/sdd
Type in n and press enter three times.
Type in +2G and press enter.
Type in t and press enter.
Type in 8e and press enter.
Type in w and press enter.
Type in q and press enter.
Run partprobe to make the kernel aware of the disk changes.

[root@slave ~]# partprobe
Check the partition path by running fdisk -l.

[root@slave ~]# fdisk -l
Disk /dev/sdd: 3221 MB, 3221225472 bytes, 6291456 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xeef01ba1
Device Boot Start End Blocks Id System
/dev/sdd1 2048 4196351 2097152 8e Linux LVM
Create the physical volume using pvcreate.

[root@slave ~]# pvcreate /dev/sdd1
Physical volume “/dev/sdd1” successfully created
We’re now going to add 2GB of space from the new /dev/sdd1 partition to the lvtestvolume volume group.

[root@slave ~]# vgextend lvtestvolume /dev/sdd1
Volume group “lvtestvolume” successfully extended
Verify the size of the volume group by running vgdisplay lvtestvolume.

[root@slave ~]# vgdisplay lvtestvolume
— Volume group —
VG Name lvtestvolume
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 4.99 GiB
PE Size 4.00 MiB
Total PE 1278
Alloc PE / Size 512 / 2.00 GiB
Free PE / Size 766 / 2.99 GiB
VG UUID wxeQ0N-ZboT-lN2s-CCeQ-zkbb-B24Q-Khh6NB
The disk space has now been made available to the volume group, however the logical volume needs to be extended in order to make use of the additional space.

[root@slave ~]# lvdisplay lvtestvolume
— Logical volume —
LV Path /dev/lvtestvolume/data
LV Name data
VG Name lvtestvolume
LV UUID fwCnof-OoOu-8PNR-wPC2-LqBL-TQK6-DCZbiR
LV Write Access read/write
LV Creation host, time slave, 2014-10-13 19:23:50 -0400
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 8192
Block device 253:4
We can now use lvextend to add an additional 2GB of space to the lvtestvolume.

[root@slave ~]# lvextend -L +2G /dev/lvtestvolume/data
Extending logical volume data to 4.00 GiB
Logical volume data successfully resized
We can finally verify the disk space addition from using lvdisplay /dev/lvtestvolume/data or through using df -hk | grep /data.

[root@slave ~]# lvdisplay /dev/lvtestvolume/data
— Logical volume —
LV Path /dev/lvtestvolume/data
LV Name data
VG Name lvtestvolume
LV UUID fwCnof-OoOu-8PNR-wPC2-LqBL-TQK6-DCZbiR
LV Write Access read/write
LV Creation host, time slave, 2014-10-13 19:23:50 -0400
LV Status available
# open 1
LV Size 4.00 GiB
Current LE 1024
Segments 2
Allocation inherit
Read ahead sectors auto
– currently set to 8192
Block device 253:4
[root@slave ~]# df -hk | grep /data
/dev/mapper/lvtestvolume-data 1998672 6144 1871288 1% /data

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>