Announcement

Collapse
No announcement yet.

Dd Command Examples on Linux

Collapse
X
Collapse
  •  

  • Dd Command Examples on Linux


    The dd command, or data duplicator, is a robust and versatile utility famous for its disk manipulation features. While its primary purpose is to create disk images, it also lets you clone data, convert file formats, take backups, and more.
    Whether you’re a Linux beginner or an experienced user, understanding the various applications of the dd command can be beneficial. In this short tutorial, we’ll explore multiple examples of the dd command in Linux you can learn with no hassles.
    Create an Image of a Hard Disk Using dd Command

    Creating an image of a hard disk using the dd command is the foremost example. This image acts as a backup of a storage device, and you can create one by executing the below command:

    dd if=/path/to/source/partition of=~/drive.img bs=8M



    Let’s break the above command:
    1. if (Input File): Specifies the source file or the drive from where you want it to read the data.
    2. of (Output File): Specifies the target file or the drive where you want to write the data.
    3. bs (Block Size): Specifies the size(in MBs) of blocks to use for the I/O operations.
    4. count: Sets the number of blocks to copy.
    5. Seek: Seek the input value of N and skip the N number of blocks before writing any data.
    6. skip: Skips N number of blocks before reading any data.

    In case you don’t know how to find the path of the hard disk, you can run the df command to list all the disks and their current storage space:

    df






    Now, let’s take an example to create image of a /dev/sda2 using the following command:

    sudo dd if=/dev/sda2 partition of=~/drive.img bs=8M




    If you want to restore the disk image, please run the below dd command:

    dd if=~/drive.img of=/path/to/target/partition




    You can also use the dd command to create a bootable USB drive from an ISO image, like:

    dd if=~/drive.iso of=/path/of/USB_drive bs=4M status=progress && sync




    Here, we use the “status=progress” option to display the progress of the data transfer, the amount of data copied, and its transfer speed. The “sync” option reduces the risk of data loss or corruption and ensures the data gets completely written to the target drive.
    If you instead want to convert an ISO image file to a raw disk image file, use:

    dd if=~/drive.iso of=~/drive.img




    For the sake of data backup or any other similar purpose, you can use the below dd command to clone a disk:

    dd if=/source/disk of=/target/disk bs=8M



    Replace ‘/source/disk’ and ‘/target/disk’ with the actual source and target disks, respectively. This command will generate an exact source copy at the target path.
    Furthermore, if you want to convert any disk partition into an ISO image file, run the following:

    dd  if=/source/disk of=~/iso_image.iso bs=2M



    Here, replace ‘iso_image’ with the name of the ISO file you intend to create.
    Wrapping Up

    The dd command is a powerful utility for creating, modifying, and restoring disk images. You can master it to perform disk cloning and data conversion tasks with ease. Therefore, this tutorial demonstrates multiple examples of the dd command in Linux. You can experiment the above commands to make disk images, restore disk data from images, create bootable drives, clone a disk, and much more.


    More...
      Posting comments is disabled.

    Categories

    Collapse

    Article Tags

    Collapse

    There are no tags yet.

    Latest Articles

    Collapse

    • HAProxy on Ubuntu: Load Balancing and Failover for Resilient Infrastructure
      by Kasimba



      by german.suarez


      Introduction

      In today’s fast-paced digital landscape, ensuring the availability and performance of applications is paramount. Modern infrastructures require robust solutions to distribute traffic efficiently and maintain service availability even in the face of server failures. Enter HAProxy, the de facto standard for high-performance load balancing and failover.


      This article...
      Today, 03:00 PM
    • Providing a license for package sources
      by Kasimba
      Arch Linux hasn't had a license for any package sources (such as PKGBUILD files) in the past, which is potentially problematic. Providing a license will preempt that uncertainty.

      In RFC 40 we agreed to change all package sources to be licensed under the very liberal 0BSD license. This change will not limit what you can do with package sources. Check out the RFC for more on the rationale and prior discussion.

      Before we make this change, we will provide contributors with...
      11-19-2024, 09:21 AM
    • Linux Binary Analysis for Reverse Engineering and Vulnerability Discovery
      by Kasimba



      by George Whittaker


      Introduction

      In the world of cybersecurity and software development, binary analysis holds a unique place. It is the art of examining compiled programs to understand their functionality, identify vulnerabilities, or debug issues—without access to the original source code. For Linux, which dominates servers, embedded systems, and even personal computing, the skill of binary analysis is...
      11-18-2024, 07:10 PM
    • Ubuntu vs Debian: Linux Distributions Compared Deep Dive
      by Kasimba
      Debian and Ubuntu are two popular Linux distributions. In this deep dive we will guide you on the key differences between them from perspective of both corporate enterprise and personal productivity or pleasure usage. After reading this blog post you should be in a better position to decide to select Ubuntu or Debian.
      Stewardship, Licensing, Community and Cost

      Where as Debian is 100% fully committed to free software as defined by the Debian Free Software Guidelines, Ubuntu is created...
      11-17-2024, 08:30 PM
    • Debian Backup and Recovery Solutions: Safeguard Your Data with Confidence
      by Kasimba



      by George Whittaker


      Introduction

      In the digital age, data loss is a critical concern, and effective backup and recovery systems are vital for any Debian system administrator or user. Debian, known for its stability and suitability in enterprise, server, and personal computing environments, offers a multitude of tools for creating robust backup and recovery solutions. This guide will explore these solutions,...
      11-13-2024, 05:30 PM
    • Installing Development Tools on Debian: Setting Up Compilers, Libraries, and IDEs for a Robust Development Environment
      by Kasimba



      by George Whittaker


      Introduction

      Debian is one of the most trusted and stable Linux distributions, making it a top choice among developers and system administrators. Setting up a powerful development environment on Debian involves installing the right tools, compilers, libraries, and Integrated Development Environments (IDEs) that can support various programming languages and workflows. This guide provides...
      11-07-2024, 11:22 PM
    Working...
    X