VOOZH about

URL: https://thenewstack.io/linux-low-level-data-copying-with-dd/

⇱ Linux: Low-level Data Copying with dd - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2024-08-17 06:00:10
Linux: Low-level Data Copying with dd
tutorial,
Data / Linux / Storage

Linux: Low-level Data Copying with dd

When you need low-level Linux data copying, there's one tool that never fails: the dd command. Here's how to use dd.
Aug 17th, 2024 6:00am by Jack Wallen
👁 Featued image for: Linux: Low-level Data Copying with dd
Featured image via Unsplash. 

When you use Linux, you know there are always multiple ways to solve a problem.

Take, for instance, the need to create backups. Yes, you could opt to use one of the many backup solutions (such as Bacula, rsync, Deja Dup, Fwbackups, Backupninja, Simple Backup Suite, Kbackup, BackupPC …  the list goes on and on). You’ll find command line tools, GUI tools, and even some web-based backup solutions.

But when you need low-level data copying (such as to create a partition or full disk copies), one tool never fails to rise above the rest. That tool is the `dd`command, which stands for data duplicator.

With dd, you can create a byte-for-byte copy of a partition or a drive and even convert data between files or devices. The `dd`  command allows you to control block size, and skip and seek data.

Needless to say, dd is very powerful. In fact, this command is so powerful that you really need to exercise caution when using it. Run the command improperly and you could wipe out an entire drive of data.

One thing dd is good for is copying a Linux installation from one disk to a larger disk. This is a good option when you have a server or desktop with a drive that’s full. You can even create a bootable USB drive from an ISO, thereby avoiding having to use third-party software for the task.

Let’s take a look at some examples of how the dd command is used. Remember, this command is very powerful, so I would highly recommend you test it on a non-production machine before you take on the important task of migrating an installation from one drive to another.

What You’ll Need

To make use of dd, you’ll need the following:

That’s it. Let’s get to work.

dd: The Basic Syntax

The basic syntax of the dd command can be in one of two forms:

  • dd [OPERAND]
  • dd OPTION

With that in mind, let’s take a look at some examples.

Create a Bootable USB

Because it’s less likely you’ll do damage by creating a bootable USB device, we’ll take a look at that example first. Let’s say your ISO image is AlmaLinux-9.3-x86_64-dvd.iso and the USB drive you want to use is located at /dev/sdg.

It’s very important that you know the exact path of your USB drive. If you’re not sure, you can locate it with the lsblk command.

To create this bootable USB drive, the command would look something like this:

sudo dd if=/home/jack/Downloads/AlmaLinux-9.3-x86_64-dvd.iso of=/dev/sdg bs=4M status=progress && sync

A bit of an explanation for the above:

  • if= This is the input file or the ISO file you want to use for the bootable USB device.
  • of= This is the output file or the location of the USB drive.
  • bs=4M This defines how many bytes will be read and written to (the default is 512).
  • status= This is the level of information to print to the output. In this case, progress shows periodic transfer statistics.
  • sync This makes certain all data is written to the USB device before the process finishes.

Converting Files

Before we continue, there’s a really cool feature found with dd that allows you to convert text. For example, you might have a file comprised of all lowercase text and you want to convert it to all uppercase. Say the file in question is called “testing” and you want to create a new file called “testing2” that is the uppercase version of the original. To do that, the command would be:

dd if=testing of=testing2 conv=ucase

The possible options you can use with conv include:

  • ascii Convert from EBCDIC to ASCII.
  • ebcdic Convert from ASCII to EBCDIC.
  • ibm Convert from ASCII to alternate EBCDIC.
  • block Pads newline-terminated records with spaces to cbs-size.
  • unblock Replaces trailing spaces in cbs-size records with newline.
  • lcase Converts upper case to lowercase.
  • ucase Converts lower case to uppercase.
  • sparse Tries to seek rather than write all-NUL output blocks.
  • swab Swaps every pair of input bytes.
  • sync Pads every input block with NULs to ibs-size; when used with block or unblock, pad with spaces rather than NULs.
  • excl Fails if the output file already exists.

Cloning Disks with dd

Finally, we’re going to take on the meat and potatoes of the dd command … disk cloning. Remember, you’ll need a drive that’s  bigger than the one you’re cloning. Cloning with dd creates an exact, byte-for-byte copy of a drive or partition, such that the new drive is identical to the source. This is great when you suspect a drive is failing and you want to salvage it before it’s too late.

To do this, you’ll want to connect the new drive to the system that contains the drive to be cloned. Let’s say, for example, the source drive is /dev/sda and the destination is /dev/sdb.

What you first need to do is boot the machine using either a rescue distribution or any live version of a Linux distribution. The reason you must do this is that both source and destination must be unmounted (and you can’t unmount a drive that’s in use).

Once you’ve booted the live distribution, connect the destination drive and clone the source with the command:

sudo dd if=/dev/sda of=/dev/sdb bs=4M status=progress

The process will take some time, so exercise your patience here. When the process completes, reboot the machine, making sure to remove the USB device.

To verify everything works, you should open the boot menu of the machine and select the destination drive as the boot source. If everything works out fine, you could then remove the source drive, and insert the designation drive, and all should be good to go.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.