Linux给根目录扩容

需求:Linux系统挂载到根目录的磁盘空间满了,如何扩容?
一、添加磁盘并分区

[root@cdn ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xf1212eee.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p):

Using default response p.
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943039, default 41943039): +10G

Created a new partition 1 of type 'Linux' and of size 10 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

二、创建pv

[root@cdn ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.

三、将原vg扩容

[root@localhost ~]# vgextend bigcloud-enterprise-linux-for-euler /dev/sda4
  Volume group "bigcloud-enterprise-linux-for-euler" successfully extended

四、扩容pv

[root@localhost ~]# lvextend -L 60G /dev/bigcloud-enterprise-linux-for-euler/root
  Size of logical volume bigcloud-enterprise-linux-for-euler/root changed from 20.91 GiB (5353 extents) to 60.00 GiB (15360 

extents).
  Logical volume bigcloud-enterprise-linux-for-euler/root successfully resized.

五、格式化

[root@localhost ~]# resize2fs /dev/mapper/bigcloud--enterprise--linux--for--euler-root
resize2fs 1.45.6 (20-Mar-2020)
Filesystem at /dev/mapper/openeuler-root is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 8
The filesystem on /dev/mapper/bigcloud--enterprise--linux--for--euler-root is now 15728640 (4k) blocks long.
#使用xfs_growfs命令扩展xfs文件系统,如果是ext4文件系统,则使用resize2fs  /dev/mysql/lv_data 

六、检查

[root@localhost ~]# lsblk

你可能感兴趣的:(linux,lvm)