Menu
Is free
check in
home  /  the Internet / Creating a hard disk image using the DD utility. How to record an ISO image of a distribution on a flash drive from the terminal in Unuuntu and DD DD Copying

Creating a hard disk image using the DD utility. How to record an ISO image of a distribution on a flash drive from the terminal in Unuuntu and DD DD Copying

Be careful because when the flash drive name is error in the DD command, you can damage the Host Winchester.

We will withdraw the designation of the sections of all devices

and find among them a flash drive:

Sudo FDISK -U -L / DEV / SD?

Also, to determine sections on all devices, you can use the command:

Sudo Cat / Proc / Partitions

DD command syntax

DD if \u003d / aaaa of \u003d / bbbb bs \u003d CCCC Count \u003d DDDD CONV \u003d NOERROR
  • if: (Input File) indicates the source, i.e. On where you copy. The file that can be both the usual file and the device file is indicated.
  • of.: (Output File) Specifies the destination file. The same, we can write both in an ordinary file and directly into the device.
  • bS.: The number of bytes that will be recorded at a time. That is, the size of a piece of data that will be read and recorded at a time. it is recommended to put BS \u003d the size of the Kesh Winchester i. 8m 16m 32m.
  • count: how many pieces bS. will be copied.
  • cONV: Allows you to connect filters applicable to data stream. Filter "NOERROR" Just turns off the program stopping when it hits the read error.

Examples

Full disk erasure

So that nothing can be restored on the carrier - you can score with zeros, this team will always end the mistake "on the carrier ended the place"

DD if \u003d / dev / zero of \u003d / dev / sdx

Creating a disk image

DD if \u003d / dev / cdrom of \u003d image.iso conv \u003d noerror

you can also log in

Mount -o Loop /PathToimageFile/image.iso / MNT / FOLDERMOUNT

If something does not work, the process is divided into 2 levels:

LOSETUP -E / DEV / LOOP0 /PathToimageFile/image.iso Mount / Dev / Loop0 / MNT / Foldermount

Operations with MBR

MBR is located in the first 512 bytes hard disk, and consists of a partition table, bootloader and pair extra. byte. Sometimes, it has to backgame, restore it, etc. Backup is performed like this:

DD if \u003d / dev / sda of \u003d mbr.img bs \u003d 512 count \u003d 1

It is possible to restore it is easier:

DD if \u003d MBR.img of \u003d / dev / sda

Copy with archiving

(Using GZIP) data from a flash drive on the hard drive.

Dd if \u003d / dev / sdx conv \u003d sync, noerror bs \u003d 8m | gzip -c\u003e /pathtosave/sdx.img.gz

and back

Gunzip -C /PathThtofile/sdx.img.gz | DD OF \u003d / DEV / SDX CONV \u003d SYNC, NOERROR BS \u003d 8M

Copy over the network

dd if \u003d / dev / sdx conv \u003d sync, noerror bs \u003d 8m | SSH -C Blowfish [Email Protected] "dd of \u003d sdx.img.gz bs \u003d 8m"

and back

Dd if \u003d sdx.img.gz | SSH -C Blowfish [Email Protected] "DD OF \u003d / DEV / SDX BS \u003d 8M"

The DD command performs only one simple feature: copies the data from the file to another file. But since in Linux, many essences are presented as files, and DD applications becomes a lot. Consider the most useful of them.

What does DD mean?

dD is a reduction from Data Duplicator (Copying Data). But due to the fact that in inept hands, the DD command can lead to a complete loss of all data, the program is often a joke called Disk Destroyer (disk destroyer). We will try to figure out how not only not to destroy their data, but even even benefit from the use of DD.

Total DD use case

The syntax of the team is as follows:

DD if \u003d $ Input_Data OF \u003d $ Output_Data

The command copies the data from the $ input_data file to the $ OUTPUT_DATA file, given the Option options. It would seem simple. Now consider what opportunities opens this simple copying.

Examples of using DD.

1. The destruction of all data on the disk without the possibility of recovery:

DD if \u003d / dev / urandom of \u003d / dev / sda bs \u003d 4k

2. Full tolete copying of one disk to another (cloning):

DD if \u003d / dev / sda of \u003d / dev / sdb bs \u003d 4096

3. Copying one section in another:

Dd if \u003d / dev / sda3 of \u003d / dev / sdb3 bs \u003d 4096 conv \u003d notrunc, noerror

4. Displays the list of available file systems:

DD If \u003d / Proc / Filesystems | Hexdump -C | less

5. Copying data on devices with different block size (1kb of the source and 2 KB at the receiver):

DD if \u003d / dev / st0 IBS \u003d 1024 OBS \u003d 2048 OF \u003d / DEV / ST1

6. Create a bootable flash drive:

Dd if \u003d / home / $ user / bootimage.img of \u003d / dev / sdc

7. Check the disk on failure sectors:

DD if \u003d / dev / sda of \u003d / dev / null bs \u003d 1m

8. Creation backup MBR Disc. and saving on a diskette

DD if \u003d / dev / sda of \u003d / dev / fd0 bs \u003d 512 count \u003d 1

