Search Results


dd this, dd that

Date Mar 12, 2021

Contents

Basic procedure on dding the image to your flash drive.

Making things simple, we will use 4 of the powerful commands on linux just to dd the stuff on drive.

Step 0: Check the drive

I can't emphasize this enough but one of the basic mistake by noobies is to copy the commands without understanding their function. This includes the drive name too, so make sure you are using the correct drive to work with as THIS WILL REALLY FUCK UP YOUR DATA IF DONE WRONG.

# Match the device id and its size mentioned in outupt with your corresponding drive.
sudo fdisk -l

Step 1: Wipe the headers

Some drives even after wiping will have associated partition table information that can result in corruption of data and in many cases making drive invalid. To clean this, wipefs utility will be used.

# Make sure to select the correct device
sudo wipefs -af /dev/sde

Step 2: Remove GPT data

If you are using a Linux on a modern machine (with UEFI enabled), there is a high chance that your drive contains GPT (GUID Partition Table) in it. To clean this, sgdisk utility will be used.

# Again, select the right device
sudo sgdisk --zap-all /dev/sde

Step 3: Clean the remnants of partition

Sometimes to protect drive from corruption, there are backup of partition tables on specific locations. This can cause faulty overwrites with the old partitioning to the new, if cloning an image. Good example of this is if flashing different Raspberry Pi images on same SD card. To clean this, shred command will be used. This command will select a random source, in our case /dev/urandom and overwrite the bits on drive from random source.

# Last time, check if device is right. No crying afterwards!
sudo shred --verbose --random-source=/dev/urandom --iterations=1 /dev/sde

Step 4: Verify image checksum

No matter from where you have downloaded disk image, you should always verify the image's hash signature only if obtained from trusted sources.

# Use the checksum only if the source obtained from is trusted.
sha1sum <file_name.iso>
md5 <file_name.iso>
# match the output of the command with your checksum

Final Step: Let's clone it!

Okay, so the final part is here. This one is much more simple to follow.

#
sudo dd if=<path_to_image> bs=16M of=/dev/sde oflag=direct status=progress
# Wait for this command to finish the cloning procedure

Finished

Final wording is, just check the drive to see if it's actually working or not.