vmware中ubuntu虚拟机扩容

vmware中ubuntu虚拟机扩容

  1. Vmware添加磁盘空间

WX20231123-143534@2x.png
  1. 查看需要挂载的硬盘

    [root@elk2 ~]# fdisk -l
    GPT PMBR size mismatch (41943039 != 52428799) will be corrected by write.
    Disk /dev/nvme0n1: 25 GiB, 26843545600 bytes, 52428800 sectors
    Disk model: VMware Virtual NVMe Disk
    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: 66881C31-AF40-44F7-B83D-E31E1C2D3919
    
    Device           Start      End  Sectors  Size Type
    /dev/nvme0n1p1    2048  1953791  1951744  953M EFI System
    /dev/nvme0n1p2 1953792  5668863  3715072  1.8G Linux filesystem
    /dev/nvme0n1p3 5668864 41940991 36272128 17.3G Linux filesystem
    
    
    Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 17 GiB, 18253611008 bytes, 35651584 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
    
  2. 可以看到增加的5G磁盘还未分区

    [root@elk2 ~]# fdisk /dev/nvme0n1
    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.
    
    
    Command (m for help): n
    Partition number (4-128, default 4):
    First sector (41940992-52428766, default 41940992):
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (41940992-52428766, default 52428766):
    
    Created a new partition 4 of type 'Linux filesystem' and of size 5 GiB.
    
    Command (m for help): wq
    The partition table has been altered.
    Syncing disks
    
  3. 查看磁盘分区情况

    [root@elk2 ~]# fdisk -l
    Disk /dev/nvme0n1: 25 GiB, 26843545600 bytes, 52428800 sectors
    Disk model: VMware Virtual NVMe Disk
    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: 66881C31-AF40-44F7-B83D-E31E1C2D3919
    
    Device            Start      End  Sectors  Size Type
    /dev/nvme0n1p1     2048  1953791  1951744  953M EFI System
    /dev/nvme0n1p2  1953792  5668863  3715072  1.8G Linux filesystem
    /dev/nvme0n1p3  5668864 41940991 36272128 17.3G Linux filesystem
    /dev/nvme0n1p4 41940992 52428766 10487775    5G Linux filesystem
    
    
    Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 17 GiB, 18253611008 bytes, 35651584 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
    
  4. 查看LVM(Logical Volume Manager,逻辑卷管理器)中逻辑卷(Logical Volumes)的信息

    [root@elk2 ~]# lvs
      LV        VG        Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      ubuntu-lv ubuntu-vg -wi-ao---- 17.00g
    
  5. 向LVM的卷组添加物理卷

    [root@elk2 ~]# vgextend ubuntu-vg /dev/nvme0n1p4
    Physical volume "/dev/nvme0n1p4" successfully created.
      Volume group "ubuntu-vg" successfully extended
    
  6. 扩展逻辑卷

    [root@elk2 ~]# lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv /dev/nvme0n1p4
      Size of logical volume ubuntu-vg/ubuntu-lv changed from 17.00 GiB (4352 extents) to <22.00 GiB (5631 extents).
      Logical volume ubuntu-vg/ubuntu-lv successfully resized.
    
  7. 刷新逻辑卷

    [root@elk2 ~]# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
    resize2fs 1.45.5 (07-Jan-2020)
    Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
    old_desc_blocks = 3, new_desc_blocks = 3
    The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 5766144 (4k) blocks long.
    
  8. 查看磁盘使用情况

    [root@elk2 ~]# df -h
    Filesystem                         Size  Used Avail Use% Mounted on
    udev                               1.9G     0  1.9G   0% /dev
    tmpfs                              392M  1.3M  391M   1% /run
    /dev/mapper/ubuntu--vg-ubuntu--lv   22G  8.9G   12G  43% /
    tmpfs                              2.0G     0  2.0G   0% /dev/shm
    tmpfs                              5.0M     0  5.0M   0% /run/lock
    tmpfs                              2.0G     0  2.0G   0% /sys/fs/cgroup
    /dev/nvme0n1p2                     1.8G  206M  1.5G  13% /boot
    /dev/loop0                          60M   60M     0 100% /snap/core20/1627
    /dev/nvme0n1p1                     952M  6.0M  946M   1% /boot/efi
    /dev/loop1                          62M   62M     0 100% /snap/lxd/22761
    /dev/loop2                          92M   92M     0 100% /snap/lxd/24065
    /dev/loop3                          36M   36M     0 100% /snap/snapd/20298
    /dev/loop5                          60M   60M     0 100% /snap/core20/2019
    /dev/loop4                          47M   47M     0 100% /snap/snapd/19459
    tmpfs                              392M     0  392M   0% /run/user/0
    
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容