1. See the Disks and Partition Status:

[root@288RHEL64S ~]# fdisk -l

Disk /dev/sda: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 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: 0x000946d2

   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        6528    51915776   8e  Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 49.0 GB, 48997859328 bytes
255 heads, 63 sectors/track, 5956 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/VolGroup-lv_swap: 4160 MB, 4160749568 bytes
255 heads, 63 sectors/track, 505 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

2. See LVM Physical Volume Status using the following command:

[root@288RHEL64S ~]# pvs   
  PV         VG       Fmt  Attr PSize  PFree   
  /dev/sda2  VolGroup lvm2 a--  49.51g    0

 

[root@288RHEL64S ~]# pvscan
  PV /dev/sda2   VG VolGroup   lvm2 [49.51 GiB / 0    free]
  Total: 1 [49.51 GiB] / in use: 1 [49.51 GiB] / in no VG: 0 [0   ]

 

[root@288RHEL64S ~]# pvdisplay

  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup
  PV Size               49.51 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              12674
  Free PE               0
  Allocated PE          12674
  PV UUID               UFthVT-S5ja-jQZ0-ZO27-9w5J-EfEV-o09WY

 

  1. See LVM Volume Group Status:
[root@288RHEL64S ~]# vgs

  VG       #PV #LV #SN Attr   VSize  VFree
  VolGroup   1   2   0 wz--n- 49.51g    0

 

 [root@288RHEL64S ~]# vgscan

  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup" using metadata type lvm2

 

[root@288RHEL64S ~]# vgdisplay

  --- Volume group ---
  VG Name               VolGroup
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  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               49.51 GiB
  PE Size               4.00 MiB
  Total PE              12674
  Alloc PE / Size       12674 / 49.51 GiB
  Free  PE / Size       0 / 0  
  VG UUID               u2twPp-Tk5E-A7AT-LpYu-gYCC-fGiF-LOcDKr
  1. See LVM Logical Volume Status
[root@288RHEL64S ~]# lvs

  LV      VG       Attr      LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_root VolGroup -wi-ao--- 45.63g                                            
  lv_swap VolGroup -wi-ao---  3.88g

 

[root@288RHEL64S ~]# lvscan

  ACTIVE            '/dev/VolGroup/lv_root' [45.63 GiB] inherit
  ACTIVE            '/dev/VolGroup/lv_swap' [3.88 GiB] inherit

 

 [root@288RHEL64S ~]# lvdisplay

  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_root
  LV Name                lv_root
  VG Name                VolGroup
  LV UUID                Hibr3Y-4BiB-qkPw-fob0-Bglb-ORP5-jfw1Jg
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2015-11-12 12:41:05 +0600
  LV Status              available
  # open                 1
  LV Size                45.63 GiB
  Current LE             11682
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_swap
  LV Name                lv_swap
  VG Name                VolGroup
  LV UUID                mX2PKI-mqyU-93Vi-gc0S-g8rM-eVwa-pFL8zT
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2015-11-12 12:41:16 +0600
  LV Status              available
  # open                 1
  LV Size                3.88 GiB
  Current LE             992
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

To create a new partition with free space of /dev/sda

[root@288RHEL64S yum.repos.d]# fdisk /dev/sda


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):

Type m to see available command options:

Command (m for help): m

Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Type p to see partition table:

Command (m for help): p

Disk /dev/sda: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 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: 0x000946d2

   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        6528    51915776   8e  Linux LVM

Type n to create a new partition and type for e for extended or p for primary and given partition number 3 [Note: Here two partitions already existed that’s why number is 3]:

Command (m for help): n   

Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (6528-65270, default 6528):
Using default value 6528
Last cylinder, +cylinders or +size{K,M,G} (6528-65270, default 65270):
Using default value 65270

Type t and press enter to create or change partition type and given partition number (here 3) and hex code (here 8e for LVM partition):

Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)

Type p to see change in partition table:

Command (m for help): p

