美文网首页
Vmware上扩展linux虚拟机磁盘空间

Vmware上扩展linux虚拟机磁盘空间

作者: FrankZX | 来源:发表于2021-05-02 14:11 被阅读0次

1, 编辑虚拟机设置


image.png

需要删除虚拟机快照才可以进行下一步操作

2, 进入到快照管理器删除快照

3, image.png

4, 点击扩展,等到扩展完成。

5, 开启linux主机,使用fdisk和resize2fs命令

root@test:~# fdisk /dev/sda

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

GPT PMBR size mismatch (46555135 != 85983231) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.

Command (m for help): p

Disk /dev/sda: 41 GiB, 44023414784 bytes, 85983232 sectors
Disk model: VMware Virtual S
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: 995D5226-4890-4236-AD8A-38173B823912

Device     Start      End  Sectors  Size Type
/dev/sda1   2048     4095     2048    1M BIOS boot
/dev/sda2   4096 46553087 46548992 22.2G Linux filesystem

Command (m for help): d
Partition number (1,2, default 2):

Partition 2 has been deleted.

Command (m for help): n
Partition number (2-128, default 2):
First sector (4096-85983198, default 4096):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (4096-85983198, default 85983198):

Created a new partition 2 of type 'Linux filesystem' and of size 41 GiB.
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: N

Command (m for help): w

The partition table has been altered.
Syncing disks.

root@test:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           794M  3.1M  791M   1% /run
/dev/sda2        22G   16G  5.3G  75% /
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop0      100M  100M     0 100% /snap/core/10958
/dev/loop2       55M   55M     0 100% /snap/core18/1754
/dev/loop1       94M   94M     0 100% /snap/core/9066
/dev/loop3       56M   56M     0 100% /snap/core18/1997
/dev/loop4      132M  132M     0 100% /snap/docker/796
/dev/loop6       70M   70M     0 100% /snap/lxd/20211
/dev/loop5      121M  121M     0 100% /snap/docker/423
/dev/loop7       22M   22M     0 100% /snap/keepalived/1962
/dev/loop8       18M   18M     0 100% /snap/keepalived/799
/dev/loop9      209M  209M     0 100% /snap/microk8s/2094
/dev/loop10      28M   28M     0 100% /snap/snapd/7264
/dev/loop11      70M   70M     0 100% /snap/lxd/20222
/dev/loop12      33M   33M     0 100% /snap/snapd/11588
/dev/loop13     181M  181M     0 100% /snap/microk8s/2128
tmpfs           794M     0  794M   0% /run/user/1000
root@test:~# resize2fs /dev/sda2
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 6
The filesystem on /dev/sda2 is now 10747387 (4k) blocks long.

root@test:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           794M  3.1M  791M   1% /run
/dev/sda2        41G   16G   24G  41% /
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop0      100M  100M     0 100% /snap/core/10958
/dev/loop2       55M   55M     0 100% /snap/core18/1754
/dev/loop1       94M   94M     0 100% /snap/core/9066
/dev/loop3       56M   56M     0 100% /snap/core18/1997
/dev/loop4      132M  132M     0 100% /snap/docker/796
/dev/loop6       70M   70M     0 100% /snap/lxd/20211
/dev/loop5      121M  121M     0 100% /snap/docker/423
/dev/loop7       22M   22M     0 100% /snap/keepalived/1962
/dev/loop8       18M   18M     0 100% /snap/keepalived/799
/dev/loop9      209M  209M     0 100% /snap/microk8s/2094
/dev/loop10      28M   28M     0 100% /snap/snapd/7264
/dev/loop11      70M   70M     0 100% /snap/lxd/20222
/dev/loop12      33M   33M     0 100% /snap/snapd/11588
/dev/loop13     181M  181M     0 100% /snap/microk8s/2128
tmpfs           794M     0  794M   0% /run/user/1000

相关文章

网友评论

      本文标题:Vmware上扩展linux虚拟机磁盘空间

      本文链接:https://www.haomeiwen.com/subject/okutdltx.html