![Linux VM 中可调整大小的磁盘分区](https://linux22.com/image/740403/Linux%20VM%20%E4%B8%AD%E5%8F%AF%E8%B0%83%E6%95%B4%E5%A4%A7%E5%B0%8F%E7%9A%84%E7%A3%81%E7%9B%98%E5%88%86%E5%8C%BA.png)
我正在尝试增加虚拟机 Ubuntu 中的磁盘大小。我使用了以下命令序列:
echo 1 > /sys/block/sda/device/rescan
fdisk /dev/sda
Command (m for help): d
Partition number (1,2, default 2): 2
Command (m for help): n
Select (default p): p
现在我看到以下内容:parted
root@proj:~# parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 85,9GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 85,9GB 85,9GB ext4
(parted)
磁盘管理
root@proj:~# fdisk /dev/sda
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 615AE39E-D8BF-41FC-823C-99CDF4CBAEDF
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 167772126 167768031 80G Linux filesystem
Command (m for help):
我使用 Webmin 来管理我的服务器,重新启动后它继续显示:
Mounted As Type Free Total Device ID
/ ext4 41% (15.70 GB) 38.37 GB UUID=1f76306d-c5e9-45d8-ae14-923bb1114c16
Local disk space 22.67 GB used / 15.70 GB free / 38.37 GB total
我对这些问题还不熟悉,请帮我理解一下,我的错误是什么?
答案1
扩大分区是使空间可供操作系统使用的必要步骤,但还不够。您还需要修改文件系统中的元数据,这是使分区中的原始空间可用于存储文件、目录、权限等的算法。
根据提供的详细信息,您最有可能需要运行的命令是
resize2fs /dev/sda2