GNU/Linux >> Linux の 問題 >  >> Linux

GNU/Linux でパーティションを移動するには?

dd と fdisk による手動の方法:

# fdisk -l /dev/sdb | grep sdb3
/dev/sdb3        73402368  1953525167   940061400   83  Linux

# fdisk /dev/sdb
Command (m for help): d
Partition number (1-4): 3
Command (m for help): n
Partition number (1-4, default 3): 3
First sector (73385984-1953525167, default 73385984): 
Using default value 73385984
Last sector, +sectors or +size{K,M,G} (73385984-1953525167, default 1953525167): 
Using default value 1953525167
Command (m for help): w
The partition table has been altered!

# fdisk -l /dev/sdb | grep sdb3
/dev/sdb3        73385984  1953525167   940069592   83  Linux

# dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 count=100 skip=$((73402368-73385984)) seek=0 2> /dev/null | file -s -
/dev/stdin: LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f

# dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3  skip=$((73402368-73385984)) seek=0 of=/dev/sdb3

# file -s /dev/sdb3
/dev/sdb3: sticky LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f

現在、約 2 時間待っています。 (もっと見ると 18 時間のように見えます...)

注:これはデータを後方に移動するだけで、前方には移動しません。

一時停止:

# pidof dd
907
# kill -STOP 907
# cat /proc/907/fdinfo/1
pos:    586921398272
flags:  0100001

# kill -9 907

remember 586921398272/512 = 1146330856

再開:

dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3  skip=$((1146330856+73402368-73385984)) seek=1146330856 of=/dev/sdb3

sfdisk スクリプト可能な fdisk を意図しており、あるバージョンから --move-data オプション。 man ページの例:

echo '+100M,' | sfdisk --move-data /dev/sdc -N 1

いつでも dd を使用できます .

  • liveCD (またはパーティションがマウントされていないことを確認するその他の方法) から起動
  • dd if=/dev/sdc2 of=somefile bs=1M ファイルにパーティションのコピーを作成します。
  • パーティションを削除するための fdisk (または任意のもの)
  • fdisk (またはお好きなもの) を使用して、目的の場所にパーティションを作成します。
  • dd of=/dev/sdc2 if=somefile bs=1M ファイルからコンテンツを復元します。

Linux
  1. LinuxでGNUPartedを使用してドライブをパーティション分割する

  2. Linuxでディスクをパーティション分割する方法

  3. Linuxでスワップパーティションを管理する方法

  1. Linux でスワップをディスク パーティションから LVM ボリュームに移動する方法

  2. Linux スワップ パーティションを有効にするにはどうすればよいですか?

  3. Linux でスワップ パーティションを変更するにはどうすればよいですか?

  1. Linuxでハードドライブを交換する方法

  2. Linuxでファイルを移動する方法

  3. Linuxでドライブをパーティション分割してフォーマットする方法