
pve环境下kvm虚拟机硬盘root分区无损扩容的方法
pve环境下kvm虚拟机硬盘root分区无损扩容的方法
折腾了两天都没有搞定,搜索了大部分都是复制粘贴和无用的信息
最后,在pve官网文档找到了解决的方法,首先kvm虚拟机的系统分lvm分区
https://pve.proxmox.com/wiki/Resize_disks
系统原始分区信息如下
1
2
3
4
5
6
7
8
9
10
11
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 17.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 7565MB 7564MB primary ext4 boot
2 7567MB 8589MB 1022MB extended
5 7567MB 8589MB 1022MB logical linux-swap(v1) swap
在pve添加了8GB的容量,但是从上面信息可以看到root分区只有7Gb,注意上面的信息显示Boot的为root分区
安装parted分区工具
我们要先删除多余的分区,这里为扩展分区 2
apt-get install parted
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
parted /dev/sda
(parted) p
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 17.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 7565MB 7564MB primary ext4 boot
2 7567MB 8589MB 1022MB extended
5 7567MB 8589MB 1022MB logical linux-swap(v1) swap
#不需要swap分区,所以删除第二分区
rm 2
(parted) p
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 17.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 7565MB 7564MB primary ext4 boot
(parted) resizepart 1 100%
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?
Yes/No? yes
Error: Error informing the kernel about modifications to partition /dev/sda1 -- Device or resource busy. This means Linux won't know about any changes you made to /dev/sda1 until
you reboot -- so you shouldn't mount it or use it in any way before rebooting.
Ignore/Cancel? i
Error: Partition(s) 5 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old
partition(s) will remain in use. You should reboot now before making further changes.
Ignore/Cancel? I
(parted) p
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 17.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 17.2GB 17.2GB primary ext4 boot
(parted) quit
因为我们删除了swap分区,为了防止系统启动时寻找swap分区导致启动时间过长,需要删除swap分区的挂载
vi /etc/fstab.
删除swap分区即可,重启搞定