web-dev-qa-db-ja.com

GPartedでパーティションイメージのサイズを変更しますか?

以前にGPartedでパーティションのサイズを変更しました。ここで、大きいがほとんど空のパーティションを小さいドライブに移動したいと思います。サイズを変更する代わりに、3番目のドライブ(ddを使用してドライブイメージ)にコピーを作成し、コピーのサイズを変更してから、コピーを新しいドライブにddすることをお勧めします。しかし、Gpartedはドライブイメージで動作するとは思いませんか?どうすればよいですか? GPartedが直接使用するツールを使用できますか?

ああ!または、ループバックを使用して、gpartedが操作できる物理ドライブのようにイメージファイルを表示できますか?

15
endolith

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までサイズを変更できます。

これで、必要に応じてテスト実行を実行できますが、イメージを操作しているため、厳密には必要ありません。 kM、または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.

それでおしまい!これで、そのディスクイメージを新しいデバイスにコピーできます。

3
Patches

5年前の状況はよくわかりませんが、今日はケーキです。

$ Sudo udisksctl loop-setup -f disk.img
Mapped file disk.img as /dev/loop0.
$ Sudo gparted /dev/loop0

これでケーキを食べることができます。

14
user7455651

GPartedで適切なサイズに変更してから、Clonezillaを使用してパーティションを新しいディスクに移動できますか?

0
uSlackr

私はGPartedを何年も使用していて、少しも失うことはありませんでした。私も好きです Easus Windows用の無料のホームエディション。

パーティションの大きさはどれくらいですか?データを失わないように、USB/DVD /無料のオンラインストレージシステムにコピーして、その場でサイズを変更できますか?前述の2つのツールは、完了するまで実行してもデータが失われることはありません。

あなたは言う I've resized partitions in GParted before-では、なぜ今心配しているのですか?そして、DDはビットコピー用のビットを作成します...したがって、とにかくサイズを変更する必要があります(最初にデフラグ)。