PVE linux_VM partition expansion

Adjust the size of the disk page

 

Manual partitioning

fdisk -l

 

fdisk / dev / sda the disk partition, 
type n and press Enter, n is the " new new " New Partition

[root @ localhost ~] # fdisk / dev / sda
Welcome fdisk (util-linux 2.23.2).

 
 

Change will stay in memory until you decide to write the changes to disk.
Please think twice before using the write command.

 
 


Command (input m to get help): n-
the Partition type:
P Primary (2 Primary, Extended 0, 2 Free)
E Extended
the Select (default P): P
partition number (3,4, 3 by default): 3
start sector ( 629145600-1069547519, default 629 145 600):
the default value 629 145 600
Last sector, sector + or + size {K, M, G} (629145600-1069547519, 1069547519 default):
the default value 1069547519
partition 3 is provided for Linux type, size to 210 GiB

Command (input m to get help): W
of The Partition Table Altered has been!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
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)
正在同步磁盘。

 

 By partx tools allow the kernel reread partition table

partx -d / dev / sda // there because the kernel is not part of the adjustment disk information, it first clears all the information 
partx -a / dev / sda // add disk partition information after adjustment 
partx -s / dev / sda // it displays the disk partition information

  # See if the kernel has to recognize the new partition:

cat /proc/partitions

 

 

 

Expansion 

New partitions to create physical volumes: Volume expansion, add LVM group

pvcreate / dev sda3 initialization just partition /
[root@localhost ~]# pvcreate  /dev/sda3
  Physical volume "/dev/sda3" successfully created.
[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  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               299.80 GiB
  PE Size               4.00 MiB
  Total PE              76749
  Alloc PE / Size       76749 / 299.80 GiB
  Free  PE / Size       0 / 0   
  VG UUID               i3fy1h-quuU-JJ9g-Gdfu-cNW9-KsW1-u72oi4
查看卷组,并将初始化的分区加入到虚拟卷组
为卷组vg_root添加新的物理卷sda3增加卷组的容量
 

[root@localhost ~]# vgextend centos /dev/sda3
Volume group "centos" successfully extended

扩展逻辑卷的大小

[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 300G 57G 243G 19% /
devtmpfs 25G 0 25G 0% /dev
tmpfs 25G 0 25G 0% /dev/shm
tmpfs 25G 8.6M 25G 1% /run
tmpfs 25G 0 25G 0% /sys/fs/cgroup
/dev/sda1 197M 123M 74M 63% /boot
tmpfs 4.9G 0 4.9G 0% /run/user/0


[root@localhost ~]# lvextend -l +100%FREE /dev/mapper/centos-root
Size of logical volume centos/root changed from 299.80 GiB (76749 extents) to <509.80 GiB (130508 extents).
Logical volume centos/root successfully resized.

 

#xfs用以下命令来扩磁盘空间:

[root@localhost ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=19647744 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=78590976, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=38374, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 78590976 to 133640192

[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 510G 57G 453G 12% /
devtmpfs 25G 0 25G 0% /dev
tmpfs 25G 0 25G 0% /dev/shm
tmpfs 25G 8.6M 25G 1% /run
tmpfs 25G 0 25G 0% /sys/fs/cgroup
/dev/sda1 197M 123M 74M 63% /boot
tmpfs 4.9G 0 4.9G 0% /run/user/0

 

QA:

 

[root@localhost ~]# resize2fs -p /dev/mapper/centos-root 
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block 当尝试打开 /dev/mapper/centos-root 时
找不到有效的文件系统超级块.
[root@localhost ~]# df -T
文件系统                类型         1K-块    已用      可用 已用% 挂载点
/dev/mapper/centos-root xfs      314210408 1092908 313117500    1% / devtmpfs devtmpfs 25666376 0 25666376 0% /dev tmpfs tmpfs 25678444 0 25678444 0% /dev/shm tmpfs tmpfs 25678444 8708 25669736 1% /run tmpfs tmpfs 25678444 0 25678444 0% /sys/fs/cgroup /dev/sda1 xfs 201380 125880 75500 63% /boot tmpfs tmpfs 5135692 0 5135692 0% /run/user/0

 

Guess you like

Origin www.cnblogs.com/qianchilang/p/11956701.html