kamal@192.168.10.140's password:
Last login: Mon Dec 10 22:35:38 2018 from 192.168.10.2
[kamal@ipa ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 8.0G 4.4G 3.7G 55% /
devtmpfs 903M 0 903M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 22M 898M 3% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/sda1 497M 212M 286M 43% /boot
tmpfs 184M 4.0K 184M 1% /run/user/42
tmpfs 184M 44K 184M 1% /run/user/1000
tmpfs 184M 0 184M 0% /run/user/0
[kamal@ipa ~]$ su -
Password:
Last login: Mon Dec 10 22:35:52 EST 2018 on pts/1
[root@ipa ~]# fdisk -l
Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 22013951 10493952 8e Linux LVM
Disk /dev/mapper/centos-root: 8589 MB, 8589934592 bytes, 16777216 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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
[root@ipa ~]# fdisk /dev/sda
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): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p):
Using default response p
Partition number (3,4, default 3):
First sector (22013952-33554431, default 22013952):
Using default value 22013952
Last sector, +sectors or +size{K,M,G} (22013952-33554431, default 33554431): $
Last sector, +sectors or +size{K,M,G} (22013952-33554431, default 33554431):
Using default value 33554431
Partition 3 of type Linux and of size 5.5 GiB is set
Command (m for help): p
Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 22013951 10493952 8e Linux LVM
/dev/sda3 22013952 33554431 5770240 83 Linux
Command (m for help): t
Partition number (1-3, default 3):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 22013951 10493952 8e Linux LVM
/dev/sda3 22013952 33554431 5770240 8e Linux LVM
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@ipa ~]# partprobe -s
/dev/sda: msdos partitions 1 2 3
[root@ipa ~]# echo "If it does not work, you can use partx"
If it does not work, you can use partx
[root@ipa ~]# partx -v -a /dev/sda
partition: none, disk: /dev/sda, lower: 0, upper: 0
/dev/sda: partition table type 'dos' detected
partx: /dev/sda: adding partition #1 failed: Device or resource busy
partx: /dev/sda: adding partition #2 failed: Device or resource busy
partx: /dev/sda: adding partition #3 failed: Device or resource busy
partx: /dev/sda: error adding partitions 1-3
[root@ipa ~]# fdisk -l
Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 22013951 10493952 8e Linux LVM
/dev/sda3 22013952 33554431 5770240 8e Linux LVM
Disk /dev/mapper/centos-root: 8589 MB, 8589934592 bytes, 16777216 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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
[root@ipa ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created.
[root@ipa ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- 10.00g 4.00m
[root@ipa ~]# vgextend centos /dev/sda3
Couldn't create temporary archive name.
[root@ipa ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- 10.00g 4.00m
[root@ipa ~]# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 8.0G 4.8G 3.3G 60% /
[root@ipa ~]# vgextend centos /dev/sda3
Volume group "centos" successfully extended
[root@ipa ~]# pvscan
PV /dev/sda2 VG centos lvm2 [10.00 GiB / 4.00 MiB free]
PV /dev/sda3 VG centos lvm2 [5.50 GiB / 5.50 GiB free]
Total: 2 [15.50 GiB] / in use: 2 [15.50 GiB] / in no VG: 0 [0 ]
[root@ipa ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 2 2 0 wz--n- 15.50g 5.50g
[root@ipa ~]# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 8.0G 4.9G 3.2G 61% /
[root@ipa ~]# xfs_info /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=524288 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=2097152, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@ipa ~]# echo "now, extend your logical volume using whole partition, rather then specifyting particular size"
now, extend your logical volume using whole partition, rather then specifyting particular size
[root@ipa ~]# lvextend /dev/mapper/centos-root /dev/sda3
Size of logical volume centos/root changed from 8.00 GiB (2048 extents) to 13.50 GiB (3456 extents).
Logical volume centos/root successfully resized.
[root@ipa ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 13.50g
swap centos -wi-ao---- 2.00g
[root@ipa ~]# lvscan
ACTIVE '/dev/centos/root' [13.50 GiB] inherit
ACTIVE '/dev/centos/swap' [2.00 GiB] inherit
[root@ipa ~]# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 8.0G 4.9G 3.2G 62% /
[root@ipa ~]# echo "You just extended LVM, now you have to extend xfs filessytem"
You just extended LVM, now you have to extend xfs filessytem
[root@ipa ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=524288 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=2097152, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2097152 to 3538944
[root@ipa ~]# echo "It says data blocks changed from 2097152 to 3538944"
It says data blocks changed from 2097152 to 3538944
[root@ipa ~]# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 14G 5.0G 8.6G 37% /
[root@ipa ~]#
Last login: Mon Dec 10 22:35:38 2018 from 192.168.10.2
[kamal@ipa ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 8.0G 4.4G 3.7G 55% /
devtmpfs 903M 0 903M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 22M 898M 3% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/sda1 497M 212M 286M 43% /boot
tmpfs 184M 4.0K 184M 1% /run/user/42
tmpfs 184M 44K 184M 1% /run/user/1000
tmpfs 184M 0 184M 0% /run/user/0
[kamal@ipa ~]$ su -
Password:
Last login: Mon Dec 10 22:35:52 EST 2018 on pts/1
[root@ipa ~]# fdisk -l
Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 22013951 10493952 8e Linux LVM
Disk /dev/mapper/centos-root: 8589 MB, 8589934592 bytes, 16777216 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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
[root@ipa ~]# fdisk /dev/sda
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): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p):
Using default response p
Partition number (3,4, default 3):
First sector (22013952-33554431, default 22013952):
Using default value 22013952
Last sector, +sectors or +size{K,M,G} (22013952-33554431, default 33554431): $
Last sector, +sectors or +size{K,M,G} (22013952-33554431, default 33554431):
Using default value 33554431
Partition 3 of type Linux and of size 5.5 GiB is set
Command (m for help): p
Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 22013951 10493952 8e Linux LVM
/dev/sda3 22013952 33554431 5770240 83 Linux
Command (m for help): t
Partition number (1-3, default 3):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 22013951 10493952 8e Linux LVM
/dev/sda3 22013952 33554431 5770240 8e Linux LVM
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@ipa ~]# partprobe -s
/dev/sda: msdos partitions 1 2 3
[root@ipa ~]# echo "If it does not work, you can use partx"
If it does not work, you can use partx
[root@ipa ~]# partx -v -a /dev/sda
partition: none, disk: /dev/sda, lower: 0, upper: 0
/dev/sda: partition table type 'dos' detected
partx: /dev/sda: adding partition #1 failed: Device or resource busy
partx: /dev/sda: adding partition #2 failed: Device or resource busy
partx: /dev/sda: adding partition #3 failed: Device or resource busy
partx: /dev/sda: error adding partitions 1-3
[root@ipa ~]# fdisk -l
Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 22013951 10493952 8e Linux LVM
/dev/sda3 22013952 33554431 5770240 8e Linux LVM
Disk /dev/mapper/centos-root: 8589 MB, 8589934592 bytes, 16777216 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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
[root@ipa ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created.
[root@ipa ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- 10.00g 4.00m
[root@ipa ~]# vgextend centos /dev/sda3
Couldn't create temporary archive name.
[root@ipa ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- 10.00g 4.00m
[root@ipa ~]# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 8.0G 4.8G 3.3G 60% /
[root@ipa ~]# vgextend centos /dev/sda3
Volume group "centos" successfully extended
[root@ipa ~]# pvscan
PV /dev/sda2 VG centos lvm2 [10.00 GiB / 4.00 MiB free]
PV /dev/sda3 VG centos lvm2 [5.50 GiB / 5.50 GiB free]
Total: 2 [15.50 GiB] / in use: 2 [15.50 GiB] / in no VG: 0 [0 ]
[root@ipa ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 2 2 0 wz--n- 15.50g 5.50g
[root@ipa ~]# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 8.0G 4.9G 3.2G 61% /
[root@ipa ~]# xfs_info /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=524288 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=2097152, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@ipa ~]# echo "now, extend your logical volume using whole partition, rather then specifyting particular size"
now, extend your logical volume using whole partition, rather then specifyting particular size
[root@ipa ~]# lvextend /dev/mapper/centos-root /dev/sda3
Size of logical volume centos/root changed from 8.00 GiB (2048 extents) to 13.50 GiB (3456 extents).
Logical volume centos/root successfully resized.
[root@ipa ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 13.50g
swap centos -wi-ao---- 2.00g
[root@ipa ~]# lvscan
ACTIVE '/dev/centos/root' [13.50 GiB] inherit
ACTIVE '/dev/centos/swap' [2.00 GiB] inherit
[root@ipa ~]# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 8.0G 4.9G 3.2G 62% /
[root@ipa ~]# echo "You just extended LVM, now you have to extend xfs filessytem"
You just extended LVM, now you have to extend xfs filessytem
[root@ipa ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=524288 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=2097152, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2097152 to 3538944
[root@ipa ~]# echo "It says data blocks changed from 2097152 to 3538944"
It says data blocks changed from 2097152 to 3538944
[root@ipa ~]# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 14G 5.0G 8.6G 37% /
[root@ipa ~]#
No comments:
Post a Comment