Answers:
您无法使用GParted执行此操作,但是可以ntfsresize
直接在磁盘映像上使用该命令。
首先,克隆磁盘映像。您可以使用blkid
或gParted 查找磁盘设备名称,然后运行:
sudo dd if=<disk device> of=<image file>
例如:
$ sudo dd if=/dev/sda2 of=disk.img
1000000+0 records in
1000000+0 records out
512000000 bytes (512 MB) copied, 9.33361 s, 54.9 MB/s
然后,验证是否可以通过运行以下命令将其调整为所需的大小:
ntfsresize -i <image file>
例如:
$ ntfsresize -i disk.img
ntfsresize v2011.4.12 (libntfs-3g)
Device name : disk.img
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 511996416 bytes (512 MB)
Current device size: 512000000 bytes (512 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use : 4 MB (0.6%)
Collecting resizing constraints ...
You might resize at 3035136 bytes or 4 MB (freeing 508 MB).
Please make a test run using both the -n and -s options before real resizing!
在此示例中,我可以将大小一直减小到4MB,因为我只是制作了一个空白磁盘映像用于说明!
现在,您可以根据需要进行测试运行,尽管由于在图像上进行操作,这不是严格必需的。您可以通过附加指定千字节,兆字节或千兆字节大小k
,M
或者G
,分别为:
ntfsresize -cnvs <size> <image file>
例如:
$ ntfsresize -cnvs 256M disk.img
ntfsresize v2011.4.12 (libntfs-3g)
没有输出就是好的输出!现在真正做到:
ntfsresize -vs <size> <image file>
最后一个例子:
$ ntfsresize -vs 256M disk.img
ntfsresize v2011.4.12 (libntfs-3g)
Device name : disk.img
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 511996416 bytes (512 MB)
Current device size: 512000000 bytes (512 MB)
New volume size : 255996416 bytes (256 MB)
Checking for bad sectors ...
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use : 4 MB (0.6%)
Collecting resizing constraints ...
Needed relocations : 625 (3 MB)
WARNING: Every sanity check passed and only the dangerous operations left.
Make sure that important data has been backed up! Power outage or computer
crash may result major data loss!
Are you sure you want to proceed (y/[n])? y
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Relocating needed data ...
Relocate record 1:0x80:00000001:0x00000000:0x0000f423 --> 0x00007a11
Relocate record 2:0x80:00000624:0x00000000:0x0000f424 --> 0x00007a12
100.00 percent completed
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
Syncing device ...
Successfully resized NTFS on device 'disk.img'.
You can go on to shrink the device for example with Linux fdisk.
IMPORTANT: When recreating the partition, make sure that you
1) create it at the same disk sector (use sector as the unit!)
2) create it with the same partition type (usually 7, HPFS/NTFS)
3) do not make it smaller than the new NTFS filesystem size
4) set the bootable flag for the partition if it existed before
Otherwise you won't be able to access NTFS or can't boot from the disk!
If you make a mistake and don't have a partition table backup then you
can recover the partition table by TestDisk or Parted's rescue mode.
而已!现在,您可以将该磁盘映像复制到新设备。
dd
逻辑分区。如果您做了扩展分区,您将在其中获得所有逻辑分区!
dd
扩展分区会带来额外的信息,这些信息会使e2fsprogs
和混淆ntfsprogs
。正如您先前所发现的,他们对分区一无所知。
我使用GParted已有很多年了,而且从没有失去过一点。我也喜欢Windows的Easus免费家庭版。
您的分区大小是多少?您可以将数据复制到USB / DVD /免费的在线存储系统中,以免丢失数据-然后调整大小吗?如果您让上述两个工具运行完毕,它们将不会丢失数据。
你说I've resized partitions in GParted before
-那么为什么现在担心呢?而且DD会有点复制...所以无论如何您都必须调整大小(首先进行碎片整理)。