Advertisement
v1ral_ITS

Terminal DD COMPLETE cp/.img/backup.bootloader etc..

Apr 10th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.12 KB | None | 0 0
  1.  
  2. Data transfer forms of dd
  3.  
  4. blocks=$(isosize -d 2048 /dev/sr0)
  5. dd if=/dev/sr0 of=isoimage.iso bs=2048 count=$blocks status=progress
  6.  
  7.     Creates an ISO disk image
  8. from a CD-ROM, DVD or Blu-ray disk.[8]
  9.  
  10. dd if=system.img of=/dev/sdc bs=4096 conv=noerror
  11.  
  12.     Restores a hard disk drive
  13. (or an SD card, for example)
  14. from a previously created image.
  15.  
  16. dd if=/dev/sda2 of=/dev/sdb2 bs=4096 conv=noerror
  17.  
  18.     Clones one partition to another.
  19.  
  20. dd if=/dev/ad0 of=/dev/ad1 bs=1M conv=noerror
  21.  
  22.     Clones a hard disk drive "ad0" to "ad1".
  23.  
  24. Master boot record backup and restore
  25.  
  26. It is possible to repair a master boot record. It can be transferred to and from a repair file.
  27.  
  28. To duplicate the first two sectors of a floppy drive:
  29.  
  30. dd if=/dev/fd0 of=MBRboot.img bs=512 count=2
  31.  
  32. To create an image of the entire x86 master boot record (including a MS-DOS partition table and MBR magic bytes):
  33.  
  34. dd if=/dev/sda of=MBR.img bs=512 count=1
  35.  
  36. To create an image of only the boot code of the master boot record (without the partition table and without the magic bytes required for booting):
  37.  
  38. dd if=/dev/sda of=MBR_boot.img bs=446 count=1
  39.  
  40. Data modification
  41.  
  42. dd can modify data in place. For example, this overwrites the first 512 bytes of a file with null bytes:
  43.  
  44. dd if=/dev/zero of=path/to/file bs=512 count=1 conv=notrunc
  45.  
  46. The notrunc conversion option means do not truncate the output file — that is, if the output file already exists, just replace the specified bytes and leave the rest of the output file alone. Without this option, dd would create an output file 512 bytes long.
  47.  
  48. To duplicate a disk partition as a disk image file on a different partition:
  49.  
  50. dd if=/dev/sdb2 of=partition.image bs=4096 conv=noerror
  51.  
  52. Disk wipe
  53. Main article: Data erasure
  54.  
  55. For security reasons, it is sometimes necessary to have a disk wipe of a discarded device.
  56.  
  57. To wipe a disk by writing zeros to it, dd can be used this way:
  58.  
  59. dd if=/dev/zero of=/dev/sda bs=16M
  60.  
  61. Another approach could be to wipe a disk by writing random data to it:
  62.  
  63. dd if=/dev/urandom of=/dev/sda bs=16M
  64.  
  65. When compared to the data modification example above, notrunc conversion option is not required as it has no effect when the dd's output file is a block device.[9]
  66.  
  67. The bs=16M option makes dd read and write 16 Mebibytes at a time. For modern systems, an even greater block size may be faster. Note that filling the drive with random data may take longer than zeroing the drive, because the random data must be created by the CPU, while creating zeroes is very fast. On modern hard-disk drives, zeroing the drive will render most data it contains permanently irrecoverable.[10] However, with other kinds of drives such as flash memories, much data may still be recoverable by special laboratory techniques.[citation needed]
  68.  
  69. Modern hard disk drives contain a Secure Erase command designed to permanently and securely erase every accessible and inaccessible portion of a drive. It may also work for some Solid-state drives (flash drives). As of 2017, it does not work on USB flash drives nor on Secure Digital flash memories.[citation needed] When available, this is both faster than using dd, and more secure.[citation needed] On Linux machines it is accessible via the hdparm command's --security-erase-enhanced option.
  70.  
  71. The shred program offers multiple overwrites as well as more-secure deletion of individual files.
  72.  
  73. Data recovery
  74.  
  75. The early history of open-source software for data recovery and restoration of files, drives and partitions included the GNU dd, whose copyright notice starts in 1985,[11] with one block size per dd process, and no recovery algorithm other than the user's interactive session running one form of dd after another. Then, a C program called dd_rescue[12] was written in October 1999, having two block sizes in its algorithm. However, the author of the 2003 shell script dd_rhelp, which enhances dd_rescue's data recovery algorithm, recommends GNU ddrescue,[13][14] a data recovery program unrelated to dd that was initially released in 2004.
  76.  
  77. To help distinguish the newer GNU program from the older script, alternate names are sometimes used for GNU's ddrescue, including addrescue (the name on freecode.com and freshmeat.net), gddrescue (Debian package name), and gnu_ddrescue (openSUSE package name). Another open-source program called savehd7 uses a sophisticated algorithm, but it also requires the installation of its own programming-language interpreter.
  78. Benchmarking drive performance
  79.  
  80. To make drive benchmark test and analyze the sequential (and usually single-threaded) system read and write performance for 1024-byte blocks:
  81.  
  82. dd if=/dev/zero bs=1024 count=1000000 of=file_1GB
  83. dd if=file_1GB of=/dev/null bs=1024
  84.  
  85. Generating a file with random data
  86.  
  87. To make a file of 100 random bytes using the kernel random driver:
  88.  
  89. dd if=/dev/urandom of=myrandom bs=100 count=1
  90.  
  91. Converting a file to upper case
  92.  
  93. To convert a file to uppercase:
  94.  
  95. dd if=filename of=filename1 conv=ucase,notrunc
  96.  
  97. Limitations
  98.  
  99. As stated in a part of documentation provided by Seagate, "certain disc utilities, such as DD, which depend on low-level disc access may not support 48-bit LBAs until they are updated".[15][citation needed] Using ATA hard disk drives over 128 GiB in size requires system support 48-bit LBA; however, in Linux, dd uses the kernel to read or write to raw device files instead of accessing hardware directly.[b] At the same time, support for 48-bit LBA has been present since version 2.4.23 of the kernel, released in 2003.[16][17]
  100. Dcfldd
  101.  
  102. dcfldd is a fork of dd that is an enhanced version developed by Nick Harbour, who at the time was working for the United States' Department of Defense Computer Forensics Lab.[18][19][20] Compared to dd, dcfldd allows for more than one output file, supports simultaneous multiple checksum calculations, provides a verification mode for file matching, and can display the percentage progress of an operation.
  103. See also
  104.  
  105.     Free software portal Information technology portal
  106.  
  107.     Backup
  108.     Disk cloning
  109.     Disk Copy
  110.     Disk image
  111.     .img (filename extension)
  112.     List of Unix programs
  113.     ddrescue a GNU version that copies data from corrupted files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement