Skip to content

Instantly share code, notes, and snippets.

@krishna209
Created April 20, 2015 22:23
Show Gist options
  • Save krishna209/f1254ed8c72a18aef272 to your computer and use it in GitHub Desktop.
Save krishna209/f1254ed8c72a18aef272 to your computer and use it in GitHub Desktop.
#Typed parted in console
#it will take you into parted shell
parted
#select device to be parted using the following command
select devicename
#Ex select /dev/vda
#vda represents virtual device
#sda represents physical storage
#p is for display
#print/p will display the partitions done and memory available in the disc
print
(parted) p
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 211MB 210MB primary ext4 boot
2 211MB 10.7GB 10.5GB primary lvm
(parted) mkpart #to make the partition
Partition type? primary/extended? primary # type of partition
File system type? [ext2]? # filesystem type , we need ext4 but it is not supported by default
Start? 10.7GB # starting point of the partitiion
End? 21.5GB #ending point of the partition
Warning: WARNING: the kernel failed to re-read the partition table on /dev/vda (Device or resource busy). As a result, it may not reflect all of your changes until after
reboot.
(parted) q #to quit from the parted shell
[root@workernode3 ~]# reboot # need to reboot to reflect the changes
Steps to add the created partition to a logical volume
pvdisplay # displays the current physical volumes and volume group details
--- Physical volume ---
PV Name /dev/vda2
VG Name VolGroup00
PV Size 9.80 GiB / not usable 23.00 MiB
Allocatable yes (but full)
PE Size 32.00 MiB
Total PE 313
Free PE 0
Allocated PE 313
PV UUID 2I4UJJ-nEny-zaJb-V1an-knNU-0cYe-Rw6sTk
[root@workernode3 ~]# pvcreate /dev/vda3 # physical volume create , to create a new physical volume
Physical volume "/dev/vda3" successfully created
[root@workernode3 ~]#
[root@workernode3 ~]#
[root@workernode3 ~]# vgdisplay # virtual group display to see the details of the group
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 9.78 GiB
PE Size 32.00 MiB
Total PE 313
Alloc PE / Size 313 / 9.78 GiB
Free PE / Size 0 / 0
VG UUID 7VjBKK-vWvf-Faxz-cAPT-gLjv-3gd2-RQadCz
vgextend VolGroup00 /dev/vda3 # extend the logical volume with the new disk space
Volume group "VolGroup00" successfully extended
[root@workernode3 ~]# pvscan # to verify whether it is added to the group or not
PV /dev/vda2 VG VolGroup00 lvm2 [9.78 GiB / 0 free]
PV /dev/vda3 VG VolGroup00 lvm2 [9.97 GiB / 9.97 GiB free]
Total: 2 [19.75 GiB] / in use: 2 [19.75 GiB] / in no VG: 0 [0 ]
[root@workernode3 ~]# lvextend /dev/VolGroup00/LogVol00 /dev/vda3# logical volume extend
Extending logical volume LogVol00 to 18.25 GiB
Logical volume LogVol00 successfully resized
[root@workernode3 ~]# resize2fs /dev/VolGroup00/LogVol00 # resizing the volume with the new space and die system
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4784128 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 4784128 blocks long.
[root@workernode3 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 18G 1.9G 16G 12% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/vda1 194M 34M 151M 19% /boot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment