LVM ROOT PARTITION EXTEND IN CENTOS 6

To check current status of disk please run below command

[root@graylog-rc ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000cce69

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 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: 0x00000000
Disk /dev/mapper/vg_graylogrc-lv_root: 18.8 GB, 18798870528 bytes
255 heads, 63 sectors/track, 2285 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: 0x00000000
Disk /dev/mapper/vg_graylogrc-lv_swap: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 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: 0x00000000

To check the status of LVM please run below command

[root@graylog-rc ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
lv_root vg_graylogrc -wi-ao—- 17.51g
lv_swap vg_graylogrc -wi-ao—- 2.00g

 

To check the status of mounted disks size current size

[root@graylog-rc ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_graylogrc-lv_root ext4 18G 8.5G 8.0G 52% /
tmpfs tmpfs 935M 0 935M 0% /dev/shm
/dev/sda1 ext4 485M 33M 452M 7% /boot

 

To create changes in Disk use fdisk command

[root@graylog-rc ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xaa450455.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652):
Using default value 652

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): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Create format of disk using mkfs.ext4 command

[root@graylog-rc ~]# mkfs.ext4 /dev/sdb
sdb sdb1
[root@graylog-rc ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1309289 blocks
65464 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

 

[root@graylog-rc ~]# pvcreate /dev/sd
sda sda1 sda2 sdb sdb1
[root@graylog-rc ~]# pvcreate /dev/sdb1
Physical volume “/dev/sdb1” successfully created

[root@graylog-rc ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_graylogrc 1 2 0 wz–n- 19.51g 0

 

[root@graylog-rc ~]# vgextend vg_graylogrc /dev/sdb1
Volume group “vg_graylogrc” successfully extended

 

[root@graylog-rc ~]# resize2fs /dev/mapper/vg_graylogrc-lv
resize2fs 1.41.12 (17-May-2010)
open: No such file or directory while opening /dev/mapper/vg_graylogrc-lv

[root@graylog-rc ~]# resize2fs /dev/mapper/vg_graylogrc-lv_root
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 4589568 blocks long. Nothing to do!

 

[root@graylog-rc ~]# lvextend -l +100%FREE /dev/mapper/vg_graylogrc-lv_root
Extending logical volume lv_root to 22.50 GiB
Logical volume lv_root successfully resized

[root@graylog-rc ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_graylogrc-lv_root ext4 18G 8.5G 8.0G 52% /
tmpfs tmpfs 935M 0 935M 0% /dev/shm
/dev/sda1 ext4 485M 33M 452M 7% /boot

[root@graylog-rc ~]# resize2fs /dev/mapper/vg_graylogrc-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_graylogrc-lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 2
Performing an on-line resize of /dev/mapper/vg_graylogrc-lv_root to 5898240 (4k) blocks.
The filesystem on /dev/mapper/vg_graylogrc-lv_root is now 5898240 blocks long.

 

[root@graylog-rc ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_graylogrc-lv_root ext4 23G 8.5G 13G 40% /
tmpfs tmpfs 935M 0 935M 0% /dev/shm
/dev/sda1 ext4 485M 33M 452M 7% /boot

 

[root@graylog-rc ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
lv_root vg_graylogrc -wi-ao—- 22.50g
lv_swap vg_graylogrc -wi-ao—- 2.00g

 

[root@graylog-rc ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_graylogrc 2 2 0 wz–n- 24.50g 0

Recommended For You.

Grsecurity® is an extensive security enhancement to the Linux kernel that defends against a wide range of security threats through