Blog | G5 Cyber Security

Hard Drive Acquisition with DD

TL;DR

Yes, dd can be used to acquire a hard drive, but it’s crucial to understand the risks and use it correctly. Incorrect usage can easily overwrite data. This guide explains how to do it safely.

Acquiring a Hard Drive with DD: A Step-by-Step Guide

  1. Identify the Target Drive
sudo lsblk
sudo fdisk -l
  • Example Output (lsblk):
    NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
    disk0   8:0    0 238.5G  0 disk 
    sda    8:16   0 238.5G  0 disk 
    sda1   8:17   0 512M  0 part /boot/efi
    sda2   8:18   0 237.9G  0 part /

    In this example, disk0 is the physical drive and sda is a common device name for it.

  • Double-check! If you’re unsure, disconnect other drives temporarily to avoid mistakes.
  • Unmount the Drive
  • sudo umount /dev/sda1
    sudo umount /dev/sda2
  • Run the DD Command
  • sudo dd if=/dev/sdX of=/path/to/image.img bs=4M status=progress
  • Replace /dev/sdX with the correct device name (e.g., /dev/sda).
  • Replace /path/to/image.img with the desired path and filename for the image file. Ensure you have enough space on the destination drive!
  • bs=4M sets the block size to 4MB, which is a good balance between speed and efficiency.
  • status=progress shows the progress of the imaging process (available in newer versions of dd). If your version doesn’t support this, you can send a SIGUSR1 signal to the dd process to get status updates.
  • Important: Consider using conv=sync,noerror for more robust imaging, especially with failing drives.
    sudo dd if=/dev/sdX of=/path/to/image.img bs=4M conv=sync,noerror status=progress
    • conv=sync pads every input block with zeros to a fixed size.
    • conv=noerror continues copying even if read errors occur (useful for damaged drives). Errors will be reported.
  • Verify the Image
  • sudo md5sum /dev/sdX
    sudo md5sum /path/to/image.img
    sudo sha256sum /dev/sdX
    sudo sha256sum /path/to/image.img
  • Compare the checksums. They must match exactly for a valid image.
  • Important Considerations
  • Exit mobile version