16 LVM growing lvs vgs fdisk /dev/sdb partprobe

FS->LV->VG->PVolume

Extend operation
In order to extend the file system
First we need to create a new physical volume
next assign PV to VG.
grow LV from VG, then FS

Reduce FS size
vice-verse
first resize FS, then LV, VG and PV

-----------
[root@localhost /]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/cl-root         17G  4.7G   13G  28% /
devtmpfs                   480M     0  480M   0% /dev
tmpfs                      493M   96K  493M   1% /dev/shm
tmpfs                      493M   20M  473M   4% /run
tmpfs                      493M     0  493M   0% /sys/fs/cgroup
/dev/sda1                 1014M  188M  827M  19% /boot
tmpfs                       99M   48K   99M   1% /run/user/1000
/dev/mapper/vgmyvg-lvmylv   93M  1.6M   87M   2% /mnt
[root@localhost /]#

if you want to make filesystem bigger, order in which to do this should be considered.


Filesystem seats on top of Logical volume

[root@localhost /]# lvs
File descriptor 22 (socket:[27108]) leaked on lvs invocation. Parent PID 3225: -bash
  LV     VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   cl     -wi-ao---- 17.00g                                                    
  swap   cl     -wi-ao----  2.00g                                                    
  lvmylv vgmyvg -wi-ao---- 96.00m                                                    
[root@localhost /]# 

If we want to increase, we need available size in Volume group
[root@localhost /]# vgs
File descriptor 22 (socket:[27108]) leaked on vgs invocation. Parent PID 3225: -bash
  VG     #PV #LV #SN Attr   VSize  VFree
  cl       1   2   0 wz--n- 19.00g    0 
  vgmyvg   1   1   0 wz--n- 96.00m    0 
[root@localhost /]# 

=====================
[root@localhost /]# fdisk /dev/sdb 
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/sdb: 4294 MB, 4294967296 bytes, 8388608 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: 0xc0ee42ab

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb3          206848      411647      102400   8e  Linux LVM

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): e
Partition number (2,4, default 2): 
First sector (411648-8388607, default 411648): 
Using default value 411648
Last sector, +sectors or +size{K,M,G} (411648-8388607, default 8388607): 
Using default value 8388607
Partition 2 of type Extended and of size 3.8 GiB is set


Command (m for help):
Partition type:
   p   primary (2 primary, 1 extended, 1 free)
   l   logical (numbered from 5)
Select (default p): 1(L)
Adding logical partition 5
First sector (413696-8388607, default 413696): 
Using default value 413696
Last sector, +sectors or +size{K,M,G} (413696-8388607, default 8388607): +100M
Partition 5 of type Linux and of size 100 MiB is set

Command (m for help): p

Disk /dev/sdb: 4294 MB, 4294967296 bytes, 8388608 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: 0xc0ee42ab

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          411648     8388607     3988480    5  Extended
/dev/sdb3          206848      411647      102400   8e  Linux LVM
/dev/sdb5          413696      618495      102400   83  Linux

Partition table entries are not in disk order



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@localhost /]# partprobe
[root@localhost /]# 

partprobe is a program that informs the operating system kernel of partition table changes, by requesting that the operating system re-read the partition table.

let;s resize VG

[root@localhost /]# vgextend --help
File descriptor 22 (socket:[27108]) leaked on vgextend invocation. Parent PID 3225: -bash
  vgextend: Add physical volumes to a volume group

vgextend
        [-A|--autobackup y|n]
        [--restoremissing]
        [--commandprofile ProfileName]
        [-d|--debug]
        [-f|--force]
        [-h|--help]
        [--reportformat {basic|json}]
        [-t|--test]
        [-v|--verbose]
        [--version]
        [-y|--yes]
        [ PHYSICAL DEVICE OPTIONS ]
        VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]

[root@localhost /]# 


[root@localhost /]# vgextend vgmyvg /dev/sdb5
File descriptor 22 (socket:[27108]) leaked on vgextend invocation. Parent PID 3225: -bash
  Physical volume "/dev/sdb5" successfully created.
  Volume group "vgmyvg" successfully extended
[root@localhost /]# 


[root@localhost /]# lvextend --help 
File descriptor 22 (socket:[27108]) leaked on lvextend invocation. Parent PID 3225: -bash
  lvextend: Add space to a logical volume

lvextend
        [-A|--autobackup y|n]
        [--alloc AllocationPolicy]
        [--commandprofile ProfileName]
        [-d|--debug]
        [-f|--force]
        [-h|--help]
        [-i|--stripes Stripes [-I|--stripesize StripeSize]]
        {-l|--extents [+]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}] |
         -L|--size [+]LogicalVolumeSize[bBsSkKmMgGtTpPeE]}
         --poolmetadatasize [+]MetadataVolumeSize[bBsSkKmMgG]}
        [-m|--mirrors Mirrors]
        [--nosync]
        [--use-policies]
        [-n|--nofsck]
        [--noudevsync]
        [--reportformat {basic|json}]
        [-r|--resizefs]
        [-t|--test]
        [--type VolumeType]
        [-v|--verbose]
        [--version]
        LogicalVolume[Path] [ PhysicalVolumePath... ]

[root@localhost /]# 



[root@localhost /]# lvextend -l +100%FREE -r /dev/vgmyvg/lvmylv
-r -resize filesystem as well. extend both file system and logical volume in 1 step

File descriptor 22 (socket:[27108]) leaked on lvextend invocation. Parent PID 3225: -bash
  Size of logical volume vgmyvg/lvmylv changed from 96.00 MiB (24 extents) to 192.00 MiB (48 extents).
  Logical volume vgmyvg/lvmylv successfully resized.
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mapper/vgmyvg-lvmylv is mounted on /mnt; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mapper/vgmyvg-lvmylv is now 196608 blocks long.

[root@localhost /]# 

[root@localhost /]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/cl-root         17G  4.7G   13G  28% /
devtmpfs                   480M     0  480M   0% /dev
tmpfs                      493M   96K  493M   1% /dev/shm
tmpfs                      493M   20M  473M   4% /run
tmpfs                      493M     0  493M   0% /sys/fs/cgroup
/dev/sda1                 1014M  188M  827M  19% /boot
tmpfs                       99M   48K   99M   1% /run/user/1000
/dev/mapper/vgmyvg-lvmylv  186M  1.6M  176M   1% /mnt
tmpfs                       99M     0   99M   0% /run/user/0
[root@localhost /]# 


Comments

Popular posts from this blog

HAproxy logging

teamcity Automatic Agent Start under Linux

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all