如何扩展Linux系统分区大小

brw-rw----. 1 root disk 8, 0 Nov 28 23:34 /dev/sda

brw-rw----. 1 root disk 8, 1 Nov 28 23:34 /dev/sda1

brw-rw----. 1 root disk 8, 2 Nov 28 23:34 /dev/sda2

brw-rw----. 1 root disk 8, 16 Nov 28 23:34 /dev/sdb

在这里插入图片描述

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

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

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.

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0xa1773dc6.

Command (m for help): n

Partition type:

p primary (0 primary, 0 extended, 4 free)

e extended

Select (default p):

Using default response p

Partition number (1-4, default 1): 1

First sector (2048-41943039, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):

Using default value 41943039

Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

[root@rhel76 ~]# ll /dev/sd*

brw-rw----. 1 root disk 8, 0 Nov 28 23:34 /dev/sda

brw-rw----. 1 root disk 8, 1 Nov 28 23:34 /dev/sda1

brw-rw----. 1 root disk 8, 2 Nov 28 23:34 /dev/sda2

brw-rw----. 1 root disk 8, 16 Nov 28 23:49 /dev/sdb

brw-rw----. 1 root disk 8, 17 Nov 28 23:49 /dev/sdb1

[root@rhel76 ~]# fdisk -l | grep dev

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors

/dev/sdb1 2048 41943039 20970496 83 Linux

Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectors

/dev/sda1 * 2048 1953791 975872 83 Linux

/dev/sda2 1953792 125829119 61937664 8e Linux LVM

Disk /dev/mapper/rhel-root: 31.4 GB, 31415336960 bytes, 61358080 sectors

Disk /dev/mapper/rhel-swap: 2000 MB, 2000683008 bytes, 3907584 sectors

Disk /dev/mapper/rhel-u01: 30.0 GB, 30001856512 bytes, 58597376 sectors

在这里插入图片描述

3.创建 PV


[root@rhel76 ~]# pvs

PV VG Fmt Attr PSize PFree

/dev/sda2 rhel lvm2 a-- <59.07g 4.00m

[root@rhel76 ~]# pvcreate /dev/sdb1

Physical volume “/dev/sdb1” successfully created.

[root@rhel76 ~]# pvs

PV VG Fmt Attr PSize PFree

/dev/sda2 rhel lvm2 a-- <59.07g 4.00m

/dev/sdb1 lvm2 — <20.00g <20.00g

4.扩展逻辑卷


[root@rhel76 ~]# vgs

VG #PV #LV #SN Attr VSize VFree

rhel 1 3 0 wz–n- <59.07g 4.00m

[root@rhel76 ~]# vgextend rhel /dev/sdb1

[root@rhel76 ~]# vgextend rhel /dev/sdb1

Volume group “rhel” successfully extended

[root@rhel76 ~]# vgs

VG #PV #LV #SN Attr VSize VFree

rhel 2 3 0 wz–n- 79.06g 20.00g

[root@rhel76 ~]# vgs

VG #PV #LV #SN Attr VSize VFree

jem_vg 1 0 0 wz–n- <20.00g <20.00g

rhel 1 3 0 wz–n- <59.07g 4.00m

[root@rhel76 ~]# lvdisplay

— Logical volume —

LV Path /dev/rhel/root

LV Name root

VG Name rhel

LV UUID fB06rl-92CE-trM6-e2tM-pP4o-6SKt-p03lGC

LV Write Access read/write

LV Creation host, time rhel76, 2021-06-26 22:04:57 +0000

LV Status available

open 1

LV Size <29.26 GiB

Current LE 7490

Segments 1

Allocation inherit

Read ahead sectors auto

  • currently set to 8192

Block device 253:0

[root@rhel76 ~]# lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert

root rhel -wi-ao---- <29.26g

swap rhel -wi-ao---- 1.86g

u01 rhel -wi-ao---- 27.94g

[root@rhel76 ~]# lvextend -L +18G /dev/rhel/root

Size of logical volume rhel/root changed from <29.26 GiB (7490 extents) to <47.26 GiB (12098 extents).

Logical volume rhel/root successfully resized.

使用以下命令刷新lv

[root@rhel76 ~]# xfs_growfs /dev/rhel/root

meta-data=/dev/mapper/rhel-root isize=512 agcount=4, agsize=1917440 blks

= sectsz=512 attr=2, projid32bit=1

= crc=1 finobt=0 spinodes=0

data = bsize=4096 blocks=7669760, imaxpct=25

= sunit=0 swidth=0 blks

naming =version 2 bsize=4096 ascii-ci=0 ftype=1

log =internal bsize=4096 blocks=3745, version=2

= sectsz=512 sunit=0 blks, lazy-count=1

realtime =none extsz=4096 blocks=0, rtextents=0

data blocks changed from 7669760 to 12388352

5.再次确认分区大小


[root@rhel76 ~]# df -TH

Filesystem Type Size Used Avail Use% Mounted on

/dev/mapper/rhel-root xfs 51G 4.4G 47G 9% /

devtmpfs devtmpfs 2.1G 0 2.1G 0% /dev

tmpfs tmpfs 2.1G 0 2.1G 0% /dev/shm

tmpfs tmpfs 2.1G 14M 2.1G 1% /run

tmpfs tmpfs 2.1G 0 2.1G 0% /sys/fs/cgroup

/dev/sda1 xfs 996M 172M 825M 18% /boot

/dev/mapper/rhel-u01 xfs 30G 34M 30G 1% /u01

tmpfs tmpfs 413M 4.1k 413M 1% /run/user/42

tmpfs tmpfs 413M 54k 413M 1% /run/user/0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值