Disk /dev/sda: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 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: 0x000946d2

   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        6528    51915776   8e  Linux LVM
/dev/sda3            6528       65270   471852475   8e  Linux LVM

Finally type w and press enter to write change in the disk and exit from fdisk [Note: If you want quit without saving changes given q command and press enter ]:

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 or after you run partprobe(8) or kpartx(8)
Syncing disks.

 

[root@mahedi-rnd-vm ~]# pvcreate /dev/sda3

  Physical volume "/dev/sda3" successfully created

 

[root@mahedi-rnd-vm ~]# pvs

  PV         VG       Fmt  Attr PSize   PFree 
  /dev/sda2  VolGroup lvm2 a--   49.51g      0
  /dev/sda3           lvm2 a--  449.99g 449.99g

 

[root@mahedi-rnd-vm ~]# vgs

  VG       #PV #LV #SN Attr   VSize  VFree
  VolGroup   1   2   0 wz--n- 49.51g    0

 

[root@mahedi-rnd-vm ~]# vgextend VolGroup /dev/sda3

  Volume group "VolGroup" successfully extended

 

[root@mahedi-rnd-vm ~]# vgs

  VG       #PV #LV #SN Attr   VSize   VFree 
  VolGroup   2   2   0 wz--n- 499.50g 449.99g

 

[root@mahedi-rnd-vm ~]# pvs

  PV         VG       Fmt  Attr PSize   PFree 
  /dev/sda2  VolGroup lvm2 a--   49.51g      0
  /dev/sda3  VolGroup lvm2 a--  449.99g 449.99g

 

[root@mahedi-rnd-vm ~]# vgdisplay

  --- Volume group ---
  VG Name               VolGroup
  System ID            
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               499.50 GiB
  PE Size               4.00 MiB
  Total PE              127872
  Alloc PE / Size       12674 / 49.51 GiB
  Free  PE / Size       115198 / 449.99 GiB
  VG UUID               u2twPp-Tk5E-A7AT-LpYu-gYCC-fGiF-LOcDKr
[root@mahedi-rnd-vm ~]# lvextend -L +100G /dev/mapper/

control           VolGroup-lv_root  VolGroup-lv_swap

 

 

[root@mahedi-rnd-vm ~]# lvextend -L +100G /dev/mapper/VolGroup-lv_root

  Extending logical volume lv_root to 145.63 GiB
  Logical volume lv_root successfully resized

 

[root@mahedi-rnd-vm ~]# resize2fs /dev/VolGroup/lv_root

resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = 3, new_desc_blocks = 10
Performing an on-line resize of /dev/VolGroup/lv_root to 38176768 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 38176768 blocks long.

 

[root@mahedi-rnd-vm ~]# df -H

Filesystem                       Size   Used  Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root     154G   3.7G   143G   3% /
tmpfs                            2.1G   148k   2.1G   1% /dev/shm
/dev/sda1                        508M    39M   443M   9% /boot

 

[root@mahedi-rnd-vm ~]# vgdisplay

  --- Volume group ---
  VG Name               VolGroup
  System ID            
  Format                lvm2
  Metadata Areas        2
  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                2
  Act PV                2
  VG Size               499.50 GiB
  PE Size               4.00 MiB
  Total PE              127872
  Alloc PE / Size       38274 / 149.51 GiB
  Free  PE / Size       89598 / 349.99 GiB
  VG UUID               u2twPp-Tk5E-A7AT-LpYu-gYCC-fGiF-LOcDKr

 

[root@mahedi-rnd-vm ~]# lvcreate -n lv_www -L 200G VolGroup

  Logical volume "lv_www" created

 

[root@mahedi-rnd-vm ~]# mkfs.ext4 /dev/VolGroup/lv_www

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
13107200 inodes, 52428800 blocks
2621440 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1600 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, 1605632, 2654208,
     4096000, 7962624, 11239424, 20480000, 23887872

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

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

 

Facebook Comments

239total visits,1visits today

Leave a Reply

Your email address will not be published. Required fields are marked *