双机备份下Centocs7 扩到根电脑分区

  1. 查看分区大小和挂载情况 用到的命令df、lsblk

[root@localhost ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/centos-root 99G 96G 3.9G 97% /

devtmpfs 3.8G 0 3.8G 0% /dev

tmpfs 3.9G 33M 3.8G 1% /dev/shm

tmpfs 3.9G 27M 3.8G 1% /run

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

/dev/vda1 1014M 189M 826M 19% /boot

tmpfs 6.4G 0 6.4G 0% /run/user/0

[root@localhost ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

fd0 2:0 1 4K 0 disk

sr0 11:0 1 1024M 0 rom

vda 252:0 0 200G 0 disk

├─vda1 252:1 0 1G 0 part /boot

└─vda2 252:2 0 99G 0 part

└─centos-root 253:0 0 99G 0 lvm /

双机备份下Centocs7 扩到根电脑分区

  1. 又原来的100G 调整虚拟机磁盘为200G 直接调整。

双机备份下Centocs7 扩到根电脑分区

  1. 创建分区

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): p

Disk /dev/vda: 214.7 GB, 214748364800 bytes, 419430400 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: 0x000a727a

Device Boot Start End Blocks Id System

/dev/vda1 * 2048 2099199 1048576 83 Linux

/dev/vda2 2099200 209715199 103808000 8e Linux LVM

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): 3

First sector (209715200-419430399, default 209715200):

Using default value 209715200

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

Using default value 419430399

Partition 3 of type Linux and of size 100 GiB is set

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 ~]#

双机备份下Centocs7 扩到根电脑分区

  1. 刷新分区并创建物理卷

[root@localhost ~]# partprobe /dev/vda

[root@localhost ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

fd0 2:0 1 4K 0 disk

sr0 11:0 1 1024M 0 rom

vda 252:0 0 200G 0 disk

├─vda1 252:1 0 1G 0 part /boot

├─vda2 252:2 0 99G 0 part

│ └─centos-root 253:0 0 99G 0 lvm /

└─vda3 252:3 0 100G 0 part

[root@localhost ~]# partprobe /dev/vda3

  1. 查看卷组名称,以及卷组使用情况

[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 <99.00 GiB

PE Size 4.00 MiB

Total PE 25343

Alloc PE / Size 25343 / <99.00 GiB

Free PE / Size 0 / 0

VG UUID wEdhD1-PJnZ-gSBB-ZE4X-pMKK-Obor-b7JnO2

6.扩展卷组

[root@localhost ~]# vgextend centos /dev/vda3

Physical volume "/dev/vda3" successfully created.

Volume group "centos" successfully extended

7.查看当前逻辑卷

[root@localhost ~]# lvdisplay

--- Logical volume ---

LV Path /dev/centos/root

LV Name root

VG Name centos

LV UUID q9mens-Ujcs-Kgzq-Gbtd-gEdF-D6x7-Oa3GmP

LV Write Access read/write

LV Creation host, time localhost, 2020-01-13 11:17:40 +0800

LV Status available

# open 1

LV Size <99.00 GiB

Current LE 25343

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 8192

Block device 253:0

8.将“VG Name centos”卷组中的空闲空间扩展到根分区逻辑卷

[root@localhost ~]# lvextend -l +100%FREE /dev/centos/root

Size of logical volume centos/root changed from <99.00 GiB (25343 extents) to 198.99 GiB (50942 extents).

Logical volume centos/root successfully resized.

9.刷新根分区

[root@localhost ~]# xfs_growfs /dev/centos/root

meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=6487808 blks

= sectsz=512 attr=2, projid32bit=1

= crc=1 finobt=0 spinodes=0

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

= sunit=0 swidth=0 blks

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

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

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

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

data blocks changed from 25951232 to 52164608

双机备份下Centocs7 扩到根电脑分区

以上是 双机备份下Centocs7 扩到根电脑分区 的全部内容, 来源链接: utcz.com/a/64644.html

回到顶部