linux根目录扩展
扩展之前查下硬盘的状态
开始扩容操作
[root@localhost ~]# fdisk /dev/vda
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
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)
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3):
First sector (83886080-629145599, default 83886080):
Using default value 83886080
Last sector, +sectors or +size{K,M,G} (83886080-629145599, default 629145599):
Using default value 629145599
Partition 3 of type Linux and of size 260 GiB is set
Command (m for help): t
Partition number (1-3, default 3): 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/vda: 322.1 GB, 322122547200 bytes, 629145600 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: 0x00060768
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 1026047 512000 83 Linux
/dev/vda2 1026048 83886079 41430016 8e Linux LVM
/dev/vda3 83886080 629145599 272629760 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@localhost ~]# partprobe /dev/vda --刷新磁盘
[root@localhost ~]# ls -l /dev/vda3
brw-rw----. 1 root disk 252, 3 Apr 10 10:34 /dev/vda3
[root@localhost ~]# pvcreate /dev/vda3
Physical volume "/dev/vda3" successfully created
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/vda2
VG Name centos
PV Size 39.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 10114
Free PE 11
Allocated PE 10103
PV UUID pg9zD3-QWYE-RZXc-uLOM-SfQk-VURD-d6Wr9l
"/dev/vda3" is a new physical volume of "260.00 GiB"
--- NEW Physical volume ---
PV Name /dev/vda3
VG Name
PV Size 260.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID ra2snJ-YcDL-euab-hhxl-qJOo-NIHR-Bqnf3W
[root@localhost ~]# vgextend centos /dev/vda3
Volume group "centos" successfully extended
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name centos
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 299.50 GiB
PE Size 4.00 MiB
Total PE 76673
Alloc PE / Size 10103 / 39.46 GiB
Free PE / Size 66570 / 260.04 GiB
VG UUID Ag6kw7-SS2G-7oUn-2HQj-quZR-uzPl-HZuJm4
lvextend -l +100%FREE /dev/mapper/centos-root
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID bbhfDd-Hp4e-CP0E-fhB6-ZahD-wnzA-oA3oKt
LV Write Access read/write
LV Creation host, time localhost, 2020-04-09 14:56:05 +0800
LV Status available
# open 2
LV Size 3.88 GiB
Current LE 992
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID X8f5Yb-IfY2-iYVI-zNSm-IiDU-AewJ-weKW1b
LV Write Access read/write
LV Creation host, time localhost, 2020-04-09 14:56:06 +0800
LV Status available
# open 1
LV Size 35.59 GiB
Current LE 9111
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
resize2fs /dev/mapper/centos-root --(7之前)
xfs_growfs /dev/mapper/centos-root --(centos7)