Create a physical volume on the newly added disk (20GB) and expand the logical volume size of swap and / home by + 10GB.
-Virtualization software: vmware workstation ・ OS: CentOS 6.5
This time, the logical volume size of / swap and / home is expanded, so you can work while the OS is online, but if you want to reduce the logical volume size of / (root), use LIVECD and set it in rescue mode. is needed.
[root@localhost ~]# df -hTP
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-lv_root ext4 37G 3.4G 32G 10% /
tmpfs tmpfs 931M 228K 931M 1% /dev/shm
/dev/sda1 ext4 504M 46M 434M 10% /boot
/dev/mapper/VolGroup01-lv_home ext4 190M 6.4M 174M 4% /home
/dev/sr0 iso9660 4.2G 4.2G 0 100% /media/CentOS_6.5_Final
Disk newly added by sdc (20GB)
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 4.2G 0 rom /media/CentOS_6.5_Final
sr1 11:1 1 1024M 0 rom
sda 8:0 0 40G 0 disk
sda1 8:1 0 512M 0 part /boot
sda2 8:2 0 39.5G 0 part
VolGroup00-lv_root (dm-0) 253:0 0 37.5G 0 lvm /
VolGroup00-lv_swap (dm-1) 253:1 0 2G 0 lvm [SWAP]sdb 8:16 0 20G 0 disk
sdb1 8:17 0 200M 0 part
VolGroup01-lv_home (dm-2) 253:2 0 196M 0 lvm /home
sdc 8:32 0 20G 0 disk
[root@localhost ~]# fdisk -l
disk/dev/sda: 42.9 GB,42949672960 bytes
Head 255,Sector 63,Cylinder 5221
Units =Number of cylinders of 16065* 512 =8225280 bytes
Sector size(logic/Physics):512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disc identifier: 0x00020db8
Device boot start / end block Id system
/dev/sda1 * 1 66 524288 83 Linux
Partition 1 does not end with a cylinder boundary.
/dev/sda2 66 5222 41417728 8e Linux LVM
disk/dev/sdb: 21.5 GB,21474836480 bytes
Head 160,Sector 6,Cylinder 43690
Units =Number of cylinders of 960* 512 =491520 bytes
Sector size(logic/Physics):512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disc identifier: 0x0002c5b0
Device boot start / end block Id system
/dev/sdb1 3 429 204800 8e Linux LVM
disk/dev/sdc: 21.5 GB,21474836480 bytes
Head 255,Sector 63,Cylinder 2610
Units =Number of cylinders of 16065* 512 =8225280 bytes
Sector size(logic/Physics):512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disc identifier: 0x00037b08
Device boot start / end block Id system
disk/dev/mapper/VolGroup00-lv_root: 40.3 GB,40261124096 bytes
Head 255,Sector 63,Cylinder 4894
Units =Number of cylinders of 16065* 512 =8225280 bytes
Sector size(logic/Physics):512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disc identifier: 0x00000000
disk/dev/mapper/VolGroup00-lv_swap: 2147 MB,2147483648 bytes
Head 255,Sector 63,Cylinder 261
Units =Number of cylinders of 16065* 512 =8225280 bytes
Sector size(logic/Physics):512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disc identifier: 0x00000000
disk/dev/mapper/VolGroup01-lv_home: 205 MB,205520896 bytes
Head 255,Sector 63,Cylinder 24
Units =Number of cylinders of 16065* 512 =8225280 bytes
Sector size(logic/Physics):512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disc identifier: 0x00000000
[root@localhost ~]# fdisk /dev/sdc
warning:DOS compatibility mode will be deprecated. This mode(command'c')To stop
Highly recommended. and change display units to
sectors (command 'u').
command(Help with m): m
Command behavior
a Flag the bootable
b bsd Edit the disk label
c dos Add compatibility flag
d Delete the area
l List known area types
m Show this menu
n Create a new area
o Create a new empty DOS region table
p Show area table
q Exit without saving changes
s Create an empty SanDisk label
Change the system ID of the t region
u display/Change item unit
v Collate region tables
w Write the table to disk and exit
x special features(For experts only)
command(Help with m): n
Command action
e-extension
p primary partition(1-4)
p
Partition number(1-4): 1
First cylinder(1-2610,Initial value 1):
Use the initial value 1
Last cylinder, +Number of cylinders or+size{K,M,G} (1-2610,Initial value 2610): +10G
command(Help with m): t
Selected area 1
Hexagon code(Display code list with L command): L
0 Sky 24 NEC DOS 81 Minix/Old bf Solaris
1 FAT12 39 Plan 9 82 Linux swat c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 Hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 41 PPC PReP Boot 85 Linux Extended Region c7 Syrinx
5 Extended area 42 SFS 86 NTFS volume da non-FS day
6 FAT16 4d QNX4.x 87 NTFS volume db CP/M / CTOS / .
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux Play de Dell Ute
8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt
9 AIX boot 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2 Boot 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad eb BeOS fs
e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95 expansion 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC
11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
12 Compaq Diagnosis 61 SpeedStor a9 NetBSD f4 SpeedStor
14 Hidden FAT16<3 63 GNU HURD Also ab Darwin Boo f2 DOS Second
16 Hidden FAT16 64 Novell Netware af HFS/ HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swat fd Linux raid own
1b Hidden W95 FAT3 75 PC/IX bb Hidden Boot Wiz fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris Boo ff BBT
1e Hidden W95 FAT1
Hexagon code(Display code list with L command): 8e
Region system type 1 to 8e(Linux LVM)Changed to
command(Help with m): p
disk/dev/sdc: 21.5 GB,21474836480 bytes
Head 255,Sector 63,Cylinder 2610
Units =Number of cylinders of 16065* 512 =8225280 bytes
Sector size(logic/Physics):512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disc identifier: 0x00037b08
Device boot start / end block Id system
/dev/sdc1 1 1306 10490413+ 8e Linux LVM
command(Help with m): n
Command action
e-extension
p primary partition(1-4)
p
Partition number(1-4): 2
First cylinder(1307-2610,Initial value 1307):
Use the initial value 1307
Last cylinder, +Number of cylinders or+size{K,M,G} (1307-2610,Initial value 2610):
Use the initial value 2610
command(Help with m): t
Partition number(1-4): 2
Hexagon code(Display code list with L command): 8e
Region system type 2 to 8e(Linux LVM)Changed to
command(Help with m): p
disk/dev/sdc: 21.5 GB,21474836480 bytes
Head 255,Sector 63,Cylinder 2610
Units =Number of cylinders of 16065* 512 =8225280 bytes
Sector size(logic/Physics):512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disc identifier: 0x00037b08
Device boot start / end block Id system
/dev/sdc1 1 1306 10490413+ 8e Linux LVM
/dev/sdc2 1307 2610 10474380 8e Linux LVM
command(Help with m): w
The partition table has changed!
ioctl()To reload the partition table.
The disks are syncing.
[root@localhost ~]# pvscan
PV /dev/sdb1 VG VolGroup01 lvm2 [196.00 MiB / 0 free]
PV /dev/sda2 VG VolGroup00 lvm2 [39.50 GiB / 0 free]
Total: 2 [39.69 GiB] / in use: 2 [39.69 GiB] / in no VG: 0 [0 ]
[root@localhost ~]#
[root@localhost ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
[root@localhost ~]# pvcreate /dev/sdc2
Physical volume "/dev/sdc2" successfully created
[root@localhost ~]#
[root@localhost ~]# pvscan
PV /dev/sdb1 VG VolGroup01 lvm2 [196.00 MiB / 0 free]
PV /dev/sda2 VG VolGroup00 lvm2 [39.50 GiB / 0 free]
PV /dev/sdc1 lvm2 [10.00 GiB]
PV /dev/sdc2 lvm2 [9.99 GiB]
Total: 4 [59.68 GiB] / in use: 2 [39.69 GiB] / in no VG: 2 [19.99 GiB]
[root@localhost ~]# vgdisplay -v
Finding all volume groups
Finding volume group "VolGroup01"
--- Volume group ---
VG Name VolGroup01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 196.00 MiB
PE Size 4.00 MiB
Total PE 49
Alloc PE / Size 49 / 196.00 MiB
Free PE / Size 0 / 0
VG UUID QAWvr5-edqd-EYtc-Leo7-0nRW-8S46-31Sg2l
--- Logical volume ---
LV Path /dev/VolGroup01/lv_home
LV Name lv_home
VG Name VolGroup01
LV UUID 8HafSX-cnNI-bz1d-lo2c-L9Nj-IYZq-ibKVKM
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2020-10-11 14:15:41 +0900
LV Status available
# open 1
LV Size 196.00 MiB
Current LE 49
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Physical volumes ---
PV Name /dev/sdb1
PV UUID pGnDqB-jr3Z-BTXr-K2PS-INvP-5DRo-Gj2Uqf
PV Status allocatable
Total PE / Free PE 49 / 0
Finding volume group "VolGroup00"
--- Volume group ---
VG Name VolGroup00
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 39.50 GiB
PE Size 4.00 MiB
Total PE 10111
Alloc PE / Size 10111 / 39.50 GiB
Free PE / Size 0 / 0
VG UUID z9HJFE-UYsB-xLif-pnAb-Th5P-NE2f-d4CVKc
--- Logical volume ---
LV Path /dev/VolGroup00/lv_root
LV Name lv_root
VG Name VolGroup00
LV UUID jY98Rj-yCdd-MWNX-iVZe-OPuH-Hqyc-adjd9T
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2020-10-11 14:15:36 +0900
LV Status available
# open 1
LV Size 37.50 GiB
Current LE 9599
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/VolGroup00/lv_swap
LV Name lv_swap
VG Name VolGroup00
LV UUID 72hHcq-qtUB-SeVK-3BwO-sgde-2is0-95lgZD
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2020-10-11 14:15:41 +0900
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Physical volumes ---
PV Name /dev/sda2
PV UUID diLbku-oX9J-KCct-WYWe-Qt1w-EPlm-VKz2uc
PV Status allocatable
Total PE / Free PE 10111 / 0
[root@localhost ~]#
[root@localhost ~]# vgextend VolGroup00 /dev/sdc1
Volume group "VolGroup00" successfully extended
[root@localhost ~]#
[root@localhost ~]# vgextend VolGroup01 /dev/sdc2
Volume group "VolGroup01" successfully extended
[root@localhost ~]#
[root@localhost ~]# pvscan
PV /dev/sdb1 VG VolGroup01 lvm2 [196.00 MiB / 0 free]
PV /dev/sdc2 VG VolGroup01 lvm2 [9.98 GiB / 9.98 GiB free]
PV /dev/sda2 VG VolGroup00 lvm2 [39.50 GiB / 0 free]
PV /dev/sdc1 VG VolGroup00 lvm2 [10.00 GiB / 10.00 GiB free]
Total: 4 [59.67 GiB] / in use: 4 [59.67 GiB] / in no VG: 0 [0 ]
Allocate free space to lv_swap and lv_home from each VG that has been increased in size by adding a physical volume.
[root@localhost ~]# lvextend -l +100%FREE /dev/VolGroup00/lv_swap
Extending logical volume lv_swap to 12.00 GiB
Logical volume lv_swap successfully resized
[root@localhost ~]#
[root@localhost ~]# lvextend -l +100%FREE /dev/VolGroup01/lv_home
Extending logical volume lv_home to 10.18 GiB
Logical volume lv_home successfully resized
[root@localhost ~]#
[root@localhost ~]# vgdisplay -v
Finding all volume groups
Finding volume group "VolGroup01"
--- Volume group ---
VG Name VolGroup01
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 10.18 GiB
PE Size 4.00 MiB
Total PE 2605
Alloc PE / Size 2605 / 10.18 GiB
Free PE / Size 0 / 0
VG UUID QAWvr5-edqd-EYtc-Leo7-0nRW-8S46-31Sg2l
--- Logical volume ---
LV Path /dev/VolGroup01/lv_home
LV Name lv_home
VG Name VolGroup01
LV UUID 8HafSX-cnNI-bz1d-lo2c-L9Nj-IYZq-ibKVKM
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2020-10-11 14:15:41 +0900
LV Status available
# open 1
LV Size 10.18 GiB
Current LE 2605
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Physical volumes ---
PV Name /dev/sdb1
PV UUID pGnDqB-jr3Z-BTXr-K2PS-INvP-5DRo-Gj2Uqf
PV Status allocatable
Total PE / Free PE 49 / 0
PV Name /dev/sdc2
PV UUID UPwbu0-Cz8w-us7p-sfOv-GET0-orys-ZSAPu8
PV Status allocatable
Total PE / Free PE 2556 / 0
Finding volume group "VolGroup00"
--- Volume group ---
VG Name VolGroup00
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 49.50 GiB
PE Size 4.00 MiB
Total PE 12671
Alloc PE / Size 12671 / 49.50 GiB
Free PE / Size 0 / 0
VG UUID z9HJFE-UYsB-xLif-pnAb-Th5P-NE2f-d4CVKc
--- Logical volume ---
LV Path /dev/VolGroup00/lv_root
LV Name lv_root
VG Name VolGroup00
LV UUID jY98Rj-yCdd-MWNX-iVZe-OPuH-Hqyc-adjd9T
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2020-10-11 14:15:36 +0900
LV Status available
# open 1
LV Size 37.50 GiB
Current LE 9599
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/VolGroup00/lv_swap
LV Name lv_swap
VG Name VolGroup00
LV UUID 72hHcq-qtUB-SeVK-3BwO-sgde-2is0-95lgZD
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2020-10-11 14:15:41 +0900
LV Status available
# open 1
LV Size 12.00 GiB
Current LE 3072
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Physical volumes ---
PV Name /dev/sda2
PV UUID diLbku-oX9J-KCct-WYWe-Qt1w-EPlm-VKz2uc
PV Status allocatable
Total PE / Free PE 10111 / 0
PV Name /dev/sdc1
PV UUID B2lv0h-sEz7-fYQ3-nZel-HTkI-O8jS-gUd7Is
PV Status allocatable
Total PE / Free PE 2560 / 0
[root@localhost ~]#
[root@localhost ~]# lvscan
ACTIVE '/dev/VolGroup01/lv_home' [10.18 GiB] inherit
ACTIVE '/dev/VolGroup00/lv_root' [37.50 GiB] inherit
ACTIVE '/dev/VolGroup00/lv_swap' [12.00 GiB] inherit
[root@localhost ~]#
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 4.2G 0 rom /media/CentOS_6.5_Final
sr1 11:1 1 1024M 0 rom
sda 8:0 0 40G 0 disk
tqsda1 8:1 0 512M 0 part /boot
mqsda2 8:2 0 39.5G 0 part
tqVolGroup00-lv_root (dm-0) 253:0 0 37.5G 0 lvm /
mqVolGroup00-lv_swap (dm-1) 253:1 0 12G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
mqsdb1 8:17 0 200M 0 part
mqVolGroup01-lv_home (dm-2) 253:2 0 10.2G 0 lvm /home
sdc 8:32 0 20G 0 disk
tqsdc1 8:33 0 10G 0 part
x mqVolGroup00-lv_swap (dm-1) 253:1 0 12G 0 lvm [SWAP]
mqsdc2 8:34 0 10G 0 part
mqVolGroup01-lv_home (dm-2) 253:2 0 10.2G 0 lvm /home
[root@localhost ~]# free -m
total used free shared buffers cached
Mem: 1861 526 1335 0 24 179
-/+ buffers/cache: 321 1539
Swap: 2047 0 2047
[root@localhost ~]#
[root@localhost ~]# swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 2097144 0 -1
[root@localhost ~]#
[root@localhost ~]# swapoff /dev/VolGroup00/lv_swap
[root@localhost ~]#
[root@localhost ~]# mkswap /dev/VolGroup00/lv_swap
mkswap: /dev/VolGroup00/lv_swap: warning: don't erase bootbits sectors
on whole disk. Use -f to force.
Set swap space version 1, size= 12582908 KiB
No label, UUID=81e2aa64-c5eb-4247-b705-311fed3e707a
[root@localhost ~]#
[root@localhost ~]# swapon /dev/VolGroup00/lv_swap
[root@localhost ~]#
[root@localhost ~]# swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 12582904 0 -1
[root@localhost ~]#
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 4.2G 0 rom /media/CentOS_6.5_Final
sr1 11:1 1 1024M 0 rom
sda 8:0 0 40G 0 disk
tqsda1 8:1 0 512M 0 part /boot
mqsda2 8:2 0 39.5G 0 part
tqVolGroup00-lv_root (dm-0) 253:0 0 37.5G 0 lvm /
mqVolGroup00-lv_swap (dm-1) 253:1 0 12G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
mqsdb1 8:17 0 200M 0 part
mqVolGroup01-lv_home (dm-2) 253:2 0 10.2G 0 lvm /home
sdc 8:32 0 20G 0 disk
tqsdc1 8:33 0 10G 0 part
x mqVolGroup00-lv_swap (dm-1) 253:1 0 12G 0 lvm [SWAP]
mqsdc2 8:34 0 10G 0 part
mqVolGroup01-lv_home (dm-2) 253:2 0 10.2G 0 lvm /home
[root@localhost ~]#
[root@localhost ~]# free -m
total used free shared buffers cached
Mem: 1861 534 1327 0 24 179
-/+ buffers/cache: 329 1532
Swap: 12287 0 12287
Confirm that the swap area size has been expanded.
[root@localhost ~]# df -hTP
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-lv_root ext4 37G 3.4G 32G 10% /
tmpfs tmpfs 931M 228K 931M 1% /dev/shm
/dev/sda1 ext4 504M 46M 434M 10% /boot
/dev/mapper/VolGroup01-lv_home ext4 190M 6.4M 174M 4% /home
/dev/sr0 iso9660 4.2G 4.2G 0 100% /media/CentOS_6.5_Final
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# resize2fs /dev/VolGroup01/lv_home
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup01/lv_home is mounted on /home; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 41
Performing an on-line resize of /dev/VolGroup01/lv_home to 10670080 (1k) blocks.
The filesystem on /dev/VolGroup01/lv_home is now 10670080 blocks long.
[root@localhost ~]#
[root@localhost ~]# df -hTP
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-lv_root ext4 37G 3.4G 32G 10% /
tmpfs tmpfs 931M 228K 931M 1% /dev/shm
/dev/sda1 ext4 504M 46M 434M 10% /boot
/dev/mapper/VolGroup01-lv_home ext4 9.9G 8.1M 9.4G 1% /home
/dev/sr0 iso9660 4.2G 4.2G 0 100% /media/CentOS_6.5_Final
Confirm that the / home area size has been expanded.
Recommended Posts