我正在尝试缩小分区以匹配另一个驱动器上另一个分区的大小。我听说我首先必须缩小文件系统才能匹配。我正试图这样做 resize2fs
,但如果我使用的值
cat /proc/partitions
major minor #blocks name
202 0 178257920 xvda
202 1 178249871 xvda1
202 32 47185920 xvdc
202 33 47184896 xvdc1
像这样
ubuntu@asdf:~$ sudo resize2fs /dev/xvda1 47184896
我明白了
resize2fs 1.42.13 (17-May-2015)
The containing partition (or device) is only 44562467 (4k) blocks.
You requested a new size of 47184896 blocks.
使用时我遇到了类似的问题 parted
。
$ sudo parted /dev/xvda
GNU Parted 3.2
Using /dev/xvda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) resizepart 1 94371839
Error: The location 94371839 is outside of the device /dev/xvda.
如果我尝试做 resizepart 1 94371839
对于'/ dev / xvda1' parted
我明白了 Error: The location 94371839 is outside of the device /dev/xvda1.
当它明显位于设备的块范围内时,如图所示
sudo fdisk -l
Disk /dev/xvda: 170 GiB, 182536110080 bytes, 356515840 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
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/xvda1 * 16065 356515806 356499742 170G 83 Linux
这让我疯了。如何获取要使用的文件系统大小和分区大小的正确值 resize2fs
和 parted
?