date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,436,561,452,000
I have an external backup hard drive that is encrypted using LUKS. As I was re-organising my backups, I copied the data to another encrypted drive and did a kind of "quick wipe" on the original drive by replacing the key in the key slot with random data. Goal was to use the drive afterwards as a second backup, but at ...
The problem is the content of the key slot. In order to access the data you need the master key. The people having one of the slot keys may not be supposed to know the master key (because then you could not lock somebody out without reencrypting all the data). Thus a new key is given (password or file), turned into a ...
LUKS: find a deleted key(slot)
1,585,074,715,000
I would like to know if it is possible to recover files that I have deleted? I have VPS with CentOS 7 and if it is possible I would like to look for (and recover) deleted files by their file extensions. Thank you.
I've had pretty good success with TestDisk & PhotoRec for recovering deleted files. Haven't tried it via an SSH session but make sure you install and run screen command. I've had recovery scan that last over 24 hours.
Recovering files on CentOS 7
1,585,074,715,000
I installed Fedora 28. But I resized the partition that contained Fedora (/dev/sda7) wrongly using GParted and now I can't boot my system. (Note the partition format is ext4)
Resizing a partition does not implicitly resize any filesystem it might contain. You should have shrunk the filesystem and then shrunk the partition. (I'm surprised gparted didn't warn you.) However, to try and fix the damage, resize the partition back to whatever it was before. If you're not sure of the value then ma...
ext4 partition is broken during resizing with gparted
1,585,074,715,000
I used MonoDevelop to write a small C#-program that moves directories and files from one location to another location, but I messed it up a bit. I used C#'s DirectoryInfo.MoveTo(path1, path2); to move the folder, but I forgot to specify the actual parent folder of path2. The initial situation was like this: I have a s...
It's under the directory that was the current working directory of the Mono process that executed the move.
Moved a directory to a non-existing location?
1,585,074,715,000
The /var/spool/mail/root file was deleted by accident; I need to recover it. Is there any link related to this file or how this file got updated which script responsible for it?
The file /var/spool/mail/root typically contains locally delivered email for the root user. For example, echo hello, world | mail -s 'kandr test' root If you don't have a backup then you have lost your local email for this user account. (If you didn't ever read it then consider it a safe loss.) Don't try to recreate ...
/var/spool/mail/root file deleted by accident
1,585,074,715,000
I have got a 2-disk NAS configured by the builtin software to be a RAID1 array. On this were two volumes (LVM on MD) with data. Now I replaced the two disks and wish to copy over the old data. I have the two disks connected to a Linux PC via USB, now I want to mount the volumes. This is how it looks like: # lsblk | t...
mkdir --mode=000 /mnt/old_volume mount -o ro /dev/vg_a8765432/lv_37654321 /mnt/old_volume ls -l /mnt/old_volume
How to recover/copy data off disks that were once part of a RAID1 (LVM on MD) in a 2-disk NAS?
1,585,074,715,000
I am trying to recover whatever data I can from a bad partition on a hard drive. Unfortunately fsck failed to resolve the issue. The output from mount is as follows: $ sudo mount /dev/sda3 /mnt/ mount: wrong fs type, bad option, bad superblock on /dev/sda3, dmesg output is as follows: [77027.447708] ata1.00: exceptio...
Use ddrescue insted of dd (it will ignore read errors), then you can run fsck on the dumped image with various -b parameters. man fsck: -b superblock Instead of using the normal superblock, use an alternative superblock specified by superblock. This option is normally used ...
Recovering from an AMNR Hard Drive error (ext4)
1,585,074,715,000
I tried to delete all files named "Thumbs.db" with something like $ rm -rd /path/to/hdd/decrypted/folder/* --name Thumbs.db but it just started deleting in alphabetical order. Now, I have to recover the files, which are still on the HDD, but they're encrypted and I meanwhile shut down my computer and unplugged the...
At first, you should never mount your disk read-write during the recovery. Then you may copy the decrypted device (in /dev/mapper/foo-crypt) to an unencrypted device if you have some tools which only work with real disks. For usual linux utilities /dev/mapper/foo-crypt) should be okay. Then testdisk and photorec are g...
How to rescue files after $ rm -rd ./* on encrypted, external HDD?
1,585,074,715,000
Today, I accidentally copied over a file on an ext3 partition. Realizing this but a moment too late, I unmounted that partition hoping that the inode would have survived. No such luck. I managed to run ext3grep on the right inode, but it had been promptly overwritten by another temporary file, which was then also d...
Use dd to get each of the blocks off the disk into individual files, examine the indirect block for the remaining blocks, get them as well. Use cat to join them together (don't include the indirect block). Hope that they are good. Frequently pdf files are compressed which will make it very difficult to recover the da...
Recover deleted file from block numbers
1,585,074,715,000
syslog reports that /sys/devices/pci0000:00/0000:00:14.0/usb2/2-1 has been inserted, neither fsck nor photorec see it. Is there some other means to recover the files on this device?
If this is a normal external harddrive, remove it from the case and connect it using SATA. This will help both if the USB bridge chip is damaged (because you then won't use it) but also when the problem lies with the drive itself: many USB bridge chips handle failing harddrives badly (for example often drive read time...
USB drive kaput!
1,585,074,715,000
In the foremost manual it says that it can be used to recover files using their headers, footers and data structures. Since file deletion does not actually erase data and data is still there until some other data overwrites it. Hence I tried to recover my video files (mp4 format) just after deleting it (files were in ...
foremost needs access to the device containing the files, not the directory where it is mounted. In your case, assuming your external drive (and appropriate partition) ends up being /dev/sdc1, you'd make sure it's unmounted and run foremost -t mp4 /dev/sdc1 You need to run this from a directory with enough room to st...
Recover deleted files using foremost
1,585,074,715,000
I had Linux mint installed in my computer in one partition and had another partition for Data. I just installed Ubuntu Kylin 14.04 and during the installation there was an option like "install Ubuntu replacing Linux Mint", which was the one I chose, thinking it would just mess with the partition of Linux mint. Now I ...
Actually I was able to recover all my data which includes quite a few Gibabytes... What I did: booted the system with the USB installation disk in 'live mode' installed the program testdisk through it I was able to view and copy all the data I wanted to an external disk
How to recover the data that has possibly overwriten by the installation of another system? [duplicate]
1,585,074,715,000
I've recently reinstalled my Debian server but forgot to backup mysql databases which were in folder /var/lib/mysql. I need to recover them and tried to use PhotoRec but I can't find the mysql databases there. I have shutdown my server for the moment so it doesn't deteriorate the recovering process. Is there any bette...
You were correct to power off your system. Your best bet is to boot from a rescue disk, such as SystemRescueCD, and try to recover the files using file recovery utilities. SystemRescueCD comes installed with PhotoRec and TestDisk. The extundelete utility is also worth a try. While it does not come installed on System...
recover mysql databases after reinstall debian
1,585,074,715,000
I have just restored my data from a borg backup repository after a computer failure. My ~/.gnupg folder seems fine, private keys are there, and permissions look correct. Usually borg does a good job at this. When I cat the private keys files, there is no sign of data corruption. However I cannot list or use the privat...
I am trying a garuda kde install at the moment, and it turns out it comes with some default gpg settings I have not yet completely figured out. Anyway, it turns out some process is constantly recreating a basic .gnupg folder. It does not look like it is to blame on gpg agent since I was able to disable all gpg related...
Recover poorly backed up gpg secret keys
1,696,623,861,000
While trying to move a file into /usr/lib/x86_64-linux-gnu, I accidentally overwrote x86_64-linux-gnu itself. The system(ArchLinux) is still running, but I'm not sure how to safely recover x86_64-linux-gnu, what exactly/how important it is, or what will happen if the system reboots. How can I fix/recover x86_64-linux-...
what exactly... it is Please see here for further information, as this answer explains that quite well. Arch Linux users, please ignore the above link, which pertains to the Debian or Ubuntu handling of multiarch. For Arch handling of this, please see the Arch wiki file hierarchy. How can I fix/recover x86_64-linux...
Accidentally overwrote /usr/lib/x86_64-linux-gnu(using mv command) with file
1,696,623,861,000
Power cut happened, UPS' could not hold It all started in my little server room, where I needed to shrink one of my client's ext4 partitions using Gparted on Debian GNU/Linux 11 (bullseye), (fully updated): Then (due to heavy snow, I was later informed) a power cut happened, lasted for hours, my UPS' are not made to ...
What I actually did - Not a direct answer I did think about it a lot during those 2 hours. And the result surprised me, I scanned the timeshift snapshot /home for all sorts of files, not really many there at all. This gave me an opportunity to do a clean installation. It took me many hours, but at the end of the day, ...
How to rsync (or generally "copy") data back from Timeshift snapshot?
1,627,560,030,000
I have an old HDD which failed and I'm trying to recover what's possible with testdisk. The plan was to use dd to make an image and then use testdisk to recover files from the image to avoid damaging the disk even more. I used the following command: sudo dd if=/dev/sdc of=/mnt/BigDisk/backup.iso status=progress Every...
Finally I managed to rescue my files. I may have lied in the question because probably between the moment I tried the first time and when I posted the question I had a kernel update (probably from 5.12 to 5.13). I tried again yesterday with the new kernel and a new hard drive with an ext4 partition as destination and ...
All processes using a device got hung and even `kill -9` does nothing
1,627,560,030,000
Does a Linux alternative to Time Machine (macOS) exist? I'm looking for the recovery mode feature that lets you restore the system completely. Can programs like Cronopete or Back in Time do that?
KGIII responded to my question in the comments by providing this link. The software is TimeShift. Thanks again for your help :)
Time Machine system recovery alternative for linux
1,627,560,030,000
I was unable to recover my other account where I originally asked a question, so I'm hoping it's ok that I ask some follow up questions here I'm looking to use ddrescue to clone a failing drive that I used to boot from in order to restore all the applications/settings etc that I had. I'm planning to run ddrescue on a...
About the secondary GPT: yes, the problem still exists even if the new drive does not yet contain an existing GPT, unless the new drive has the exact same size as the source drive, which is unlikely. The secondary GPT has to be located at the end of the drive, and if you copy an image of the source drive to the beginn...
Follow up questions for using ddrescue with a USB enclosure
1,627,560,030,000
I used fetchmail to access my Hotmail/Outlook mailbox. It downloaded every message inside Inbox, but now that folder is empty at the server. Now I see that fetchmail deletes messages by default: -k | --keep : Keep retrieved messages on the remote mailserver. Normally, messages are deleted from the folder on the m...
Solved using Thunderbird: Install Thunderbird Link Hotmail account to Thunderbird using the same IMAP settings as in fetchmail In Thunderbird install ImportExportTools extension Create new folder in Local Folders, right click on the new folder, select ImportExportTools and import mbox file, select the user's mailbox ...
Recover/reupload messages deleted by fetchmail
1,627,560,030,000
Let's say that I set the block size of dd or ddrescue to 256K. A sector of flash drives usually has 512 bytes, a sector on optical data discs has 2048 bytes. Let's assume that in the next 256 KB, just one sector is unreadable. Every other sector is readable. What happens to the multiblock transfer? Does it transfer a...
Example command without abbreviating options/switches: sudo ddrescue --direct --sector-size=20480 --verbose --verbose --retry-passes="-1" /dev/sr5 If one out of the ten sectors in the 20480 next bytes is damaged, the entire 20480 bytes will not be saved. Finer grain: sudo ddrescue --direct --sector-size=2048 --verbose...
Unreadable block in multiblock reading on dd / ddrescue: How does it handle it?
1,508,169,840,000
Know that my chances are small (if even there are :(). I have a HDD of 500G with 1 logical volume (ext4). By accident I overwrote it with an ISO of 1,5G: dd if=linuxmint-18-xfce-32bit.iso of=/dev/sdb Now I lost all data. Is there some way to re-create the logical volume to get some data back? I have the LVM backup fi...
I did not succeed to restore the partition since it missed the start of it. What I did was recovering most of my data with the tool photorec that is from the same author as testdisk. Before I could use it I had to create a partition that started after the ISO partition until the end of the disk. photorec searched this...
Recover LVM after overwrite with dd
1,508,169,840,000
One partition of corrupt hard drive can't be mounted What does it mean, if one partition of a hard drive with error can't be mounted while all others are mounted? (Especially the first, boot partition can be mounted, means the partition table should be available.) Recover from unmountables And i'm having trouble to re...
Both dd and gddrescue are able to recover data from non-mountable images. The reason of the error message is the missing of the root rights. You need to run dd or ddrescue as root.
recover data from partition unable to mount
1,508,169,840,000
Is it possible to unmount a (FAT32-formatted) pendrive without committing changes? Use case: easy recovery of accidentally deleted files
Linux does not "commit changes" to a file, unless one is using a version control system (VCS) like Git or Fossil. It has what are known as "dirty buffers" -- files that have been changed without the changes being written to disk. The purpose of these dirty buffers is to speed up things; they are not designed to allo...
unmount pendrive discarding changes
1,508,169,840,000
I was tired and unfortunately I did: rm -rf * /var/www/vhosts repertory on my CentOS 6.3 running with Parallel Plesk. I lost many websites, but worst: I've lost chroot, default, fs and fs-passwd. What were these folders? What did they do? What should I do now...? I have backups, but only for my websites. I miss ever...
My content hoster helped me and found a solution, which might not work at 100% but 90% (100% is the total reload of the server). First, since I had recreated a customized /vhost/ directory with my backed up contents in there (it would not be your case), I deleted /vhosts/. Second, I ran this from SSH: usr/local/psa/bo...
rm -rf on vhosts directory, what should I do?
1,508,169,840,000
I have a Linux partition formatted to ext4 and I accidentally formatted it with Mac OS X Disk Utility to HFS+ (Mac OS X Extended Journaled). I tried to recover it with http://www.r-studio.com/ on Windows but I can't get any files except few from trash or temporary browser files. Now I'm trying another software on OS X...
I don't have any knowledge of the tool you are using, but I used before UFSexplorer and it was good (take a look here) Now, if you managed with the tool r-studio to get some files that's good, it means that the HFS+ format didn't wipe your disk and prepared it's initial data struture, So, you can use UFS explorer or t...
Recover Linux ext4 partition formatted to hfs+
1,508,169,840,000
I deleted gtk from /lib, the system lib, und an Ubuntu installation. Is there a way to recover that?
If this is ubuntu, you can reinstall the packages that include the pieces you deleted. For example, apt install --reinstall libgtk2.0-0 You can get a list of edited, damaged and missing files with sudo dpkg -V And you can find out what package a file belongs to with dpkg -S filename...
Recover libraries deleted from /lib
1,508,169,840,000
I inadvertently deleted images from my Linux filesystem today with classic command rm -f. All deleted images were in one single folder. Not all my images were in this folder, it was only very specific images. Is there a way to restore them by a command? I read about some revocery like debugfs, PhotoRec, ...
You will have to be more specific about the system environment, but assuming your file system is formatted as ext3 or ext4 (which should be the default in modern Linux systems - check the output of mount), you can try a tool called extundelete. Note, however, that any action that possibly alters the file system on whi...
Restore deleted images (png/gif/jpg/jpeg)
1,508,169,840,000
I installed Archlabs 1 month later, today I noticed bin folder in ~ directory and Deleted it. After Reboot This errors Came out in polybar /bin/sh: updates.sh: command not foun And /bin/sh: check-network: command not found I remember thad there was 4 folders int that bin folder which i deleted. can you help me to r...
The reason you're probably getting these errors is because the ~/bin folder contains programs added to your $PATH, via ~/.profile. I recommend making a new user on the machine, and copy all of the contents of their ~/bin directory to a ~/bin directory in your user directory.
updates.sh - Command Not Found - Arch linux
1,508,169,840,000
I have a ~450 gigabyte ext4 filesystem, located at /dev/sda5 on my computer. The partition it resided in, however, was about a gigabyte bigger. So I used the command e2image -ra -p -O XXXX to move the filesystem to the left, so I could use the extra gigabyte on a partition at /dev/sda6. I didn't run that exact command...
I think the commenters are right that your file system is pretty well broken. I once accidentally wrote /dev/zero to my main hard drive (while operating) for about half a second before killing it. I was able to use Photorec (http://www.cgsecurity.org/wiki/PhotoRec) to recover my partition table (pretty much automagi...
Corrupt ext4 filesystem after e2image interrupted
1,508,169,840,000
I know that a lot of deleted files can theoretically be recovered, which suggests that "deleting" doesn't actually remove the information. So how do the various extN (e.g. ext4) filesystems delete files? Do they just mark the space as "free"?
Do they just mark the space as "free"? Yes. "Removing" the file would take extra work and is in most cases unnecessary.
How does ext[n] delete files?
1,532,335,538,000
I recently wiped an old ubuntu server of mine and installed debian, but i forgot to backup a very important file. I know there is a chance that the computer has already wrote over the file, but what can I do to look for this file?
The first thing is to not use the system at all. Everything you do increases the chances that you'll overwrite a part of the file. Depending on how important it is, I would pull the plug and image the hard drive first (e.g., with dd). If nothing else, use a live CD to look for the file. If it's very important, you cou...
Recover file from previous installation? [duplicate]
1,532,335,538,000
When looking up a way to uninstall minecraft using console commands, the very first result on google told me to use the command: rm -vr ~/ .minecraft/*. I thought, oh well, I'm specifying the directory so this should work fine. The command proceeded to start deleting every folder in my home directory. Luckily I caught...
I'm assuming you have no backups and because it's ext4 you will also not have any snapshots. This will be extremely tricky... "Luckily" by using rm you don't actually remove data as in "overwriting with 0-bits" but instead you are just telling the filesystem that these files do no longer exist and this space can be re...
How to recover files deleted by rm -vr?
1,532,335,538,000
I was trying to remove this trojan that copied itself across my system and after successfully seeing all instances of the trojan using find / -name trojan I then did find / -delete -name trojan and immediately starting seeing "Operation not permitted" on files that were not related to the trojan so I killed the comman...
find / -delete -name trojan attempted to delete all files on the root filesystem. The command you meant to use is find / -name trojan -delete Sorry to be the bearer of bad news but your system is FUBAR. You should boot up from a live CD, copy on an external drive any important personal file might have been left on ...
Deleted files from linux using find and need to fix
1,304,432,287,000
I recently realized we can use cat as much as dd, and it's actually faster than dd I know that dd was useful in dealing with tapes where block size actually mattered in correctness, not just performance. In these days, though, are there situations where dd can do something cat can't? (Here I would regard a less than 2...
In appearance, dd is a tool from an IBM operating system that's retained its foreign appearance (its parameter passing), which performs some very rarely-used functions (such as EBCDIC to ASCII conversions or endianness reversal… not a common need nowadays). I used to think that dd was faster for copying large blocks o...
dd vs cat -- is dd still relevant these days?
1,304,432,287,000
I've not used dd all that much, but so far it's not failed me yet. Right now, I've had a dd going for over 12 hours - I'm writing an image back to the disk it came from - and I'm getting a little worried, as I was able to dd from the disk to the image in about 7 hours. I'm running OSX 10.6.6 on a MacBook with a Core ...
You can send dd a certain signal using the kill command to make it output its current status. The signal is INFO on BSD systems (including OSX) and USR1 on Linux. In your case: kill -INFO $PID You can find the process id ($PID above) with the ps command; or see pgrep and pkill alternatives on mac os x for more conven...
How do I know if dd is still working?
1,304,432,287,000
How can I create a backup of a remote disk using SSH on my local machine and save it to a local disk? I've tried the following: ssh [email protected] "sudo dd if=/dev/sdX " | \ dd of=/home/username/Documents/filename.image` However, I receive the following error: no tty present and no askpass program specified
If your intent is to backup a remote computer's HDD A via SSH to a single file that's on your local computer's HDD, you could do one of the following. Examples run from remote computer $ dd if=/dev/sda | gzip -1 - | ssh user@local dd of=image.gz run from local computer $ ssh user@remote "dd if=/dev/sda | gzip -1 -" |...
How to dd a remote disk using SSH on local machine and save to a local disk
1,304,432,287,000
On occasion I've seen comments online along the lines of "make sure you set 'bs=' because the default value will take too long," and my own extremely-unscientific experiences of, "well that seemed to take longer than that other time last week" seem to bear that out. So whenever I use 'dd' (typically in the 1-2GB rang...
dd dates from back when it was needed to translate old IBM mainframe tapes, and the block size had to match the one used to write the tape or data blocks would be skipped or truncated. (9-track tapes were finicky. Be glad they're long dead.) These days, the block size should be a multiple of the device sector size ...
Is there a way to determine the optimal value for the bs parameter to dd?
1,304,432,287,000
I like to create an image backup the first time I'm backing up a system. After this first time I use rsync to do incremental backups. My usual image backup is as follows: Mount and zero out the empty space: dd if=/dev/zero of=temp.dd bs=1M rm temp.dd Umount and dd the drive while compressing it dd if=/dev/hda conv=...
It depends on whether the disk image is a full disk image or just a partition. Washing the partition(s) If the disk is in good working condition, you will get better compression if you wash the empty space on the disk with zeros. If the disk is failing, skip this step. If you're imaging an entire disk, then you will w...
Is it possible to mount a gzip compressed dd image on the fly?
1,304,432,287,000
Today I had to remove the first 1131 bytes from an 800MB mixed text / binary file, a filtered subversion dump I'm hacking for a new repository. What's the best way to do this? To start with I tried dd bs=1 skip=1131 if=filtered.dump of=trimmed.dump but after the skip this copies the remainder of the file a byte at a ...
You can switch bs and skip options: dd bs=1131 skip=1 if=filtered.dump of=trimmed.dump This way the operation can benefit from a greater block. Otherwise, you could try with tail (although it's not safe to use it with binary files): tail -c +1132 filtered.dump >trimmed.dump Finally, you may use 3 dd instances to wri...
Best way to remove bytes from the start of a file?
1,304,432,287,000
I just formatted microSD card, and would like to run a dd command. Unfortunately dd command fails: $ sudo dd bs=1m if=2016-02-26-raspbian-jessie-lite.img of=/dev/rdisk2 dd: /dev/rdisk2: Resource busy $ Everyone on the internet says I need to unmount the disk first. Sure, can do that and move on. But I want to underst...
Apple court, Apple rules. Try diskutil: $ diskutil list ... # if mounted somewhere $ sudo diskutil unmount $device # all the partitions (there's also a "force" option, see the manual) $ sudo diskutil unmountDisk $device # remember zip drives? this would launch them. good times! $ sudo diskutil eject $device (In th...
Running dd. Why resource is busy?
1,304,432,287,000
Background I'm copying some data CDs/DVDs to ISO files to use them later without the need of them in the drive. I'm looking on the Net for procedures and I found a lot: Use of cat to copy a medium: http://www.yolinux.com/TUTORIALS/LinuxTutorialCDBurn.html cat /dev/sr0 > image.iso Use of dd to do so (apparently the m...
All of the following commands are equivalent. They read the bytes of the CD /dev/sr0 and write them to a file called image.iso. cat /dev/sr0 >image.iso cat </dev/sr0 >image.iso tee </dev/sr0 >image.iso dd </dev/sr0 >image.iso dd if=/dev/cdrom of=image.iso pv </dev/sr0 >image.iso cp /dev/sr0 image.iso tail -c +1 /dev/s...
Is it better to use cat, dd, pv or another procedure to copy a CD/DVD?
1,304,432,287,000
I have a bash script that creates some file using dd. The problem is dd throws a great amount of output that is going to mess with the output of my script. Searching around I've found a solution: dd if=boot1h of="/dev/r$temp1" >& /dev/null Is there an alternative, or is redirecting to /dev/null the only way?
From the dd(1) man page: status=noxfer suppress transfer statistics thus: dd if=boot1h of="/dev/r$temp1" status=noxfer This still outputs the 0+1 records in 0+1 records out garbage when dd exits, so redirecting to a data sink really is your only option.
How do I suppress dd output?
1,304,432,287,000
I know very well what the command does, but man dd, info dd tell me: 'Convert and copy a file', as does GNU Coreutils. Google says its an abbreviation of everything between medicine and bad webchat slang; except someone saying it means 'data destroyer', something used in PC forensics - I'd be horrified if my dd destro...
Wikipedia (dd) asserts it was named after IBM JCL command DD which stands for Data Definition. I always thought it would mean data duplicate, though.
What does dd stand for?
1,304,432,287,000
ORIGINAL QUESTION: If I have 2 identical hard drives with the following characteristics: SATA 6.0 Gb/s 5400 rpm 3TB How long should a full dd copy take to complete? So far it's been running for 5 hours and still going... I am using Linux Ubuntu 12.04 64bit and the command I am using is: dd if=/dev/sdb of=/dev/sdc ...
dd was useful in the old days when people used tapes (when block sizes mattered) and when simpler tools such as cat might not be binary-safe. Nowadays, dd if=/dev/sdb of=/dev/sdc is a just complicated, error-prone, slow way of writing cat /dev/sdb >/dev/sdc. While dd still useful for some relatively rare tasks, it is ...
Full DD copy from hdd to hdd
1,304,432,287,000
I have a 1TB big file (disk-image from a damaged drive) and a 1.3MB small file (beginning of a disk-file). Using the contents of the small file, I want to overwrite portions of the big file. That is, I want to insert/overwrite the first 1.3MB of the 1TB-image using the small file. Using small temporary files for test...
If you use the conv=notrunc argument, you can replace just the first however many bytes. e.g. dd conv=notrunc if=small.img of=large.img root@debian:~/ddtest# dd if=/dev/zero of=file1.img bs=1M count=10 10+0 records in 10+0 records out 10485760 bytes (10 MB) copied, 1.14556 s, 9.2 MB/s root@debian:~/ddtest# dd if=/dev...
Is dd able to overwrite parts of a file? [duplicate]
1,304,432,287,000
I am running the following command on an ubuntu system: dd if=/dev/random of=rand bs=1K count=2 However, every time I run it, I end up with a file of a different size. Why is this? How can I generate a file of a given size filled with random data?
You're observing a combination of the peculiar behavior of dd with the peculiar behavior of Linux's /dev/random. Both, by the way, are rarely the right tool for the job. Linux's /dev/random returns data sparingly. It is based on the assumption that the entropy in the pseudorandom number generator is extinguished at a ...
Why does dd from /dev/random give different file sizes?
1,304,432,287,000
I like to clone a whole partition or a whole hard drive onto a larger external disk but like to create a sparse file. I often use dd for cloning, but it doesn't support sparse files. As a workaround I used something like: cp --sparse=always <(dd if=/dev/sda1 bs=8M) /mount/external/backup/sda1.raw However this is a li...
You want dd_rescue. dd_rescue -a -b 8M /dev/sda1 /mount/external/backup/sda1.raw The copy may be interrupted at any time by Ctrl-C, showing the current position. This value can be used, when restarting by adding -s and the position to the original command, e.g. dd_rescue -a -b 8M -s 42000k /dev/sda1 /mount/external/...
Clone whole partition or hard drive to a sparse file
1,304,432,287,000
Say you want to zero-out a failing hard disk. You want to overwrite as much as possible with zeros. What you don't want is: the process aborts on the first write-error. How to do that? AFAICS, plain dd only provides an option for ignoring read errors. Thus, something like dd if=/dev/zero of=/dev/disk/by-id/lousy-vendo...
I prefer badblocks in destructive write mode for this. It writes, it continues doing so when it hits errors, and finally it tells you where those errors were, and this information may help you decide what to do next (Will It Blend?). # badblocks -v -b 4096 -t random -o badblocks.txt -w /dev/destroyme Checking for bad ...
How to ignore write errors while zeroing a disk?
1,304,432,287,000
I have read this quote (below) several times, most recently here, and am continually puzzled at how dd can be used to patch anything let alone a compiler: The Unix system I used at school, 30 years ago, was very limited in RAM and Disk space. Especially, the /usr/tmp file system was very small, which led to problems ...
Let's try it. Here's a trivial C program: #include <stdio.h> int main(int argc, char **argv) { puts("/usr/tmp"); } We'll build that into test: $ cc -o test test.c If we run it, it prints "/usr/tmp". Let's find out where "/usr/tmp" is in the binary: $ strings -t d test | grep /usr/tmp 1460 /usr/tmp -t d prints t...
Patching a binary with dd
1,304,432,287,000
I create a 1TB file with random data with dd if=/dev/urandom of=file bs=1M count=1000000. Now I check with kill -SIGUSR1 <PID> the progress and get the following: 691581+0 Datensätze ein 691580+0 Datensätze aus 725174190080 Bytes (725 GB) kopiert, 86256,9 s, 8,4 MB/s 800950+1 Datensätze ein 800950+0 Datensätze aus 839...
Summary: dd is a cranky tool which is hard to use correctly. Don't use it, despite the numerous tutorials that tell you so. dd has a “unix street cred” vibe attached to it — but if you truly understand what you're doing, you'll know that you shouldn't be touching it with a 10-foot pole. dd makes a single call to the r...
Create random data with dd and get "partial read warning". Is the data after the warning now really random?
1,304,432,287,000
I need to copy one disk to another. I tried with the command below and it takes nearly a day to copy 1 TB of disk in federo. dd if=/dev/sda of=/dev/sdb I have tried the same on a Unix(HP-UX) system with the command below and it completes within a few hours dd if=/dev/sda of=/dev/rdsk What is the alternative I could...
dd has many (weird) options, see dd(1). You should explicitly state the buffer size, so try dd if=/dev/sda of=/dev/sdb bs=16M IIRC, the default buffer size is only 512 bytes. The command above sets it to 16 megabytes. You could try something smaller (e.g. bs=1M) but you should use more than the default (especially on...
Why dd takes too long?
1,304,432,287,000
I'm working on an embedded system with the busybox version of dd. I'm trying to test an erase to the drive from some outside utility, however dd does not read from the disc again after the erase, but shows me the cached data. I've narrowed it down to dd as when I do an initial dd, see the data, restart my system to fl...
You could try sync echo 3 > /proc/sys/vm/drop_caches which drops all sorts of caches. For details see /usr/src/linux/Documentation/sysctl/vm.txt on drop_caches. Note: the question was about busybox dd which did not support iflag=direct at the time. It was added in busybox v1.33.0 (2020-12-29), see busybox dd: support...
Force dd not to cache or not to read from cache
1,304,432,287,000
I am under the following restrictions: I have a 1.0 GB .zip file on my computer which contains one file, a disk image of raspbian. When uncompressed, this file is 3.2 GB large and named 2015-11-21-raspbian-jessie.img. After having downloaded the zip file, I have just under 1.0 GB of storage space on my computer, not ...
Use unzip -p: unzip -p 2015-11-21-raspbian-jessie.zip 2015-11-21-raspbian-jessie.img | dd of=/dev/sdb bs=1M -p extracts files to stdout
How to unzip and dd a disk image to an SD Card with a single command?
1,304,432,287,000
Edited: do not run this to test it unless you want to destroy data. Could someone help me understand what I got? dd if=/dev/zero of=/dev/sda bs=4096 count=4096 Q: Why specifically 4096 for count? dd if=/dev/zero of=/dev/sda bs=512 count=4096 seek=$(expr blockdev --getsz /dev/sda - 4096) Q: What exactly does this do?...
dd if=/dev/zero of=/dev/sda bs=4096 count=4096 Q: why 4096 is particularly used for counter? This will zero out the first 16 MiB of the drive. 16 MiB is probably more than enough to nuke any "start of disk" structures while being small enough that it won't take very long. dd if=/dev/zero of=/dev/sda bs=512 count=...
What does `dd if=/dev/zero of=/dev/sda` do
1,304,432,287,000
From the Arch Linux Wiki: https://wiki.archlinux.org/index.php/USB_flash_installation_media # dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx status=progress && sync [...] Do not miss sync to complete before pulling the USB drive. I would like to know What does it do? What consequences are there if left out? Notes...
The dd does not bypass the kernel disk caches when it writes to a device, so some part of data may be not written yet to the USB stick upon dd completion. If you unplug your USB stick at that moment, the content on the USB stick would be inconsistent. Thus, your system could even fail to boot from this USB stick. Syn...
Why is sync so important when making a bootable linux usb stick?
1,304,432,287,000
I would like to create a 100GB file to use as a file-system. The file will be stored on an encrypted volume, so the file/file-system itself does not need to be (further) encrypted. Searching has revealed many different methods of doing this. Some use losetup, some don't. Is the following an acceptable method? $ dd if=...
BS and COUNT should be lowercase: dd if=/dev/zero of=~/theFile.img bs=1M count=10240 you need to make the /media/MountPoint directory if it doesn't already exist: sudo mkdir -p /media/MountPoint Apart from those two things, what you have there should work. It's usually better to be explicit than rely on implicit beh...
Create file image container
1,304,432,287,000
I have a file that I want to pad until it reaches 16 MiB (16777216 bytes). Currently it is 16515072 bytes. The difference is 262144 bytes. How do I pad it? This doesn't seem to be working: cp smallfile.img largerfile.img dd if=/dev/zero of=largerfile.img bs=1 count=262144
Besides the answers to get a physical padding you may also leave most of the padding space in the file just empty ("holes"), by seeking to the new end-position of the file and writing a single character: dd if=/dev/zero of=largerfile.txt bs=1 count=1 seek=16777215 (which has the advantage to be much more performant, ...
How to pad a file to a desired size?
1,304,432,287,000
What's the difference between two dd commands that have different bs and count values, as long as they multiply to the same? For example: dd if=/dev/random of=aa bs=1G count=2 dd if=/dev/random of=aa bs=2G count=1
As far as the end result is concerned, they will do the same. The difference is in how dd would process data. And actually, both your examples are quite extreme in that regard: the bs parameter tells dd how much data it should buffer into the memory before outputting it. So, essentially, the first command would try t...
What's the difference between these two dd commands?
1,304,432,287,000
I have 200 GB free disk space, 16 GB of RAM (of which ~1 GB is occupied by the desktop and kernel) and 6 GB of swap. I have a 240 GB external SSD, with 70 GB used1 and the rest free, which I need to back up to my disk. Normally, I would dd if=/dev/sdb of=Desktop/disk.img the disk first, and then compress it, but maki...
Technically you don't even need dd: gzip < /dev/drive > drive.img.gz If you do use dd, you should always go with larger than default blocksize like dd bs=1M or suffer the syscall hell (dd's default blocksize is 512 bytes, since it read()s and write()s that's 4096 syscalls per MiB, too much overhead). gzip -9 uses a L...
On-the-fly stream compression that doesn't spill over into hardware resources?
1,304,432,287,000
I've used dd to clone disks like this: dd if=/dev/sdb of=/dev/sda bs=4096 conv=notrunc,noerror,sync And it's always worked fine. Any and all docs on 'dd' take pains to remind you that the target disk must be the same size or bigger than the source. Does that absolutely have to be true? Now, I quite understand that...
As others have mentioned here using just dd won't work due to the copy of the GPT table placed at the end of the disk. I have managed to perform a migration to a smaller drive using the following method: First - boot into liveCD distro of your choice. Resize the source drive partitions to indeed fit within the smaller...
can 'dd' be used to clone to a smaller HDD, knowing that partitions will need editing?
1,304,432,287,000
The first 2 lines in dd stats have the following format: a+b records in c+d records out Why 2 numeric values? What does this plus sign mean? It's usually a+0, but sometimes when I use bigger block size, dd prints 0+b records out
It means full blocks of that bs size plus extra blocks with size smaller than the bs. pushd "$(mktemp -d)" dd if=/dev/zero of=1 bs=64M count=1 # and you get a 1+0 dd if=1 of=/dev/null bs=16M # 4+0 dd if=1 of=/dev/null bs=20M # 3+1 dd if=1 of=/dev/null bs=80M # 0+1 _crap=$PWD; popd; rm -rf "$_crap"; unset _crap # frost...
What does the two numbers mean respectively in dd's “a+b records” stats?
1,304,432,287,000
There is probably simple trick to do this, but I can't figure from man page. How do I cut last 1MB from file with undetermined size for example, by using dd?
Well, assuming you have stat and bash, you can get the file size with: stat -c %s your_file If you want to extract the last $amount bytes for that file with dd, you could: dd if=your_file of=extracted_part \ bs=1 count=$amount \ skip=$(( $(stat -c %s your_file) - $amount )) But the saner approach would be to u...
Use `dd` to cut file end part
1,304,432,287,000
I have a 1 TB file. I would like to read from byte 12345678901 to byte 19876543212 and put that on standard output on a machine with 100 MB RAM. I can easily write a perl script that does this. sysread delivers 700 MB/s (which is fine), but syswrite only delivers 30 MB/s. I would like something more efficient, prefera...
This is slow because of the small block size. Using a recent GNU dd (coreutils v8.16 +), the simplest way is to use the skip_bytes and count_bytes options: in_file=1tb start=12345678901 end=19876543212 block_size=4096 copy_size=$(( $end - $start )) dd if="$in_file" iflag=skip_bytes,count_bytes,fullblock bs="$block_...
Read the middle of a large file
1,304,432,287,000
I tried dd, dd_rescue and ddrescue, all failed. I thought these tools bypass the filesystem and make a bitwise copy. dd is fooled, it finishes but just produces a small file and states it's finished. dd_rescuse and ddrescue are complaining about read errors and are intolerably slow. These tools can copy only a few MB ...
I think that the simplest answer is that dd, dd_rescue and ddrescue are not designed to defeat copy protection schemes. They make no assumptions about the format of the data and try to maintain the integrity of the whole of the original on disk data. In the case of dd I suspect that it is terminating due to an intenti...
Why can't I copy my DVD with dd?
1,304,432,287,000
I have 2 exactly same formatted, same size and same brand SD-cards. I would like to dd image to /dev/disk2 and to /dev/disk3 at the same time. Pseudocode sudo dd bs=1m if=/Users/masi/2016-05-10-raspbian-jessie.img of={/dev/disk2,/dev/disk3} How can you dd from one input to many output SDs?
Borrowing from don_crissti's answer using tee, but without dd or bashisms: sudo tee /dev/disk2 /dev/disk3 > /dev/disk4 < masi.img Using pee from Debian's moreutils package: sudo dd if=masi.img | \ pee "dd of=/dev/disk2" "dd of=/dev/disk3" "dd of=/dev/disk4" With bash, ksh, or zsh, that can be abbreviated to: s...
dd: write to multiple disks?
1,304,432,287,000
I used dd to backup a 80GB drive dd if=/dev/sdb of=~/sdb.img Now I need to access some files on that drive, but I don't want to copy the ".img" back over the drive. mount ~/sdb.img /mnt/sdb doesn't work either. It returns : mount: you must specify the filesystem type I tried to find the filesystem type with file -s...
When you use dd on /dev/sdb instead of /dev/sdb1 or /dev/sdb2, you copy all the partitions from the said drive into one file. You must mount each partition separately. To mount a partition from a file, you must first find out where in the file that partition resides. Using your output from file -s sdb.img we find th...
How do I mount an `img` created with /bin/dd of a hard drive?
1,304,432,287,000
# dd if=2013-Aug-uptime.csv bs=1 count=1 skip=3 2> /dev/null d # dd if=2013-Aug-uptime.csv bs=1 count=1 skip=0x3 2> /dev/null f Why the second command outputs a different value? Is it possible to pass the skip|seek offset to dd as an hexadecimal value?
Why the second command outputs a different value? For historical reasons, dd considers x to be a multiplication operator. So 0x3 is evaluated to be 0. Is it possible to pass the skip|seek offset to dd as an hexadecimal value? Not directly, as far as I know. As well as multiplication using the operator x, you can suffi...
passing dd skip|seek offset as hexadecimal
1,304,432,287,000
I've read about how to make hard drives secure for encryption, and one of the steps is to write random bits to the drive, in order to make the encrypted data indistinguishable from the rest of the data on the hard drive. However, when I tried using dd if=/dev/urandom of=/dev/sda in the past, the ETA was looking to be ...
dd if=/dev/urandom of=/dev/sda, or simply cat /dev/urandom >/dev/sda, isn't the fastest way to fill a disk with random data. Linux's /dev/urandom isn't the fastest cryptographic RNG around. Is there an alternative to /dev/urandom? has some suggestions. In particular, OpenSSL contains a faster cryptographic PRNG: opens...
Fast Way to Randomize HD?
1,304,432,287,000
What is the console equivalent of the following Python code: target = file("disk", "w") # create a file target.seek(2*1024*1024*1024) # skip to 2 GB target.write("\0") target.close() Maybe some dd incantation? The idea is making a file with the apparent size of 2 GB for use e.g. in virtualization. kvm disk -cd wha...
Generally speaking, just use dd; but as you mention the use of KVM virtualization, you might consider using qemu-img: qemu-img create -f raw disk 2G It does the same as the dd command in the answer of Chris Down, effectively. Regardless of what command you use, for use in virtualization, I would strongly suggest usin...
How can you trim files using the command line?
1,304,432,287,000
I need to concatenate chunks from two files: if I needed concatenate whole files, I could simply do cat file1 file2 > output But I need to skip first 1MB from the first file, and I only want 10 MB from the second file. Sounds like a job for dd. dd if=file1 bs=1M count=99 skip=1 of=temp1 dd if=file2 bs=1M count=10 of...
dd can write to stdout too. ( dd if=file1 bs=1M count=99 skip=1 dd if=file2 bs=1M count=10 ) > final_output
dd: multiple input files
1,304,432,287,000
I want to back up my SSD using the Linux dd command, but I'm not sure how reliable that method will be. I think I read somewhere that dd does not check for or report errors, so obviously if true then it will be a deal breaker. This will be the command: sudo dd status=progress bs=512K if=/dev/nvme0n1 of=/media/d/ssd.im...
TLDR: Use ddrescue It supports resume/continue capabilities, has automatic logs, and tons of other options. More at the ddrescue home page. Example syntax: ddrescue /dev/sde yourimagename.image sde.log IF you want to (given your comment mentioning restoring) restore the image from the command above onto another drive...
Is "dd" a reliable tool to make an SSD image?
1,304,432,287,000
I have a bunch of Class 10 UHS-1 SDHC SD cards from different manufacturers. They are all partitioned as follows $ sudo fdisk -l /dev/sdj Disk /dev/sdj: 14.9 GiB, 15931539456 bytes, 31116288 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal):...
Did you compare their contents immediately after writing the duplicated contents? If yes, they should come out exactly the same. For example, # Duplicate dd bs=16M if=/dev/sdg of=/dev/sdk # Comparing should produce no output cmp /dev/sdg /dev/sdk # Compare, listing each byte difference; also no output cmp -l /dev/sdg...
Why do these duplicated SD cards have different sha1sums for their content?
1,444,865,232,000
I used shred to wipe my external hard disk: sudo shred -vz /dev/sdb I should also add that the disk had 5 bad sectors. I want to verify the disk has been zeroed, per https://superuser.com/questions/1510233/is-there-a-faster-way-to-verify-that-a-drive-has-been-fully-zeroed I'm not that familiar with dd, but I believe t...
Has the disk been zeroed? Yes. The output of your dd command shows that it has written 5000981077504 bytes. Your cmp command says that it's reached EOF (end of file) after 5000981077504 bytes, which is the same. Be aware that this only works well with hard drives. For solid-state devices, features such as wear level...
How can I verify that my hard disk has been zeroed / wiped?
1,444,865,232,000
So I'm trying to split a 64MB file FileCarve.001 into 512 byte segments (each block is 512 bytes long). I need to make sure the file has the same data when split into smaller files, so I cat all the files to standard out and pipe it into sha256sum (there's a lot of files, so I need to do this with find and xargs). Spl...
The order find processes the files is not deterministic. It may be just the same order as the underlying system call gives, which probably depends on the underlying filesystem structure and can be essentially random. Some implementations might process the list somehow, but don't expect it to be sorted. Let's try with ...
Splitting a small file into 512 byte segments changes it, but splitting it in 1k segments doesn't
1,444,865,232,000
I am using dd to do a network transfer of a disk image to an sd card on my BeagleBone. Using pkill -USR1 -n -x dd in an ssh connection to this BeagleBone gives me a status update of the transfer process, which is great. I am just curious how it is actually working so I can use it effectively in the future. After read...
This is behavior specific to dd. From the dd man page: Sending a USR1 signal to a running 'dd' process makes it print I/O statistics to standard error and then resume copying. $ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid 18335302+0 records in 18335302+0 records out 9387674624 bytes (...
What does the command pkill -USR1 -n -x dd mean exactly?
1,444,865,232,000
Earlier I was using fsarchiver to create compressed partition image. Due to some weird behavior I am choosing to replace it with dd. However, I like how fsarchiver compressed with zstd. So, I studied, How to make a disk image and restore from it later? Using DD for disk cloning Making full disk image with DD compre...
Using dd like that (without any options) will make your life miserable. Just cut it out entirely. Or at the very least increase its block size and tell it not to object to short reads. Without dd, first run sudo -s to get a root shell: gzip </dev/sda2 >/media/mint/Data/_Fsarchiver/MintV1.img.gz gunzip </media/mint/...
compressing and decompressing dd image - zstd instead of gzip
1,444,865,232,000
I have the below shell script and I wonder whether oflag's direct does the syncing automatically or if it is explicitly required: dd bs=10M oflag=direct,sync of=ofile.bin Also what is the difference in saying oflag=sync and conv=sync and conv=fsync? What impact does it have if I change the code to the line below? dd ...
We can probably rule out conv=sync to start with. It does something rather different, which I expect you do not want :-). pad every input block with NULs to ibs-size; when used with block or unblock, pad with spaces rather than NULs oflag=direct does not sync automatically on its own.[*] conv=fsync differs fr...
dd command oflag direct and sync flags
1,444,865,232,000
I'm overwriting my hard drive with random data using the good old dd: dd if=/dev/urandom of=/dev/disk/by-uuid/etc bs=512 It's a 2TB array and my MacBook (running Linux, ok?) can only write data at around 3.7MB/s, which is pretty pathetic as I've seen my desktop at home do 20MB/s. When I go home tonight, I'd like to s...
As @don_crissti already commented, just use seek= to resume. dd if=/dev/urandom of=/dev/disk/by-uuid/etc bs=512 seek=464938971 GNU dd also supports seeking in bytes, so you can resume exactly, regardless of blocksize: dd if=/dev/urandom of=/dev/disk/by-uuid/etc bs=1M \ seek=238048755782 oflag=seek_bytes A larger ...
Resuming a DD of an entire disk
1,444,865,232,000
Is there a utility (or some shell magic) that allows me to compare two block devices? Details: I have one large (0.5 TB) RAID device that I've backed up to a slightly larger SATA device using dd. The device has several partitions on it, however I copy from the 'parent' device and not the partitioned device nodes (e.g...
I would use the command cmp /dev/hda /dev/hdb it will stop at the first differing byte, writing out its offset, or on EOF on the shorter one.
Comparison of raw block devices
1,444,865,232,000
I am trying to clone a 500 GB SSD to a 1TB SSD. For some reason, it keeps failing when the data being copied reaches 8GB. This is the third 1TB SSD I've tried this on and they all get stuck at the same place. I've ran the following command: dd if=/dev/sda of=/dev/sdb bs=1024k status=progress I've also tried to clo...
The error is, dd: error reading '/dev/sda': Input/output error, which tells you that the problem is reading the source disk and not writing to the destination. You can replace the destination disk as many times as you like and it won't resolve the issue of reading the source. Instead of using dd, consider rescuing the...
Why does my dd Full Disk Copy Keep failing at 8 GB?
1,444,865,232,000
What exactly does this do? I don't understand how you could access base memory with this...seems kinda weird. Is it safe? dd if=/dev/urandom of=/dev/mem
Don't try this at home! It can crash your system, and if you're really unlucky it could damage a peripheral or make your computer unbootable. Actually, on most platforms, it just fails with an error, but that depends on the hardware architecture. There is most definitely no guarantee that this is harmless unless you r...
Is dd if=/dev/urandom of=/dev/mem safe?
1,444,865,232,000
Will # dd if=/dev/zero of=/dev/sda wipe out a pre-existing partition table? Or is it the other way around, i.e, does # fdisk /dev/sda g (for GPT) wipe out the zeros written by /dev/zero?
Will dd if=/dev/zero of=/dev/sda wipe out a pre-existing partition table? Yes, the partition table is in the first part of the drive, so writing over it will destroy it. That dd will write over the whole drive if you let it run (so it will take quite some time). Something like dd bs=512 count=50 if=/dev/zero of=/dev...
Will dd if=/dev/zero of=/dev/sda wipe out a pre-existing partition table?
1,444,865,232,000
On my current Linux system (Debian Jessie amd64), I'm getting different behavior for dd using /dev/urandom (/dev/random behavior is properly documented). If I naively want 1G of random data: $ dd if=/dev/urandom of=random.raw bs=1G count=1 0+1 records in 0+1 records out 33554431 bytes (34 MB) copied, 2.2481 s, 14.9 M...
If you check Reading from /dev/urandom gives EOF after 33554431 bytes and follow the discussion, it points to another bug report where Ted Tso states... ...that commit 79a8468747c5 causes reads larger than 32MB results in a only 32MB to be returned by the read(2) system call. That is, it results in a short read....
Why does dd from /dev/urandom stops early? [duplicate]
1,444,865,232,000
The manpage for dd notes an option swab swab swap every pair of input bytes Why? Don't ask me what I'm trying to do -- I'm not doing anything in particular, I'm just scratching my head. If were going to offer swaps, why not do it for all word sizes? Not that I need that, but if we're just swapping 2 neighborin...
Because that was its original purpose. In the words of Douglas McIlroy, who was the head of the team that created Unix, in A Research UNIX Reader: Annotated Excerpts from the Programmer’s Manual, 1971-1986: DD (v5 page 74) Originally intended for converting files between the ASCII, little-endian, byte-stream world of...
Why does `dd` have `swab` functionality
1,444,865,232,000
Just hit this problem, and learned a lot from the chosen answer: Create random data with dd and get "partial read warning". Is the data after the warning now really random? Unfortunately the suggested solution head -c is not portable. For folks who insist that dd is the answer, please carefully read the linked answer ...
Unfortunately, to manipulate the content of a binary file, dd is pretty much the only tool in POSIX. Although most modern implementations of text processing tools (cat, sed, awk, …) can manipulate binary files, this is not required by POSIX: some older implementations do choke on null bytes, input not terminated by a ...
What's the POSIX way to read an exact number of bytes from a file?
1,444,865,232,000
I just made a backup of an entire hard drive (50GB) over ssh via: dd if=/dev/hda | buffer -s 64k -S 10m | ssh myuser@myhost "cat > ~/image.img" What's now the best way to check the integrity of the file image.img, i.e. how to verify that everything is copied correctly?
If the command terminated successfully, then the backup is correct, barring a hardware fault (which could equally affect any verification you might perform). It may later become incorrect if the hardware is faulty, but most storage hardware detects corruption. There is one caveat here: in a pipeline, the shell doesn't...
How to check integrity of a dd backup?
1,444,865,232,000
The dd manual page is very limited on this: ` status=LEVEL The LEVEL of information to print to stderr; 'none' suppresses everything but error messages, 'noxfer' suppresses the final transfer statistics, 'progress' shows periodic transfer statistics This does no...
The first number (1207841280) is the number of bytes copied so far. The second number is this interpreted as the SI unit Gigabytes (1 GB is 10003 bytes). The third number is this interpreted as the IEC unit Gibibytes (1 GiB is 10243 bytes). Notice the difference between "GB" and "GiB". The source code of the dd comman...
How do I interpret the output of dd when the option status=progress is chosen?
1,444,865,232,000
Pseudocode but originally developed for Windows 7 iso file but applied for Windows 8 in the thread How to create bootable Windows 8 iso image in Linux? but it does not work with Windows 10 iso # https://rwmj.wordpress.com/2010/11/04/customizing-a-windows-7-install-iso/ # https://unix.stackexchange.com/a/312477/16920 $...
The only reliable solution which I found for the case. Create bootable Windows in Windows.
How to Create Bootable Windows 10 image in Debian?
1,444,865,232,000
When running dd command to copy an ISO on Linux, I get a single progress print that stays open for a long time (many minutes). Then another at the end. The problem seems to be that a very large cache is being used which confuses dd 's output. sudo dd bs=4M if=my.iso of=/dev/sdc status=progress Output (first line show...
From the first line we can tell dd has read and written 1.5GB in one second. Even an SSD can't write that fast. What happened is that the /dev/sdc block device accepted it (writeback), but didn't send it to disk but buffered it and started writing to disk at the rate the disk can take it. Something like 3MiB/s. The sy...
How to prevent dd's progress from being meaningless on Linux?
1,444,865,232,000
I have to backup my hard disk. I want to use dd and put the image on an external hdd. Can I do this using dd from the OS that resides on the hdd itself or do I have to boot from another device, for example a LiveCD? Is it safe, in general, to take the image of a device, if the device is mounted and working? What if t...
In general it is not safe. The FS assumes that operations are written in certain order so it can write new data of file and then make a pointer to it from other data, the exact details depend on filesystem. Imagine if following happens: dd reads from location X which contains garbage or some data Filesystem writes to...
Is it safe to take the drive image of the current working drive?
1,444,865,232,000
I had a 32GB SD Card with this structure (or very close): luis@Fresoncio:~$ sudo fdisk -l Disk /dev/mmcblk0: 29.2 GiB, 31393316864 bytes, 61315072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Di...
Assuming sda is your 64GB source SD card and sdb is your 32GB destination SD card. You can limit dd to only copy the number of required sectors with: dd if=/dev/sda of=/dev/sdb bs=512 count=61315072
Using DD to copy only half (part) of removable device
1,444,865,232,000
Besides the explanations from the man pages and --help information, in which way do the commands dd, cp and rsync differ when used to copy files? In which context is each of these superior to the others, for some definition of 'superior', so that it should get preference of use?
They are completely different animals that better fit on different file or device manipulation cases: dd This command was created as a "copy and convert" utility, originally intended for converting files between the ASCII, little-endian, byte-stream world of DEC computers and the EBCDIC, big-endian, appearing at t...
What is the difference between `dd`, `cp` and `rsync`? [closed]
1,444,865,232,000
I have a partition sdb1 of size 3.3 GB. From 3.3 GB only 1.9 GB is used and 1.2 GB is an empty space. I want to create an image of this partition. But I want the image to only have the used space i.e. 1.9 GB Now when I run a command using dd: dd if=/dev/sdb1 of=/home/data/Os.img bs=1M status=progress I saw behavior ...
This has been answered here. First make an image of the partition. Then use losetup to mount the image. As it's not a disk but a partition, you don't need the partscan flag. # lsblk # losetup --find foo.img Lookup the newly created loop device # lsblk loop1 7:1 0 4096M 0 loop Zero out the remaining space ...
Create an image of the partition (only the used space)
1,444,865,232,000
I am experimenting with some old SCSI tape drives, and I have successfully written some data to a tape, but I am struggling trying to read it back again. # tar tvf /dev/st0 tar: /dev/st0: Cannot read: Cannot allocate memory tar: At beginning of tape, quitting now tar: Error is not recoverable: exiting now # dd if=/...
Ok, I think I've worked this out. TL;DR Use dd with a large block size to read from the tape instead: dd if=/dev/nst0 bs=1M | tar tvf - Background When you write to tapes, the data is written in units called blocks. These are like sectors on a hard disk. Where hard disk blocks were fixed at 512-bytes for many years...
"Cannot allocate memory" when reading from SCSI tape
1,444,865,232,000
Prior to running the dd command, the command lsblk returned the output below: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931.5G 0 disk The command dd if=/dev/urandom of=/dev/sda conv=fsync status=progress is run. The device however loses power and shuts down. When...
Several possibilities: Linux supports a lot of different partition table types, some of which use very few magic bytes, and then it's easy to mis-identify random data (*) [so it's possible to randomly generate a somewhat "valid" partition table]. Some partition table types have backups at the end of the disk as well ...
Why does writing random data using dd result in disk partitions?
1,444,865,232,000
I'm trying to find the first non-zero byte (starting from an optional offset) on a block device using dd and print its offset, but I am stuck. I didn't mention dd in the title as I figured there might be a more appropriate tool than dd to do this, but I figured dd should be a good start. If you know of a more appropri...
You can do this using cmp, comparing to /dev/zero: cmp /path/to/block-device /dev/zero cmp will give you the offset of the first non-zero byte. If you want to skip bytes, you can use GNU cmp’s -i option, or if you’re not using GNU cmp, feed it the appropriate data using dd: cmp -i 100 /path/to/block-device /dev/zero ...
How do I find the first non-zero byte on a block device, with an optional offset?
1,444,865,232,000
I have been trying to format an sd card with the lastest debian jessie-lite image for use with raspberry pi. When using the dd command, it states that there is no space left on device after copying 10 megs. I have searched SE and have tried to use various answers to questions but I always end up back at the same pla...
-rw-r--r-- 1 root root 10485760 Mar 3 22:04 /dev/sdb /dev/sdb is a regular file, not a device. You must have run rm /dev/sdb at some point. It is created automatically when the device is inserted, but when you run commands as root, you can mess up with it. Now that /dev/sdb is a regular file, it's stored in memory...
dd command indicates not enough disk space - trying to format sd card for raspberry pi
1,444,865,232,000
If I were to use the dd command as follows: dd if=/dev/zero of=/dev/sdX bs=16M What happens at the end of the disk if it is not an exact multiple of 16M? Does that mean the last remaining portion of the disk is not zeroed? I noticed in https://www.marksanborn.net/howto/wiping-a-hard-drive-with-dd/, he writes that th...
The whole output device is wiped whether its size is a multiple of the block size you pass to dd or not. The notrunc flag has no effect when the output is a device file, because truncating a device file has no effect. If the output was a regular file, it would have the effect that the output file is not truncated befo...
dd command bs option at end of disk
1,444,865,232,000
I have a CentOS 6 server with two hard drives in it. My old 3TB drive has been giving me some issues so I'm moving things over to a new drive. Because my / and /home partition are managed by a LVM it was easy to migrate those to the new drive. Now I want to move over my /boot partition and the MBR that makes it all...
If the two hard-disks are of the same size (or the new one is bigger), why didn’t you just copy the old disk to the new disk? I.e. dd if=/dev/sda of=/dev/sdb Now, if the new hard-disk is bigger, change the partition sizes with parted or gparted. All this done booting from a live CD/USB-stick.
Moving /boot and MBR to a new drive