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

Linux での dd コマンドの例

dd コマンドは、ファイルをコピーして変換し、あるタイプのメディアから別のタイプのメディアにファイルを転送できるようにします。 dd コマンドには、実行するさまざまなオペランドまたはアクションがあります。

オペランド 慣れている
if={ファイル名} データを読み取るファイルを指定します。
of={ファイル名} データが書き込まれるファイルを指定します。
bs={bytes} 読み書きする合計ブロック サイズをバイト単位で指定します。バイトは、50 メガバイトを指定する 50M や 10 ギガバイトを指定する 10G など、より人間に優しい方法でフォーマットすることもできます。
count={blocks} 入力ファイルから出力ファイルに書き込むブロック数を指定します。
ステータス={レベル} 標準エラーに出力する情報のレベルを指定します - なし エラー メッセージ以外のすべてを非表示にするには、noxfer 合計転送統計を抑制するには、progress 転送統計を定期的に表示します。

構文

dd コマンドの構文は次のとおりです。

# dd [options] [operands]

バックアップに dd を使用する

dd を使用して、ストレージ パーティションの完全バックアップを実行できます。次の例では、データを /dev/sda1 から /dev/sdb2 にコピーします:

# dd if=/dev/sda of=/dev/sdb

dd を使用して、ドライブのイメージを作成し、それを使用して 2 つ目のドライブのクローンを作成することもできます:

# dd if=/dev/sda of=drive_image.iso 
# dd if=drive_image.iso of=/dev/sdb

dd コマンドの例

1. ファイルをコピーするには:

# dd if=old.txt of=old.txt 

2. ファイルの指定されたバイトを一度に読み書きするには:

# dd bs=1024 if=old.txt of=old.txt 

3. ファイルを指定した形式に変換するには:

# dd bs=1024 if=old.txt of=new.txt conv=ascii (from EBCDIC to ASCII)
# dd bs=1024 if=old.txt of=new.txt conv=ebcdic (from ASCII to EBCDIC)
# dd bs=1024 if=old.txt of=new.txt conv=ibm  (from ASCII to alternate EBCDIC)
# dd bs=1024 if=old.txt of=new.txt conv=block    (pad oldline-terminated records with spaces to cbs-size)
# dd bs=1024 if=old.txt of=new.txt conv=unblock (replace trailing spaces in cbs-size records with oldline)
# dd bs=1024 if=old.txt of=new.txt conv=lcase  (change upper case to lower case)
# dd bs=1024 if=old.txt of=new.txt conv=excl  (fail if the output old already exists)
# dd bs=1024 if=old.txt of=new.txt conv=notrunc   (do not truncate the output old)
# dd bs=1024 if=old.txt of=new.txt conv=ucase    (change lower case to upper case)
# dd bs=1024 if=old.txt of=new.txt conv=swab     (swap every pair of input bytes)
# dd bs=1024 if=old.txt of=new.txt conv=noerror  (continue after read errors)
# dd bs=1024 if=old.txt of=new.txt conv=sync    (pad  every  input  block  with  NULs to ibs-size)
# dd bs=1024 if=old.txt of=new.txt conv=fdatasync  (physically write output old data before finishing)
# dd bs=1024 if=old.txt of=new.txt conv=fsync  (likewise, but also write metadata) 

4. 指定した数のブロックのみをコピーするには:

# dd count=1024 if=old.txt of=new.txt 

5. フラグを指定してファイルをコピーするには:

# dd if=old.txt of=new.txt oflag=append
# dd if=old.txt iflag=directory of=new.txt oflag=directory
# dd if=old.txt iflag=noatime of=new.txt oflag=append 

6. 一度に指定されたバイトを変換するには:

# dd cbs=1024 if=old.txt of=new.txt  

7. 一度に指定されたバイト数を読み取るには:

# dd ibs=1024 if=old.txt of=new.txt  

8. 一度に指定したバイト数を書き込むには:

# dd obs=1024 if=old.txt of=new.txt

9. o/p の開始時に指定された数のブロックをスキップするには:

# dd seek=1024 if=old.txt of=new.txt 

10. i/p の開始時に指定された数のブロックをスキップするには:

# dd skip=1024 if=old.txt of=new.txt 

11.転送統計を抑制するには:

# dd status=noxfer if=old.txt of=new.txt 

12. デバイスのパーティション テーブルを消去するには:

# dd if=/dev/zero of=/dev/sda4 bs=512 count=1 


Linux
  1. Linux での rm コマンドの例

  2. Linux での ps コマンドの例

  3. Linux での join コマンドの例

  1. LinuxでのTouchコマンドの10の実用例

  2. 7 Linux df コマンドの例

  3. w Linux でのコマンド例

  1. 8 Linux TR コマンドの例

  2. Linux での sa コマンドの例

  3. Linux での ac コマンドの例