在 Ubuntu 20.04 上扩展操作系统磁盘

在 Ubuntu 20.04 上扩展操作系统磁盘

我在 Azure 上有一个运行 Ubuntu 20.04 的虚拟机,分区如下所示:

# df -h
Filesystem                   Size  Used Avail Use% Mounted on
udev                         3.9G     0  3.9G   0% /dev
tmpfs                        796M  1.5M  794M   1% /run
/dev/mapper/osencrypt         29G   12G   18G  40% /
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/sda2                    248M  160M   76M  68% /boot
/dev/sdc1                     42M  1.5K   42M   1% /mnt/azure_bek_disk
tmpfs                        200M   14M  187M   7% /var/lib/sss/db
/dev/loop0                    62M   62M     0 100% /snap/core20/1169
/dev/loop1                    68M   68M     0 100% /snap/lxd/21545
/dev/loop2                    33M   33M     0 100% /snap/snapd/13640
/dev/sda15                   105M  5.2M  100M   5% /boot/efi
/dev/mapper/resourceencrypt   16G   45M   15G   1% /mnt/resource
tmpfs                        796M     0  796M   0% /run/user/1962704655

我想将操作系统磁盘从29G扩展到300G。在Azure门户上我已经完成了更改:

在此输入图像描述

这在虚拟机上已经可见:

# lsblk -o NAME,HCTL,SIZE,MOUNTPOINT
NAME                HCTL        SIZE MOUNTPOINT
loop0                          61.9M /snap/core20/1169
loop1                          67.3M /snap/lxd/21545
loop2                          32.5M /snap/snapd/13640
sda                 0:0:0:0     300G
├─sda1                         29.7G
│ └─osencrypt                  29.7G /
├─sda2                          256M /boot
├─sda14                           4M
└─sda15                         106M /boot/efi
sdb                 0:0:0:1      16G
└─sdb1                           16G
  └─resourceencrypt              16G /mnt/resource
sdc                 0:0:0:3      48M
└─sdc1                           46M /mnt/azure_bek_disk
sdd                 1:0:0:0       1T

parted我对使用命令调整分区大小有点困惑:

# sudo parted /dev/mapper/osencrypt resizepart 1 300G
Warning: Partition /dev/mapper/osencrypt is being used. Are you sure you want to continue?
Yes/No? yes
End?  [31.8GB]?
Information: You may need to update /etc/fstab.

resize2fs没有帮助:

# sudo resize2fs /dev/mapper/osencrypt 300G
resize2fs 1.45.5 (07-Jan-2020)
The containing partition (or device) is only 7770619 (4k) blocks.
You requested a new size of 78643200 blocks.

相关内容