9. Removal image of ISO. From CD:

DD if \u003d / dev / sr0 of \u003d / home / $ user / mycdimage.iso bs \u003d 2048 conv \u003d nosync

10. Checking the file for viruses (of course, ClamAV will need):

Dd if \u003d / home / $ user / suspicious.doc | clamscan -

11. Saving the contents of RAM to the file:

DD if \u003d / dev / mem of \u003d / home / $ user / mem.bin bs \u003d 1024

12. Conversion of the image from Nero NRG format to the standard ISO image:

DD BS \u003d 1K if \u003d imagefile.nrg of \u003d imagefile.iso Skip \u003d 300K

13. Viewing the contents of the MBR:

DD if \u003d / dev / sda count \u003d 1 | Hexdump -C.

And where is the promised million applications?

The supervisory reader is likely to notice that the article lists not a million useful applications, and somewhat less. But the power of the DD program is that the other applications can be found independently by combining different files as if, of IF, of and selecting the options. Just do not forget that work with DD requires increased attention. If you do not know exactly what actions will be completed, it is better to refrain from experiments. Try not to give DD superuser rights when you can do without these rights.

In the comments with joy, your own examples of using this wonderful program are accepted.

& NBSP & NBSP Rufus. - FREE software with open source code To format removable USB data carriers and creating boot disks with different operating systems. The program is easy to use, high speed and maintains a multilingual interface.

You can download the program on the developer's website. The page contains links to download the standard version. Rufus., and transferred Rufus Portablewhich no longer differ except the name of the executable file and the storage location of the settings. The program settings include the language and update check parameters used. Standard version stores these parameters in the registry, and the tolerant - in the file rufus.ini Programs catalog. Rufus. Does not require installation in the system - just download the executable file and run it. The program interface is very simple:

In general, the program Rufus. It is not something unique in the field of means to create bootable media and its main advantage is easy to use. In order to create a bootable flash drive with its help, it is enough to have the source image of the loaded system and be able to click on the "Start" button. All selectable parameters and settings are already calculated by the use of a standard configuration program to work on a computer.

Most simple and convenient to use Rufus. To create a loading flash drive ( boot USB disk) from ISO-images of installation windows disks or Linux, as well as disks of emergency restoration of the system and diagnostic tools.

When creating a bootable flash drive, it is enough to select the device to which the ISO image boot file will be completed. Other parameters The program will substitute itself.

If there is no file with the ISO file, it can be created on the basis of a physical CD (or from a distribution kit) using CD / DVD recording programs, such as known Nero, Alcohol, or freely distributed CDBurnerXP or imgburn.

The order of creating a bootable flash drive with Windows is as follows:

  • Select a flash drive to which the image will be recorded. Unlike many similar programs, RUFUS displays the volume label, the drive letter and its volume, so if there are multiple removable discs in the system, it is easy to select the one to which entry will be performed.

  • Select a section and type scheme system interface. RUFUS allows you to create flash drives to download in the conventional BIOS interface and to download in the UEFI environment, create boot records for MBR volumes and GPT volumes. By default, "MBR for computers with BIOS or UEFI" mode is received - the most common mode for loading flash drives today.

  • Select a file system that will be used on the bootable flash drive. By default, the file system is used for bootable flash drives. FAT32.but if necessary, you can choose NTFSIf you want to use files of more than 4 GB.

  • Set cluster size. The cluster size is selected by the program based on the image and type data. file SystemBut if necessary, it can be changed.

  • Specify the volume label that will be specified for the flash drive created.

  • Set formatting parameters. These parameters are best to leave by default and simply select the ISO image file. For images created by the program dD in Linux, you need to select a parameter DD-image.

    After pressing the button Start The program will format a flash drive, establishes a sign of an active partition, will record the main boot record and boot record of the section, as well as data boot media From an ISO image. After completing the work Rufus. You can download using the obtained loading flash drive.

    Use of virtualization technology to test the loading flash drives. Links to download free and convenient programs To simplify the process of creating, debugging and verifying the created loading media.

    dD - A simple utility that is part of the majority of UNIX-like operating systems - Linux, FreeBSD, Solaris, etc.
    Its purpose is reading data from one device or file and write to another.

    dD can be effectively used to create a hard disk image, while doing without commercial utilities like Acronis True. Image or Norton Ghost.

    Suppose we have two disks:

    • / dev / sda - disc, the image of which must be created;
    • / Dev / SDB - the disk to which the image will be recorded.

    If necessary, you need to substitute your own values.

    First of all, you must boot from any available Live-CD disk having a DD utility and log in command line as a superuser. Create a mount point for backup.

    mKDIR / MNT / Backup

    Mount hDD To which you want to save the image.

    Creating a hard disk image

    dD if \u003d / dev / sda of \u003d / mnt / backup / sda.img bs \u003d 8m conv \u003d sync, noerror

    • if \u003d / dev / sda - copy the entire SDA hard drive;
    • of \u003d / mnt / backup / sda.img - copy to /mnt/backup/sda.img;
    • bs \u003d 8m - set the size cache hard disk to speed up the copy procedure (otherwise the data will be discharged by small portions of 512 bytes);
    • cONV \u003d SYNC, NOERROR - Specify DD to copy the type of bit-b-bit with ignoring read errors.

    To reduce the size of the image of the hard disk, it can be compressed by any archiver.

    dd if \u003d / dev / sda bs \u003d 8m conv \u003d Sync, Noerror | gzip -c\u003e / mmnt/backup/sda.img

    Hard disk image restoration

    To restore the hard disk image, it is necessary to do the procedure for the reverse procedure for creating this image.

    dD if \u003d / mnt / backup / sda.img of \u003d / dev / sda bs \u003d 8m conv \u003d sync, noerror

    When using compression, it is necessary to unzip the image in parallel.

    gunzip -c /mnt/backup/sda.img | DD OF \u003d / DEV / SDA CONV \u003d SYNC, NOERROR BS \u003d 8M

    Migration of the system to another hard drive

    To migrate the entire system to another hard disk, it is necessary to set the location of the new disk as a destination.

    dD if \u003d / dev / sda of \u003d / dev / sdb bs \u003d 8m conv \u003d sync, noerror

    After that, if necessary, set the boot from this hard disk. Provided that the new hard drive is greater than the old one, it will remain unbelievable area. It should be placed and format according to the available requirements.

    Copy statistics in DD

    The main minus in DD is the lack of a visual presentation of the statistics of the copy procedure. However, this minus can be easily circumvented. It is enough to connect to another terminal.

    Determine the process number under which DD is running.

    Periodically send this process The kill -usr1 command_process_dd number.

    watch -n 5 kill -usr1_process_dd

    • watch -N 5 - execute the command every 5 seconds;
    • kILL -USR1 Number_Procession_DD - Show copy statistics.

    Cons Usage DD to create disk images

    In total there are pros and cons. DD is a free and very flexible tool, but it can only be done with full copying of the volume. Special programs Copy only data that is stored on the disk.

    Thus, the volume of the disk image created using DD will be equal to the volume of the disc itself - regardless of the data disk.

    Create using the DD utility, the image of a flash drive with an archiving of free space. The backup image is useful if it suddenly stops working with the original with important information. For example, a flash drive with closed keys of electronic signatures of the organization's management. So, we have a flash drive / dev / sdd volume of 4GB, information on which takes about 90MB.
    dU - SH / RUN / MEDIA / ALEKSEY / TRANSCEND

    89m / RUN / MEDIA / ALEKSEY / TRANSCEND

    All commands are executed on behalf of the user. root. Or in the appropriate distributions before commands add sudo..
    fDISK - L / DEV / SDD

    Disk / Dev / SDD: 3.7 Gib, 3904897024 Bytes, 7626752 Sectors Units: Sectors Sector Size (Logical / Physical): 512 bytes / 512 Bytes I / O Size (Minimum / Optimal): 512 bytes / 512 bytes Disklabel Type: Dos Disk Identifier: 0xc653eaa4 Device Boot Start End Sectors Size ID Type / Dev / SDD1 2048 7628543 7626496 3.7G B W95 FAT32

    Disk / Dev / SDD: 3.7 GIB, 3904897024 Bytes, 7626752 Sectors

    Units: sectors of 1 * 512 \u003d 512 bytes

    SECEM Size (Logical / Physical): 512 bytes / 512 bytes

    I / O Size (Minimum / Optimal): 512 bytes / 512 bytes

    DiskLabel Type: DOS

    Disk Identifier: 0xC653EAA4

    Device Boot Start End Sectors Size ID TYPE

    / Dev / SDD1 2048 7628543 7626496 3.7G B W95 FAT32

    Having created a simple image team
    dD if \u003d / dev / sdd of \u003d sdd. ISO BS \u003d 4M CONV \u003d NOERROR,
    We are dealt with the storage of the 4GB file. And if the flash drive was a capacity of 64GB? And not alone? This problem will help to solve the usual archiver, take the standard gzip..
    dD if \u003d / dev / sdd bs \u003d 4m conv \u003d noerror | Gzip - C\u003e SDD. ISO. zip.
    Where is the key -c. Allows you to work with standard output.
    After completing the work, let's look at the resulting file. ls - Al SDD *

    It turned out a file of about 25MB. Real savings on disk even compared to 4GB file!
    To restore flash drive from the image, use the reverse order of commands.
    gunzip - C SDD. ISO. Zip | DD OF \u003d / DEV / SDD CONV \u003d NOERROR BS \u003d 4M

    You can also archive images hard diskswhere volumes are much more.

    By the way! For clarity of the process due to the lack of DD from DD, I propose to use a small utility progress. - Coreutils Progress Viewer. Install her in Fedora will not be difficult.
    dNF Install Progress.
    For other distributions, the desired repository can be found at https://pkgs.org/download/progress.
    By installing and running the command utility watch Progress. In the second terminal (in the first, we have an archiver and DD) on behalf of the same user, we will see about such a picture.

    man progress It will show you the various useful keys of this utility.