# 执行parted root@iStoreOS:~# parted GNU Parted 3.4 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. # 执行print命令,查看当前分区情况 (parted) print Model: QEMU QEMU HARDDISK (scsi) Disk /dev/sda: 24.0GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags:
Number Start End Size File system Name Flags 128 17.4kB 262kB 245kB bios_grub 1 262kB 134MB 134MB fat16 legacy_boot 2 134MB 403MB 268MB 3 403MB 2550MB 2147MB ext4 4 2551MB 24.0GB 21.5GB primary # 这里对分区3进行扩容,完成后退出 (parted) resizepart Partition number? 3 Warning: Partition /dev/sda3 is being used. Are you sure you want to continue? Yes/No? yes End? [2550MB]? 100% (parted) q Information: You may need to update /etc/fstab. # 执行df -h可以看到分区大小未更新 root@iStoreOS:~# df -h Filesystem Size Used Available Use% Mounted on /dev/root 169.0M 169.0M 0 100% /rom tmpfs 494.1M 5.3M 488.8M 1% /tmp /dev/sda3 1.9G 1.8G 74.2M 96% /overlay overlayfs:/overlay 1.9G 1.8G 74.2M 96% / tmpfs 4.0M 156.0K 3.8M 4% /mnt /dev/sda1 127.7M 5.7M 122.1M 4% /boot /dev/sda1 127.7M 5.7M 122.1M 4% /boot tmpfs 512.0K 0 512.0K 0% /dev tmpfs 512.0K 0 512.0K 0% /sys/module/md_mod/parameters/new_array # 执行resize2fs对文件系统进行扩容 root@iStoreOS:~# resize2fs -p /dev/sda3 resize2fs 1.46.5 (30-Dec-2021) Filesystem at /dev/sda3 is mounted on /overlay; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 3 The filesystem on /dev/sda3 is now 5767168 (4k) blocks long. # 执行df -h可以看到分区大小已经更新 root@iStoreOS:~# df -h Filesystem Size Used Available Use% Mounted on /dev/root 169.0M 169.0M 0 100% /rom tmpfs 494.1M 5.3M 488.8M 1% /tmp /dev/sda3 21.6G 1.8G 19.8G 8% /overlay overlayfs:/overlay 21.6G 1.8G 19.8G 8% / tmpfs 4.0M 156.0K 3.8M 4% /mnt /dev/sda1 127.7M 5.7M 122.1M 4% /boot /dev/sda1 127.7M 5.7M 122.1M 4% /boot tmpfs 512.0K 0 512.0K 0% /dev tmpfs 512.0K 0 512.0K 0% /sys/module/md_mod/parameters/new_array root@iStoreOS:~#