ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

ARM环境上 openEuler扩展根盘并扩展到根分区中

2026/8/13 17:17:19 拓冰建站 浏览量
ARM环境上 openEuler扩展根盘并扩展到根分区中

虚拟化平台中在线直接把磁盘40G扩展到100G,系统中无法识别,需要先关闭开机器后才可以识别到是100G

[root@openeuler ~]# uname -m
aarch64

[root@openeuler ~]# more /etc/os-release 
NAME="openEuler"
VERSION="22.03 (LTS-SP4)"
ID="openEuler"
VERSION_ID="22.03"
PRETTY_NAME="openEuler 22.03 (LTS-SP4)"
ANSI_COLOR="0;31"
[root@openeuler ~]#  vgs
VG        #PV #LV #SN Attr   VSize  VFree
openeuler   1   2   0 wz--n- 38.41g    0 
[root@openeuler ~]# lvdisplay 
--- Logical volume ---
LV Path                /dev/openeuler/root
LV Name                root
VG Name                openeuler
LV UUID                rHuEgp-5lpI-HYIc-6sCg-ht7i-UmF8-okp27I
LV Write Access        read/write
LV Creation host, time openeuler, 2024-12-01 23:48:52 +0800
LV Status              available
# open                 1
LV Size                22.41 GiB
Current LE             5737
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     8192
Block device           253:0

--- Logical volume ---
LV Path                /dev/openeuler/swap
LV Name                swap
VG Name                openeuler
LV UUID                sicsoy-TJMe-Nayq-br09-696r-7c6w-grPVkH
LV Write Access        read/write
LV Creation host, time openeuler, 2024-12-01 23:48:53 +0800
LV Status              available
# open                 2
LV Size                16.00 GiB
Current LE             4096
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     8192
Block device           253:1

[root@openeuler ~]#  fdisk -l /dev/vda   --查看磁盘大小及磁盘格式
GPT PMBR size mismatch (83886079 != 209715199) will be corrected by write.
The backup GPT table is not on the end of the device.
Disk /dev/vda: 100 GiB, 107374182400 bytes, 209715200 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
Disklabel type: gpt
Disk identifier: 6B1A02AA-01E2-4BBA-8BB0-D3F524D83E2F

Device        Start      End  Sectors  Size Type
/dev/vda1      2048  1230847  1228800  600M EFI System
/dev/vda2   1230848 81786879 80556032 38.4G Linux LVM
/dev/vda3  81786880 83884031  2097152    1G Linux filesystem
[root@openeuler ~]# parted /dev/vda    --因是gpt格式磁盘,建议使用parted分区
GNU Parted 3.5
Using /dev/vda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Warning: Not all of the space available to /dev/vda appears to be used, you can fix the GPT to use all of the space (an extra 125829120 blocks) or continue with the current
setting? 
Fix/Ignore? Fix       --这里必须是Fix,选择Ignore分区无效                           
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  Flags
1      1049kB  630MB   629MB   fat32        EFI System Partition  boot, esp
2      630MB   41.9GB  41.2GB                                     lvm
3      41.9GB  42.9GB  1074MB  xfs

(parted) mkpart                                                           
Partition name?  []?                                                      
File system type?  [ext2]? xfs
Start? 42.9GB                                                             
End? 107GB
(parted) p                                                                
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  Flags
1      1049kB  630MB   629MB   fat32        EFI System Partition  boot, esp
2      630MB   41.9GB  41.2GB                                     lvm
3      41.9GB  42.9GB  1074MB  xfs
4      42.9GB  107GB   64.4GB  xfs

(parted) q                                                                
Information: You may need to update /etc/fstab.

[root@openeuler ~]# vgextend openeuler /dev/vda4
Physical volume "/dev/vda4" successfully created.
Volume group "openeuler" successfully extended
[root@openeuler ~]# vgs
VG        #PV #LV #SN Attr   VSize   VFree  
openeuler   2   2   0 wz--n- <98.41g <60.00g
[root@openeuler ~]# df -h
Filesystem                  Size  Used Avail Use% Mounted on
devtmpfs                    4.0M     0  4.0M   0% /dev
tmpfs                        16G     0   16G   0% /dev/shm
tmpfs                       6.1G  9.3M  6.1G   1% /run
tmpfs                       4.0M     0  4.0M   0% /sys/fs/cgroup
/dev/mapper/openeuler-root   23G  2.3G   21G  10% /
tmpfs                        16G     0   16G   0% /tmp
/dev/vda3                  1014M  156M  859M  16% /boot
/dev/vda1                   599M  6.5M  593M   2% /boot/efi

[root@openeuler ~]# xfs_info /dev/mapper/openeuler-root
meta-data=/dev/mapper/openeuler-root isize=512    agcount=4, agsize=1468672 blks
=                       sectsz=512   attr=2, projid32bit=1
=                       crc=1        finobt=1, sparse=1, rmapbt=0
=                       reflink=1    bigtime=1 inobtcount=0
data     =                       bsize=4096   blocks=5874688, imaxpct=25
=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2868, version=2
=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@openeuler ~]# 

[root@openeuler ~]# lvextend -l +100%FREE /dev/mapper/openeuler-root
Size of logical volume openeuler/root changed from 22.41 GiB (5737 extents) to <82.41 GiB (21096 extents).
Logical volume openeuler/root successfully resized.
[root@openeuler ~]#  xfs_growfs /dev/mapper/openeuler-root
meta-data=/dev/mapper/openeuler-root isize=512    agcount=4, agsize=1468672 blks
=                       sectsz=512   attr=2, projid32bit=1
=                       crc=1        finobt=1, sparse=1, rmapbt=0
=                       reflink=1    bigtime=1 inobtcount=0
data     =                       bsize=4096   blocks=5874688, imaxpct=25
=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2868, version=2
=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 5874688 to 21602304
[root@openeuler ~]# df -h
Filesystem                  Size  Used Avail Use% Mounted on
devtmpfs                    4.0M     0  4.0M   0% /dev
tmpfs                        16G     0   16G   0% /dev/shm
tmpfs                       6.1G  9.3M  6.1G   1% /run
tmpfs                       4.0M     0  4.0M   0% /sys/fs/cgroup
/dev/mapper/openeuler-root   83G  2.7G   80G   4% /
tmpfs                        16G     0   16G   0% /tmp
/dev/vda3                  1014M  156M  859M  16% /boot
/dev/vda1                   599M  6.5M  593M   2% /boot/efi
[root@openeuler ~]#