date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,576,861,160,000
I have a local machine that needs be migrated to remote disk. How can I do it with dd? I know local format for command dd if=/dev/sdx of=/dev/sdx count=x bs=x But how to do it via ssh direct from local to remote?
You should run two instances of dd in that case, one in the local host and the other one on the remote host (through ssh.) To make that work, you would omit the of= argument, to have dd write the blocks to stdout (which you can write to a pipe), or omit if= to read from stdin (from a pipe.) For example, copying from l...
How to dd a local disk into a remote disk?
1,576,861,160,000
I use this dd command for checking disk speed: dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct which gives back something like this: 1 oflag=direct 1+0 records in 1+0 records out 1073741824 bytes (1,1 GB, 1,0 GiB) copied, 8,52315 s, 126 MB/s Now I would like to pipe this output, not the file dd is writing, ...
To be able to insert dd in a pipeline before or after another command, its informational messages are written to standard error rather than to standard output. The OpenBSD manual for dd explicitly mentions this (but the Ubuntu manual seems to omit this fact, but mentions it in the more complete info page): When finis...
How to write dd status/result message to a file?
1,576,861,160,000
If I dd my disk and compress the image with lzma or lzo the image is still big. The partition is 10GB used, 90GB available. But the image still around 20GB. I believe that is because I have copied many and deleted many files on that disk and the filesystem doesn't zero the unused blocks from those deletions. How can ...
The tool you think you're looking for is zerofree, as described in this duplicate question Clear unused space with zeros (ext3,ext4), and already available in most distributions. However, you seem to be asking how to take an image backup of a filesystem that excludes unused blocks. In this instance use fsarchiver, as ...
How can I zero the unused blocks on my filesystem in order to minimize the compressed disk image size? [duplicate]
1,576,861,160,000
I have an img file which I had cloned from a disk of my RISC PC using dd: dd if=/dev/hdb of=RISCPC.IMG The size around 2GB. I want to add 512 null bytes to the start and end of the file. What's the best way to do this using dd?
dd if=/dev/zero of=RISCPC.IMG.new bs=1 count=512 dd if=RISCPC.IMG of=RISCPC.IMG.new bs=512 seek=1 dd if=/dev/zero bs=1 count=512 >> RISCPC.IMG.new mv RISCPC.IMG{.new,} If you can use cat, you might consider this: cat > RISCPC.IMG.new \ <(dd if=/dev/zero bs=512 count=1) \ RISCPC.IMG \ <(dd if=/dev/zero bs=...
Adding null bytes to a file using dd
1,576,861,160,000
I have hdd.img file, which I user as HDD for my virtual machine, but it's size is too small, how can I enlarge it? There is one method, something like: dd if=/dev/zero ds=10GB count=8 >> hdd.img but it takes a lot of time :(
Something like that: dd if=/dev/zero bs=1 seek=new_filesize count=0 of=your_file For example this: dd if=/dev/zero bs=1G seek=1000 count=0 of=test will enlarge file test to 1000G
How to enlarge existing file to specific size
1,576,861,160,000
I'd like to boot a live USB for FreeBSD 11.1 in my UEFI firmware. I tried creating a live USB using: dd if=FreeBSD-11.1-RELEASE-amd64-dvd1.iso of=/dev/sdc bs=4M status=progress && sync Then I tried booting this USB and I got the GRUB message: error: unknown filesystem. Entering rescue mode. grub rescue> There's noth...
You are using the wrong image. At the Release Information page of FreeBSD 11.1, you can get the following info: dvd1 This contains everything necessary to install the base FreeBSD operating system, the documentation, debugging distribution sets, and a small set of pre-built packages aimed at getting a graphical ...
How to create a live USB of FreeBSD 11.1 from Arch Linux?
1,576,861,160,000
I know that with dd if=/dev/urandom of=/dev/sdX bs=1M count=hdd_size_in_MB you can wipe a whole disk with random data. But urandom is very slow. So I wonder if it would be possible to just create only like 100MB-1000MB of random data store it in the RAM and write it multiple times over the whole disk instead of crea...
You have among coreutils the shred command which can rewrite randomly a file or a device. It works by default with the whole file device (a partition for example), but the --size/-s can give it a size. It is quite efficient.
Faster wipe hdd with random data
1,542,829,561,000
I've got a partition P1 (which contains my Linux OS) on a drive A. I've just gotten a completely new drive B (that is larger than partition P1 AND the entire drive A). I'd like to copy across the partition from drive A to drive B, and possible resize it later on. Can this be done with dd? I could easily create a new p...
Yes ,that's what dd is for. Assuming: sxb is the drive to copy from sxc is the drive to copy to sxb4 is the fourth partition on the second drive that you want to copy from sxc1 is the partition you've created to be of equal size to sxb4 do : parted /dev/sxc GNU Parted 3.2 Using /dev/sxc Welcome to G...
How can I move a single partition to another empty drive?
1,542,829,561,000
BTRFS RAID1 array with 2 500 GB hdds, no errors. This is the root filesystem, so there are 3 partitions on each drive: 1 = /boot (ext4), 2 = / (btrfs), 3 (swap) /boot is ext4 because upgrading the kernel does not always work if /boot was a btrfs filesystem (new kernel installed but grub config not updated). Now, this ...
Warning: Don't use GParted to resize a multi-device BTRFS filesystem! Data loss likely to happen! Looks like GParted is the culprit. Apparently, it doesn't know how to resize multi-device btrfs filesystems and just runs btrfs filesystem resize but does not take care of each device using resize 1:49g and resize 2:49g. ...
How to fix BTRFS superblock error after resize/shrink (BTRFS: couldn't get super buffer head for bytenr 274877906944)
1,542,829,561,000
I have what I hope is not a huge problem, but it could end up being a very large problem. For some context, I mistakenly ran this command on my 27" iMac: sudo dd if=ubuntu-rescue.img of=/dev/sdt bs=1m After which, it gave me the following output: 233+1 records in 233+1 records out 244570112 bytes transferred in 2.275...
I was surprised to discover that my Mac Book Air does have a /dev/sdt character special device. Since I could not fathom its nature, I looked up my copy of Mac OS X for Unix Geeks. At page 60, there is the list of all entries in /dev. sdt is indeed mentioned, with the unenlightening explanation: sdt Un...
How to inspect the contents of /dev/sdt
1,542,829,561,000
I have saved my whole hard-disk with dd to an image file. The hard-disk contained some primary partitions formatted with ntfs, swap and ext4. I did it this way: dd if=/dev/sda | ssh user@fastmachine "cat - > diskimage.img" Then I have overwritten the first 5 to 6 GB of my hard-disk for testing purposes with a new sys...
Theoretically this can work, there is a caveat though: you must not change the layout of the disk outside of the area you are intending to reconstruct. The important thing is what partitioning scheme was used on the disk. For MBR this is easy, since the data is contained in the first sector (and in headers of logical ...
Is it safe to only partially restore a disk image with dd?
1,542,829,561,000
I currently have multiple full 10, 12, and 14tb drives that I plan on selling. The problem I am facing is that I cant seem to find a decently fast method to to wipe to wipe them that doesn't say it will take 30+ weeks. In regards to the data I really don't care if its done securly or not because that data is literally...
If the data is truly random, then what is on it means nothing, then who cares if anyone reads it. Therefore, just do dd if=/dev/zero of=/dev/sd<whatever> bs=16KB count=1000 That will just wipe the partition data and the first few sectors.
Quickly wiping multiple large 10tb+ drives
1,542,829,561,000
Imagine that I have a disk that is 128GB in size. On this disk, only 12GB is used. 116GB of the disk is empty space containing all zeroes (0x00). I want to take an exact snapshot of the disk such that it can be exactly reconstructed in its current state in the future. To save space in the compressed image I'll pass it...
With an uncompressed (and probably sparse itself) source file, simply using (GNU) cp --sparse=always sourcefile /dev/sdX would be enough: --sparse=WHEN control creation of sparse files. See below By default, sparse SOURCE files are detected by a crude heuristic and the corresponding DEST file is made sparse as well. ...
Write an image to disk but do not write sectors containing all zeroes in the source image?
1,542,829,561,000
I am working with a script that is a self extracting script. It's a script to install packages on a QNAP NAS. It has some scripting at the start which extracts the rest of the file. Here it goes: script_len=102 /bin/dd if="${0}" bs=$script_len skip=1 | /bin/tar -xO | /bin/tar -xzv This uses dd to copy the bytes from...
Let's take a look at a QNAP package, e.g. http://www.twonkyforum.com/downloads/8.3/TwonkyServerEU_8.3_arm-x41.qpkg .... script_len=2467 /bin/dd if="${0}" bs=$script_len skip=1 | /bin/tar -xO | /bin/tar -xzv -C $_EXTRACT_DIR script_len=2467 .... Now let's copy the data with dd, and look what's inside: %dd if=TwonkySer...
Self extracting scripts: tar -xO and dd
1,542,829,561,000
I'm using debootstrap to create a rootfs for a device that I want to then write to an image file. To calculate the size needed from my rootfs, I do the following: local SIZE_NEEDED=$(du -sb $CHROOT_DIR|awk '{print $1}') SIZE_NEEDED=$(($SIZE_NEEDED / 1048576 + 50)) # in MB + 50 MB space dd if=/dev/zero of=$ROOTFS_IMAG...
Possibly the simplest solution is to heavily overprovision the space initially, copy all the files, then use resize2fs -M to reduce the size to the minimum this utility can manage. Here's an example: dir=/home/meuh/some/dir rm -f /tmp/image size=$(du -sb $dir/ | awk '{print $1*2}') truncate -s $size /tmp/image mkfs.ex...
How to calculate the correct size of a loopback device filesystem image for debootstrap?
1,542,829,561,000
I am working with an external HDD and trying to backup a logical partition within an extended partition using dd like this: sudo dd if=/dev/sdb6 of=partition6.dd it returns: dd: opening `/dev/sdb6': No such file or directory I used the exact same method to backup a different partition (primary) with no issues sudo d...
It appears that the device file does not exist. You can verify this by doing ls /dev/sdb6. Try running the command partprobe, or sudo partprobe as user. This should detect the devices and create the according device files. This may return the error Error informing the kernel about modifications to partition /dev/sdb5...
dd can't see partition but cfdisk and GParted can
1,542,829,561,000
I'm copying dd output through netcat with the following command $dd if=/dev/zero bs=1024K count=1 | nc <IP_ADDR> <PORT> -q 0 1+0 enregistrements lus 1+0 enregistrements écrits 1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,0590934 s, 17,7 MB/s However when I try to parse the output nothing happens $ dd if=/dev/zero bs=102...
In dd if=/dev/zero bs=1024K count=1 | nc <IP_ADDR> <PORT> -q 0 | grep copied there's no way that dd status output could go to grep. grep is reading the output of nc, not dd. If dd wrote that output on its stdout, it would go to nc, not grep. Thankfully dd does not write that status message to its stdout (otherwise it...
Separate dd data from output through netcat to parse output
1,542,829,561,000
i just cleaned a 50GB partition with dd if=/dev/zero of=/dev/sda1 then added some data to it (actually installed a linux distro) some 3Gb on ext4. and decided to make a image. dd if=/dev/sda1 | gzip -9 > sda1.dd.gz and to my surprise, that file has 45GB! my thinking would be that the this file would have some 4GB as m...
From OP's comment: Turned out that the install, for some reason, scattered data all over the disk. I redid the cat /dev/zero > /mounted_drive/zero after the install and then removed the file and redid the dd, turned out to be a 1.3Gb file after gzip. With this, the question is effectively answered (and, as a side-ef...
reasons for a dd image of an almost-empty drive not be small after gzip
1,542,829,561,000
I have a zfs server, where I ran a couple of dumb tests just for understanding, and it puzzles me. Context:- FreeBSD 11.2, ZFS with Compression enabled, SAS HDDs, RAIDz2, 768GB of memory. Both commands were run directly on the FreeBSD server. # time dd if=/dev/random of=./test_file bs=128k count=131072 131072+0 recor...
I'm going to reframe your question to highlight some of the context: Why is fio --name=seqwrite --rw=write --bs=128k --numjobs=1 --size=16G --runtime=120 --iodepth=1 --group_reporting faster than time dd if=/dev/random of=./test_file bs=128k count=131072 on a FreeBSD 11.2 system with 768GB RAM, SAS HDDs and ZFS co...
Why is fio seq_writes so much faster than dd?
1,542,829,561,000
I need to create backups of a Ubuntu system in a way that I can easily restore the data and system as it is exactly in a ready to go state. So, I decided to go with dd to create a whole HHD images. I created the image as follows: dd if=/dev/current_drive of=/dev/backup_drive/backup.img conv=sync status=progress The im...
When you dd, source device/filesystem must not be changed/mounted/written to don't use conv with noerror and sync, it corrupts data add bs=1M (or bs=64K) for performance reasons Basically a successful, consistent direct disk copy can only be achieved through an independent system like a Live CD, and even then you ha...
Initramfs error after image restore using dd
1,542,829,561,000
I have a system with two LVM volumes on an eMMC device, and I'm trying to "wipe" one of the volumes by filling it with zeros. This is my first time working with LVM, so I'll show what I tried and didn't have luck with. First I used pvdisplay -m to see how my volumes are set up: # pvdisplay -m --- Physical volume --...
After more testing, it looks like there is an issue with LVM and its relationship with the Linux kernel. I'm guessing that it involves disk caching but I'm not 100% sure. Here's what I found: First I wrote some garbage data to my LVM volume: # dd if=/dev/urandom of=/dev/vg0/volume_b bs=1M count=1 1+0 records in 1+0 re...
Issues zeroing an LVM volume
1,542,829,561,000
I had an Ubuntu 14.04 running on a 1024 GB disk (disk A), which only used up to 130 GB spaces. I want to clone it to a 256 GB SSD disk ( disk B ). But failed. I used gparted to shrink the partitions on disk A to be only about 180 GB for the preparation for disk B successfully. Can you tell me where I was wrong? 1) res...
I am not familiar with sfdisk, but you could accomplish the same thing, partition table AND MBR back up using dd. This was in my notes and I am not the author... Backing up the MBR The MBR is stored in the the first 512 bytes of the disk. It consist of 3 parts: The first 446 bytes contain the boot loader. The next 64...
How to shrink, clone an entire Linux disk and boot it?
1,542,829,561,000
What I have done is clone a small 32GB flash module that had three partitions. I happened to have a 32GB USB lying around, so I thought it might just work; it did not. It seems 32GB from Toshiba is a bit different than 32GB from Sandisk. Anyway, so then took to a 2TB external drive and did the exact same thing. Speci...
Just copy the partitions that you need and the MBR if you need it too. The MBR is stored in the the first 512 bytes of the disk. dd if=/dev/sdX of=/path/to/mbr_file.img bs=512 count=1 Copy each partition dd if=/dev/sdX1 of=/path/to/partition1.img bs=512 dd if=/dev/sdX2 of=/path/to/partition2.img bs=512 dd if=/dev/s...
How to clone an entire disk to a larger disk and then offload?
1,542,829,561,000
at the moment I do some tests with loop devices on Linux/Ubuntu. In a small test script I have the following commands: #!/bin/sh rm testfile.x dd if=/dev/zero of=testfile.x bs=1M count=1200 losetup /dev/loop0 testfile.x cryptsetup --batch-mode --key-file k.kf --cipher aes-xts-plain64 --key-size 512 --hash sha512 --ite...
Loop devices have some pitfalls. Many operations are not instant, for example, when you losetup -d the loop device will be kept alive until it is no longer in use. Devices can be in use even if you're not aware of it, due to background processes scanning devices for uuids and other things. Maybe you should leave the c...
losetup /dev/loop0 disappears after some time
1,542,829,561,000
I am trying to create a ISO image of my executable By hiding few files off the ISO immage as i want the user only to see an EXE and not the other directories when they open in a PC (Windows) is the targeted ENV in which my users will launch the application.
If you have a set of directories that you want to incorporate into a ISO file you can do it using this command: % mkisofs -o ~/my_iso.iso -r -J -hide-rr-moved -V "Title of ISO" \ -graft-points "Directory1/=/home/me/dir1" "Directory2/=/home/me/dir2" The above command switches are as follows: -o = name of output...
how to create ISO and hide certain files
1,542,829,561,000
I used this command sudo dd bs=4M if=/dev/sdb1 | gzip > /home/username/image`date +%d%m%y`.gz to clone my 32gb sd card (there was linux installed for odroid U3) now I have tried to restore it on same SD card with command gzip -dc /home/username/image*.gz | sudo dd bs=4M of=/dev/sdb1 but I get error dd: error writi...
I was trying to restore it to the same SD card (same physical object) dd clone was created with command : sudo dd bs=4M if=/dev/sdb | gzip > /home/username/image`date +%d%m%y`.gz sdb instead of sdb1 (so I have created copy of whole card not only the sdb1 partition) to restore the sd card I have used : gzip -dc /home...
restore dd cloned sd card (No space left on device)
1,542,829,561,000
When using Linux (Debian), I often use dd to copy a disk image to an SD card. I have written a script that throws an error if the device file specified in the "of" option is too large. This keeps me from accidentally blowing away one of my hard disks. SD_SIZE=$(sudo sfdisk -s ${SD_DEV}) if [ $SD_SIZE -gt 33554432 ]; ...
Sometimes the copy succeeds and sometimes it fails. Probably it fail because some process in the while wrote to the mounted filesystem, guess that's why is a good practice to umount before :-) dd should really be just open and write, I guess the MacOSX version add some control and I think is easy to understand why w...
Differences between dd in Mac OS X and Linux
1,542,829,561,000
I need to get a copy of an HDD that is a real 1:1, I mean not just the filesystem but also the geometry and the partition table and everything in between. if I'll just use dd if=/dev/sdb of=/tmp/file this will generate what I'm looking for ?
Yes, this should be fine. Be sure to unmount your disk first and make sure there is enough space in the target directory. /tmp is a tmpfs in memory and not on disk on some systems, look at the output of mount to check. On a root shell you can also simply do: cat /dev/sdb >/tmp/file
1:1 copy with dd
1,542,829,561,000
I have a partition (/dev/sda1) of 10 GB. Also have "dd" file of another 7 GB partition ( /dev/sdb1). When I execute the command as: dd if=sdb1.dd of=/dev/sda1 then everything goes fine but I can not use remaining 3 GB space of /dev/sda1 Is there any way to tell DD to utilize remaining free space ( 3 GB in this cas...
dd does not care about free space (as in the filesystem concept) whatsoever, it just copies block by block. If sdb1.dd is a filesystem image, you may be able to grow it using resize2fs or other tools (depending on the filesystem type) after you copied it. resize2fs /dev/sda1
DD and Free Space
1,542,829,561,000
I'm trying to use the following command: dd if=/dev/urandom of=/dev/sg11 bs=16K count=1 But when executing it, I get the following error: dd: writing `/dev/sg11': Function not implemented When I try with dd if=/dev/urandom of=/dev/sg11 bs=16K count=1 conv=fsync, then I get a cannot allocate memory error, which becom...
/dev/sgxx is a SCSI-generic device, which allows sending and receiving of raw SCSI commands. When you write to the device, you are expected to start the write with a SCSI header, which defines the operation you wish to do. Writing random data to an sg device is really a bad idea. You'll be sending random SCSI commands...
dd outputting: "function not implemented" when trying to write to /dev/sg11
1,542,829,561,000
I'd like to simply duplicate a hard disk drive to another hard disk drive of the same size. I know I can simply do: dd if=/dev/sda of=/dev/sdb (or whatever the names of the drives are in /dev). Is there a better tool for this which will show me visual progress? If I'm only using 30GB of the drive, will it only take ...
You can make GNU dd show you progress - to quote the 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 Schily's dd (sdd) has a similar option and uses SIGQUIT...
Duplicating a hard disk
1,542,829,561,000
I have a 588Ko file, and I want to extract bytes from 0x7E8D6 to 0x8AD5D. I tried : dd if=file of=result bs=50311 count=1 skip=518358 50311 stands for 0x8AD5D - 0x7E8D6 518358 stands for 0x7E8D6 (from where I want to cut) dd tells me that it can't skip to the specified offset. What can I do? Is there any other util...
skip and count are both expressed in blocks. You're asking to skip 518358 × 50311 bytes. dd can let errors go undetected, so it's best avoided anyway. With most Unix variants (including BusyBox but not OpenSBD), you can pass a number of bytes to head and tail. Just remember that tail counts from 1. <file tail -c "$((0...
Use dd to extract a precise portion of a file?
1,542,829,561,000
I have read this post - How to dd a remote disk using SSH on local machine and save to a local disk However, the following code doesn't work: "dd if=/dev/sda | gzip -1 -" | dd of=image.gz As I do not have any /dev/sda directory. I'm assuming this is because I'm using Debian 7.0. Any help to take a complete copy of ...
The device name of a disk depends on what type of disk it is (more precisely, on what type of bus and controller the disk is connected to, and what driver handles them). /dev/sda is the typical name for the first disk in a PC (other names can be used depending on the driver, e.g. for some older types of disk controlle...
How To dd or cp Entire Disk On Debian Remote Machine To Local Machine?
1,542,829,561,000
Before I sell an old HDD I completely read and write the disk to verify that it has no bad sectors. I always did writing like this: dd if=/dev/zero of=/dev/sdb bs=100M status=progress But my computer has 32GB RAM and a lot of the data might be in cache when dd exits. Is there a way to see when the OS fails to write t...
Although you specifically requested not to recommend disk checking tools, I will do so and hereby recommend: The disk itself. You can ask the drive to perform a thorough, internal self-test, eliminating all possible sources of problems regarding caches. The self-test can conveniently be accessed via gsmartcontrol: If...
Using dd to detect bad sectors
1,542,829,561,000
Now the hard disk is 10GB. Added new hard disk with 16GB size. dev/zero information: fdisk -l /dev/zero Disk /dev/zero: 0 MB, 0 bytes, 0 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト Have did partition and format on new /dev/s...
dd's "not enough space" message pops out when device you are writing to has no more space. It means, you successfully finished your writing, there is no more space left to write. [cs-server@cs-server release_script]$ ls /media/182147d8-104d-4194-8d42-d5ccccbd4dd6/ bin boot dev etc home lcc lib logs lost+found ...
Can't run dd from /dev/zero to new added hard disk /dev/sdb on CentOS 7
1,542,829,561,000
I'd basically like to create an allocated file lets say 1GB with content. Then hopefully using some command line utility I'd like to overwrite-in-place a portion of the file, lets say the beginning 4 MB ONLY leaving the rest of the file contents in-tact. I've checked cp, and dd but they don't seem to have anything ...
Example with dd: $ cat data insertion goes here: <...> $ cat insert ABC 123 XYZ $ dd if=insert skip=4 count=3 of=data seek=22 bs=1 conv=notrunc 3+0 records in 3+0 records out 3 bytes transferred in 0.001 secs (2918 bytes/sec) $ cat data insertion goes here: <123> The dd command that I've used here skips 4 blocks i...
Overwrite a portion of a file w/o modification to the unmodified content [duplicate]
1,542,829,561,000
I made an Arch Linux ISO USB drive, and I'm trying to restore it using the directions from the Arch Linux wiki. After running: $ sudo dd count=1 bs=512 if=/dev/zero of=/dev/sde && sync parted only recognizes one sector with 512 bytes: $ sudo parted /dev/sde -s print Error: /dev/sde: unrecognised disk label Model: (f...
(As hinted by Gilles), you are not working on your USB device. Clue number one is the Model on the output of $ sudo parted /dev/sde -s print Error: /dev/sde: unrecognised disk label Model: (file) <= file! ... Your command: sudo dd count=1 bs=512 if=/dev/zero of=/dev/sde && syn...
8GB USB disk listed at only 512B or 10MB?
1,542,829,561,000
I want to use dd to overwrite a disk multiple times to destroy data beyond recovery. I know I could use dd if=/dev/zero/ of=/dev/sdx/ to do a pass with zeros, or dd if=/dev/null/ of=/dev/sdx/ to accomplish similar (not exact same) result, but it will be slower. I was wondering if there is a way to do something where I...
First, dd if=/dev/null of=/dev/sdx ( note there is no trailing / after either device name ) will do nothing, since reading from /dev/null always returns EOF. Rather than using dd, this task is more suited to shred /dev/sdx.
Multiple passes of wiping disk with `dd`
1,367,815,607,000
is there a way to mount and access a single partition on any mountpoint in my filesystem or must I use disk images and mount with offset? I made a partiton image with dd bs=4M if=/dev/sdb1 of=~/part.img and tried to mount it on /mnt with mount -t vfat ~/part.img /mnt. The output of mount is an Unknown Error -1
Yes, it is perfectly possible to mount partition images made with dd. You should add a -o loop (i.e., use a loopback device) to the mount command. The final command should look like: mount -oloop -t vfat ~/part.img /mnt Of course, you should have dd'ed from a valid and previously formatted vfat filesystem in the orig...
mounting partition images made with dd
1,367,815,607,000
I'm trying to reduce the size of a backup drive image. Original disk had these partitions: Model: ST916082 1A (scsi) Disk /dev/sde: 160GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 65.7GB 65.7GB primary ntfs ...
If it's just the dump of the partition, there's no partition table. The partition is the file, you just need to shrink the file: truncate -s 27000832000 datapartition (27000832000 is 26999992832 rounded up to the next MiB just to be on the safe side, would you like for instance to compress it to a qcow2 format or any...
How do I resize a disk image device?
1,367,815,607,000
Man dd: dd - convert and copy a file I'm leaning to use dd. Strangely after copying 1 byte text file becomes much smaller: $ block_size=1; device_to_edit=/media/ramdrive/a; device_from=/media/ramdrive/b; echo "aaaaaaaaaa">$device_to_edit; echo "bbbbbbbbbb">$device_from; cat $device_to_edit; cat $device_from; dd if=$...
What you're doing is this: block_size=1; dd ... count=1 seek=2 skip=2 bs=$block_size; you're asking dd to copy just one byte. But, by default, it truncates the output file, so that the end of file is where dd finished. $ echo abcdefgh > test1 $ echo 12345678 > test2 $ dd count=1 bs=1 skip=2 seek=2 if=test1 of=test2...
Can dd be used for regular small files?
1,367,815,607,000
I'm learning the dd command in Linux. For test purposes, i initiated this command: sudo dd bs=4M if=/dev/mmcblk0 of=/media/some_remote_host/stuff/myImage.img I know that dd is for taking an image of the given disk/drive. But I'm curious whether it includes mounting folders according to Unix file structure (file stru...
dd doesn't know anything about mounts or folders or unix file structure in filesystems. dd only knows about raw data and a few trivial transformations of raw data and data blocks. It was originally designed to read and write data from or to block devices (including disks and tapes) and could handle changing the stru...
DD command included directories
1,367,815,607,000
In the dd command, we can use skip to skip n byte in a file. From nth byte to end of file is copied. But I want to copy binary data from 1228 to 1331 only. How do I achieve this with dd on Linux?
Use the count to specify the number of bytes to copy. Use the shell to do the calculation. Use ibs=1 to set the input block size to 1, so the skip and count are specified in bytes. dd ibs=1 skip=1228 count=$((1331-1228+1)) As 1228 and 1331-1228+1 are both multiples of 4 it would be possible to set the input block si...
dd command to get data of specific range
1,367,815,607,000
My system is running the command sudo dd if=/home/vico/file.iso of=/dev/sdb1, it returns control inmediately, but the transfer takes a while. How to know that the whole process has ended?
Method 1 Rewrite your command like this sudo dd if=/home/vico/file.iso of=/dev/sdb1 status=progress Sample output: 462858752 bytes (463 MB, 441 MiB) copied, 38 s, 12,2 MB/s dd in GNU Coreutils 8.24 (Ubuntu 16.04 and newer) have this status option to display progress. Method 2 Install pv sudo apt-get install pv Some...
How to know when a 'dd' command has been completed?
1,367,815,607,000
I want to fill the free space on my hard drive with a command like that : # dd if=/dev/zero of=z but it causes GNOME to freeze regularly for a few seconds. Even the mouse cursor is affected. How can I prevent dd from freezing the interface when writing huge amounts of data ?
Try using ionice: # ionice -c3 dd if=/dev/zero of=z This start the dd process with the "idle" IO priority: it only gets disk time when no other process is using disk IO for a certain amount of time. Of course this can still flood the buffer cache and cause freezes while the system flushes out the cache to disk. There...
How to prevent dd from freezing my system?
1,367,815,607,000
I'm currently trying to burn the Ubuntu operating system onto a USB flash drive of mine, so I can boot onto Ubuntu with my Chromebook. In order to do this, I executed the following dd command: sudo dd if=ubuntu-14.04.3-desktop-i386.iso of=/dev/sda1 So far, this has been running for 18 hours, and it's appeared have d...
Yeah, so turns out that my Ubuntu disk image had somehow been completely destroyed, and was empty. I simply had thought it hadn't stopped and had kept executing simply because it didn't return to a prompt like this: pi@raspberrypi ~ $
The dd command isn't appear to accomplish anything [closed]
1,367,815,607,000
I was watching this Defcon video and around 4:30 he shows a custom pattern of drive wiping — the drive is filled with a constant text pattern. Whether he is joking or not, is this possible? How would it be done using Linux's dd command?
The drive shown is filled with a repeating text pattern. This is dead easy to do. Not with dd, because dd doesn't do repeated patterns. There's no magic in dd, it's just a tool to copy bytes in slightly weird ways, which is very occasionally useful. The magic is in the block device (e.g. /dev/sda for a disk or /dev/sd...
DD with a specific pattern
1,367,815,607,000
I am confused about the behavior of dd. Say we have some SD card called /dev/foo and this card has partitions /dev/foop0 and /dev/foop1. Using dd, I can set the of argument to /dev/foo and dd won't complain. But what exactly will happen? Will dd just write to the first partition? Or will it overwrite both partitions?...
dd will write at the start of the disk itself, overwriting the partition table in the process. You'll have trashed all the data on that disk (would need recovery software and luck to recover, depending on how much you wrote). Note that this behavior isn't specific to dd, you'd see the same thing with cat or anything e...
dd behavior, default writing and partitions
1,367,815,607,000
If I need to use a my USB drive on an Ubuntu machine I need to mount it first. If my USB device is /dev/sdb1 then I mount it with: mount /dev/sdb1 /home/some_folder Then use /home/some_folder to read and write data to the USB drive. But tools like dd can work directly with the device without a mounting point: dd if=/...
You can use your USB without mounting it. You can use dd or other tools to copy data to it, and copy data from it. It is also common to use storage devices as swap space without mounting them. "Mounting" means attaching a filesystem that resides on a separate storage device to a currently mounted filesystem. This requ...
Why some tools such as dd don't need a mount point to work with a device?
1,367,815,607,000
I'm trying to partition a usb stick to NTFS. Before, I've wrongly flashed a windows iso using dd dd if=./AME_2004_\(2020-09-16\).iso of=/dev/sdc status=progress and since then I've been having problems formatting the drive. Kde Partition Manager, cfdisk and fdisk all yield the same result when trying to partition the...
Looks like your system is automatically mounting any disk it sees. Check if your sdc is mounted somewhere: grep 'sdc' /proc/mounts. If that is the case, then umount -f /dev/sdc a few times, until it's nowhere to be seen in /proc/mounts. When that's done, zero out the disk with dd if=/dev/zero of=/dev/sdc. After that, ...
Weird partition mess on KDE. Read-only file system
1,367,815,607,000
I thought I could nuke all partitions of a drive by using dd if=/dev/zero of=/dev/sdX. In the past this has always worked for me, but in this case it is not working as expected. #check the partitions ➜ ~ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 477G 0 disk ├─sda1 8:1 0 512M 0 pa...
#the partitions are still there! This part, at least, is still normal. You have to re-read partition table to update the partition information. You can trigger a re-read with blockdev --rereadpt /dev/sdx (alternatively sfdisk --re-read but that option has been removed from recent versions of sfdisk). For everythin...
dd if=/dev/zero leaves drive contents in-tact? Bad USB stick?
1,367,815,607,000
I have a bootable disk image file that I'd like to write onto an sd-card. However, I only have a Windows 10 machine available - it has the Windows Subsystem for Linux already installed, Ubuntu runs, and dd is available. I'd like to do sudo dd if=image.img of=/dev/my-sd-card, however the sd-card device does not appear...
I like to use Rufus when performing this type of operation on a Windows machine. This program is great for creating bootable media, particularly when using Linux images. Also, the "DD" function works really well. This software is free and open source. If you insist on using your Ubuntu subsystem, type the comman...
"dd" an image onto an sd-card from Ubuntu in Windows Subsystem for Linux
1,367,815,607,000
I'm using dd to overwrite my hard drive with zeros (before I recycle my laptop). Several minutes into running, the visual display was replaced with a black background and a flashing cursor in the top left of the screen. No text is being written to the screen, so it's not clear to me whether dd is still running or how ...
When dd has written the device full it will output a message: dd: writing to '/dev/full': No space left on device Sending USR1 signal to running dd process makes it output the current status. You can use kill to send the signal: kill -USR1 $PID More recent versions of GNU dd have an option status=progress which will...
How can I tell whether dd is done erasing my hard drive?
1,367,815,607,000
I'm trying to wipe a USB flash drive of 256 MB using the dd command. I entered this command: dd if=/dev/zero of=/dev/sdb and I got this output: 499713+0 records in 499712+0 records out Why there is a difference between the number of full blocks read and written?
dd read an (extra) block from /dev/zero which it could not write to /dev/sdb (since the device was full). You'd get similar results if you interrupted the program.
Why “records in” is different than “records out” in dd command output
1,367,815,607,000
I'm writing some images back to block devices, with dd, and getting very strange output I've never seen before. # xz -dc goren.img.xz | dd bs=1M of=/dev/storage2/goren 35+2475166 records in 35+2475166 records out 21474836480 bytes (21 GB) copied, 222.912 s, 96.3 MB/s # xz -dc gronn.img.xz | dd bs=1M of=/dev/storage2/...
Those are incomplete reads. It should go away if you add iflag=fullblock. By default, dd will happily accept smaller blocks from a pipe, if there isn't more data readily available. With the iflag, dd will wait until a full block of data has been gathered, or EOF. In regards to data consistency there should be no issue...
dd shows a random number of records in/out [duplicate]
1,367,815,607,000
With an intent to check how backing up files/filesystems works, I created 3 part itions sda9, sda10 and sda11. Please see the structure below. (Please ignore sda10 for now as I have already run command to back up sda9 onto it) ravbholua@ravbholua-Aspire-5315:~/mount$ df -h Filesystem Size Used Avail Use% Mounted...
sudo dd if=/dev/sda9 of=/dev/sda11 Absolutely terrible idea for a number of reasons, such as the fact that you've duplicated the UUID's, and that you copied 21 MB to back up 141 KB of data. If you did this while /dev/sda11 was mounted, you're going to have to at least umount and re-mount it. You destroyed the parti...
Backing up a partition: doesn't reflect the status properly
1,367,815,607,000
Not sure if it's better suited for superuser of serverfault boards, let me know. I have a drive which I repartitioned with fdisk. Initially there was only one big partition, now there are a number of partitions. Now the new partition table won't be taken into account by the kernel until the next reboot. The point is...
You need to deal with NFS and get it to stop exporting the old drive. You can't just keep dismissing that with "this is not an option". That said, if you want direct access to a particular block on a device without relying on kernel partitions, then yes, dd and its seek and skip options will work. If you want to acc...
Writing data on particular sectors or blocks
1,367,815,607,000
I'm struggling to create a FAT-formatted a disk image that can store a file of known size. In this case, a 1 GiB file. For example: # Create a file that's 1 GiB in size. dd if=/dev/zero iflag=count_bytes of=./large-file bs=1M count=1G # Measure file size in KiB. LARGE_FILE_SIZE_KIB="$(du --summarize --block-size=1024 ...
It would seem to me you're trying to fit a file on a file system that doesn't have enough space – by design! You're basically saying "For a file that takes N kB, make a disk image exactly N kB in size". Where exactly is FAT going to store the file metadata, directory tables and volume descriptor? With FAT32, the stand...
Create FAT-formatted disk image that can fit 1G file
1,367,815,607,000
There are many tips on how to resize (increase) a LUKS2 encrypted device / partition / LVM volume. But how to increase the size of the LUKS container created in the file? I once created: dd if=/dev/random of=/some file bs=1M count=100 cryptsetup luksFormat /some-file cryptsetup luksOpen /some-file some-mount mkfs.ext4...
You can just set a new file size with truncate, then cryptsetup resize and resize2fs. For example, setting it to 200M: truncate -s 200M cryptfile.img Alternatively, if you prefer dd or other tools, you can just append another 100M of random data: head -c 100M /dev/urandom >> cryptfile.img Warning: if you truncate to...
How to increase the size of a LUKS file-container
1,367,815,607,000
I tried the process from this post resize partition on an image file. I didn't succeed in understanding why it goes wrong in my case. I produced a 8GB image using dd. The image contains two partitions. I map the image with losetup -P /dev/loop0 $image-file. Then: resize2fs /dev/loop0p2 4000M resize2fs 1.44.1 (24-Mar-2...
Thank you @sudodus and @fra-san. I think there is a compatibility issue when combining resize2fs and parted for shrinking a fs/partition. resize2fs uses 4k blocks, when parted uses Byte or MB, GB etc. I eventually found another way to shrink the 2nd partition: gnome-disks. It is provided with Linux Mint and works pret...
How to shrink a file image, produced with dd?
1,367,815,607,000
I would like to write a tar archive to tape, and at the same time store the block offsets for each file in a lookup table. Then when I want to restore an individual file from the archive, I would seek to the corresponding block on the tape and restore that file alone. Does tar support restoring a file in this manner? ...
tar does not help you here as you would not know where to seek to, but there is already a similar solution that is in use sice approx. 20 years in the SAMFS/QFS project as a HSM. In that solution, the starting block numbers are archived in a separate data base. The problem here is that the tape seek does not work bas...
Write tar archive to tape and then extract individual files
1,367,815,607,000
I create compressed backup images using dd and lzop on a regular basis. In the past I've created a large file beforehand with zeros using head -c xxG /dev/zero > zeros.tmp && rm zeros.tmp (xxG was the empty space available) to clean out deleted files. This saved a lot of time and backup disk space, but it's also highl...
Data returned on reads after a trim (using fstrim or any other such tool or mount option) depends on the device: some will return random data, some will return unvarying non-zero data, some will return zeroes. You can run hdparm -I on ATA devices to determine which of these options applies: it will show “Deterministic...
Does fstrim have the same effect as overwriting the disk space with zeros?
1,367,815,607,000
I was restoring a backup of my Raspberry Pi on a new micro SD card. The original card was 16Gb and the destination card was 16Gb, too. However, during the transfer dd complained that there isn't any space left. Now, I know that every card has a different real size, but how can I fix that? Is it possible to "chop" off ...
Yes, you can "chop" bytes off a raw disk image file using truncate. truncate -s 15G image.raw Obviously, this will affect the data within the disk image. You probably want to shrink the contained filesystems so they are not truncated along the way. gparted is a tool with nice UI to achieve this. gparted image.raw Ju...
dd: No space left on device
1,367,815,607,000
I want dd an image and save it to remote using tftp for example I'm trying to do "dd if=/dev/mtd2" | save it to tftp server. the direction of the file I have used in that code is wrong I'm trying my best to learn how it can be, this is the wrong code I made my self I mean half of it :'( "dd if=/dev/mtd2" | tftp -l -p...
This is a tricky one, and it also appears you're using an embedded device (by the use of /dev/mtd). It looks like you're trying to take an image of a block device, and create a 'bin' file on another machine. You may be overthinking this - a block device is openable as a file, and can be read by normal tools. If that ...
How to dd an image and save it to tftp without saving into local machine?
1,367,815,607,000
I have 40gb image split into 10 4gb files, then combined with dm-linear to create single 40gb drive. One file got damaged single 4kb sector. However when I'm copying data unsing either dd or ddrescue resulting file is 4kb smaller than original file. It results in VM boot failure due to invalid physical disk size. How ...
Use dd bs=4k conv=sync,noerror if=damaged_source_image of=destination_image With noerror, dd will continue after encountering a read error. With sync, the unread bytes (due to the read error) will be written as zeros. See this question for an extended discussion on this.
ddrescue image differs in size
1,367,815,607,000
I am using @tremby's great idea to fill a disk with random data. This involves piping openssl, which is encrypting a lot of zeros, to dd (bs=4M). I'm maxing out the single core on which this is being run (I have 7 more), and I'm nowhere near maxing out my I/O. I'm looking for a way to parallelize the input to dd...
The important part is having a way to merge the output of your several openssl commands. I believe a FIFO would solve your problem. Try this mkfifo foo openssl <whatever your command is> > foo & openssl <whatever your command is> > foo & openssl <whatever your command is> > foo & dd if=foo of=/dev/sda bs=4M EDIT: A...
Parallelize openssl as input to dd
1,367,815,607,000
I'm creating an image in memory (/tmp is a tmpfs): $ dd if=/dev/zero of=/tmp/sdcard.img bs=512 count=3147775 It's supposed to hold a partition table and the first 3 partitions of a device $ losetup /dev/loop0 /tmp/sdcard.img $ dd if=bootloader.img of=/dev/loop0 bs=512 The first 2048 sectors contain a partition table...
You can make a file as big or as small as you want - especially on a linux tmpfs. df -h /tmp Filesystem Size Used Avail Use% Mounted on tmpfs 12G 472K 12G 1% /tmp We can just make a sparse file. for cmd in \ 'dd bs=1024k seek=20k of=' \ 'ls -slh ' do eval "$cmd/tmp/file" ...
How can I manipulate a partition table file without fdisk checking the validity of it?
1,367,815,607,000
The command dd if=/dev/mem of=/dev/null seek=16k bs=4k count=1 is used to test erroect injection for edac. Why? As far as I know, dd is simply copying data from those devices to somewhere else. What bad can happen to cause an error to memory by copying?
You skipped the important part before the dd command, from the kernel documentation: For example, the following code will generate an error for any write access at socket 0, on any DIMM/address on channel 2: echo 2 >/sys/devices/system/edac/mc/mc0/inject_addrmatch/channel echo 2 >/sys/devices/system/edac/mc/mc0/i...
Using dd to cause an error in memory
1,367,815,607,000
I see a lot of dd related questions, but could not find answers to the following. If question/answers already exist, please point to them, then flag to close, delete or merge. Can a working linux installation (say on /dev/sda7) be cloned to an external hard disk partition (say /dev/sdb2), while on it? (/dev/sdb is a...
You can clone a mounted filesystem, but it's a bad idea because you'll be copying the filesystem in an inconsistent state. There's a real risk of losing data. There are ways to clone a mounted filesystem, but they require preparation beforehand. For example, if the filesystem is on a block device that permits mirrorin...
How to clone linux installation onto an external harddisk?
1,367,815,607,000
I have a surplus 120GB SSD that I want to completely clear of data. With the drive unmounted, I ran sudo dd if=/dev/urandom of=/dev/sda bs=4M but it stopped after copying 8GB, reporting “dd: error writing '/dev/sda': No space left on device”. lsblk showed the correct device name, and a capacity of 112GB. I tried sever...
When you unmount a disk, the disk has a tendency to disappear. So when you unmounted the device, the device file probably also disappeared. The remedy is normally to plug-out and plug-in. When the device file /dev/sda was gone, dd assumed that you wanted to create a normal file /dev/sda. Even though it is under /dev, ...
dd command not filling device
1,688,314,265,000
I was flashing a new operating system to a device, but after the process was complete, I couldn't boot into it. I then checked the disk, and I noticed something strange. Different tools report different sizes for the disk, even though it should be approximately 120GB in size. So, I decided to: dd if=/dev/zero of=/dev/...
By "flashing a new operating system to a device", did you mean writing a complete disk image, including partition tables? Note that your dd if=/dev/zero of=/dev/sda should have certainly overwritten the DOS-type partition table, but if you did not trigger a rescan of the disk afterwards, the system will still be using...
Disk size is variable
1,688,314,265,000
I wanted to measure my SSD read/write performance and found some recommendations for using dd and gnome-disks. (from my understanding, hdpart is not relevant since it's not using the disk itself but only cached data). The problem is that I get different results with these tools and I wish to understand why it happens....
TL;DR Both are inappropriate way of testing storage performance. Neither says much about your system storage performance, and dd says almost nothing about you SSD performance (however, I'd prefer gnome's benchmark than dd, which is totally wrong way to measure storage). Use fio, which is widely recognized as a correct...
SSD performance different results in dd and gnome-disk
1,688,314,265,000
Here are my commands mt -f /dev/st0 rewind dd if=/dev/st0 of=- As I understand it the first command rewinds my tape in /dev/st0, and the second command writes contents of /dev/st0 to -. My questions are Where is -? What is this command doing when it writes the data from the tape to -? The result of the command is: ...
It's been a long time since I've used tape. However, here's what I believe is happening mt -f /dev/st0 rewind This rewinds the tape in /dev/st0 ready for writing. Once the device is closed the tape is then automatically rewound because you didn't use the non-rewind device probably called something like /dev/nst0. Obv...
Testing LTO drive with mt and dd
1,688,314,265,000
I have an ext4 partition backed up with dd on a MBR hard drive that I would like to restore to a new GPT hard drive. Can I just create an empty partition of the exact same size on that new GPT drive and overwrite that partition with the one I want to restore or I have to do something else because the partition was bac...
Can I just create an empty partition of the exact same size on that new GPT drive and overwrite that partition with the one I want to restore? Yes. The MBR/GPT distinction is metadata stored outside of the partition. So when you made a partition backup using dd you only backed up the content of that partition (t...
Using dd to restore a partition backup from MBR disk to GPT one
1,688,314,265,000
I was gonna copy a partition to another partition using dd (dd if=/dev/arch_data/root of=/dev/sdd3), and it worked. But then I accidentally re-ran the same command again, and it takes a while so I hit Control + C. Will dd then cause any changes in data due to this?
The short answer is that you should be safe if both /dev/arch_data/root and /dev/sdd3 were not changed by anything else inbetween your two dd commands. By default dd will copy data in blocks of 512 bytes which is the standard sector size of a hard drive (See Note 1). This means that if you stopped dd early it will ha...
Does dd change any data if `if` and `of` already have the same contents
1,688,314,265,000
According to most disk benchmarks, sequential write speeds are typically very close to the read speeds. Mine are in the ~500MB/s range. $ dd if=/dev/zero of=tempfile bs=1M count=5120 conv=notrunc oflag=direct status=progress 5291114496 bytes (5,3 GB, 4,9 GiB) copied, 11 s, 481 MB/s 5120+0 records in 5120+0 records out...
The reason for the difference was explained to me by the author of fio: the dd command I used was writing zeroes whereas fio was using random data by default. Setting --zero_buffers=1 solves the issue. fio --ioengine=libaio --size=1024m --filename=$HOME/tempfile --direct=1 --loops=5 --name=test --bs=1024m --rw=write -...
FIO reporting slow write speeds while DD reports fast ones
1,688,314,265,000
Test 1: dd if=/dev/sdb of=/dev/sdc /dev/sdb is a bootable OS HDD, /dev/sdc is another HDD, after executed the above dd command, the /dev/sdc become bootable. Test 2: dd if=/dev/sdb of=/dev/sdc /dev/sdb is a bootable OS HDD, /dev/sdc is a PCIe NVME SSD, after excuted the above command, the /dev/sdc can not boot. Simi...
The PCIe NVMe SSDs I've seen are either not bootable at all, or only bootable using UEFI. If you're using legacy BIOS-style boot, and a PCIe SSD does not appear as a bootable device, it's a pretty good clue that the PCIe SSD does not support legacy-style booting. If you can get to the bootloader, but fail to start the...
dd copy from an OS HDD to PCIe NVME SSD, SSD can't boot
1,688,314,265,000
We have a relatively large disk on our Linux machine, 2.5TB in size. We want to completely format (zero-out) this disk; say the disk is /dev/sdX. We would like to achieve this with dd, for example: dd if=/dev/zero of=/dev/sdX bs=1M count=1 My question is: Does dd also support such a formatting (cleaning) of disks ...
dd would be slow in this instance. You could install pv (man page) with: yum install pv pv could be faster and I would suggest scrambling instead of zeroing, first, (if you are serious about the data erasure, that is): pv < /dev/urandom > /dev/sdX There is no need of checking if this has been done. In this instance...
How to zero a disk + verify it afterward? [closed]
1,688,314,265,000
I have a faulty 320GB drive which has reading errors in samish GB positions but the exact positions vary. I am ok with probability of errors, this is out of question here. First of all I was surprised with that I need conv=sync for conv=noerror being actually useful but ok, I have spare time to grow new foot. I found ...
Try ddrescue (gddrescue in most distros): GNU ddrescue - Data recovery tool. Copies data from one file or block device to another, trying to rescue the good parts first in case of read errors.
Blindly dd'ing faulty drive to new drive
1,688,314,265,000
I made an image with dd sudo dd if=/dev/sda of=/path_to_external_drive/backup.img Now I wanted to recover the system after the mount of all partitions went smoothly. When I make sudo dd if=backup.img of=/dev/sda I don't get any error messages until I try to boot the system. I get the following error message from s...
Your image file is 40KB larger than the disk (976773248 - 976773168 sectors). It can't work to dd the whole image to the disk. I guess your dd command was showing some warnings like "no space left" or something. But you have luck. The last (6th) partition is just a swap partition. You could use gdisk and mkswap to res...
dd image too large to recover
1,688,314,265,000
I'm trying to wipe an IOSafe external drive, and I'm running into a major problem. When I run dd to wipe the full disk (/dev/sdb) it errors out at the 1.8 GB mark (it's a 2 TB disk), saying no space left on device. sudo dd if=/dev/zero of=/dev/sdb bs=4M status=progress When I go to wipe /dev/sdb1 (the partition, tha...
Edit: Thanks to the answer to Mark Plotnick's question, it is demonstrated /dev/sdb has been removed as a device node, so you've then filled /dev (which is a tmpfs and hence limited by RAM). As you surmise, the b next to sdb1 is what shows that it's a block device. /dev should be recreated if you reboot.
What might cause a block device to somehow be smaller than its partitions?
1,688,314,265,000
I am trying to verify a backup that I made using the following command: dd if=/dev/sda of=/dev/sdc2 I backed up the contents of /dev/sda (internal hard drive) to /dev/sdc2 (external backup drive, connected via USB), however /dev/sdc2 (the partition where /dev/sda is being backed up into) is slightly larger than /dev/...
Perhaps cmp is adequate in this case: SYNOPSIS cmp [OPTION]... FILE1 [FILE2 [SKIP1 [SKIP2]]] DESCRIPTION Compare two files byte by byte. (...) -n, --bytes=LIMIT compare at most LIMIT bytes You will want to pass, as an argument to cmp -n, the size in bytes of the source device, whi...
Compare two files, while overriding second file's size
1,688,314,265,000
I am using hexedit to show/edit disk MBR (512 Bytes, copied with dd). When I open the file, hexedit displays the file as 9 columns, 4 bytes per column (36 bytes per line). That is very unfortunate. I need to have it aligned in a meaningful way (ie 8 columns, 32 columns per line) I could not find any way to do it in th...
Apparently it keys off of the width of your terminal. If you size the terminal just right you can get hexedit to show you 8 columns instead of 9. Example 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................ 00000020 00 00 ...
hexedit: change number of columns (bytes per line)
1,688,314,265,000
I am pretty new to linux. I mostly started learning after I purchased a couple of Raspberry Pis. I like to make backups of my images as I have often made the mistake of corrupting my data :). Normally I use dd: dd of=mybackup.img in=/dev/diskX bs=2m Since my image is on an SD Card, the back up image takes the whole ...
The solution seems to be to use dd of=mybackup.img if=/dev/disk3s1 instead of dd of=mybackup.img in=/dev/disk3
Backing up a partition
1,688,314,265,000
In this tutorial is written: To regain unique UUIDs, use tune2fs /dev/sdbX -U random on every partition. Ok, but how can I use it with this command? dd if=/dev/sda of=/dev/sdb bs=4096 conv=notrunc,noerror Or do I have to use it after the dd command?
You use it after the dd commmand. Because you've copied over the partition table, you'll need to first inform the kernel of the change, e.g., by running partprobe /dev/sdb. Basically, what's happening is that there is a unique value (a UUID) stored in filesystem metadata. When you copy whole partitions (as you're doin...
How use tune2fs in with dd?
1,688,314,265,000
I'm trying to dd an .img file over to my micro sd (8 GB). The rom (.img) is 2.66 GB, but in my output of DD (live) it says its transfered 9 GB. I don't get how it's turning a 2 GB image into 9 GB. I'm running OSX Lion and using a Belkin card read. The card reader is not the problem, I have used disk utility with it wi...
The behavior you describe and the nature of the file make me suspect that this is a sparse file. Sparse files are a primitive compression technique, in which large sequences of null bytes in a file are not stored on the disk. Here is an example where I create a sparse file: $ echo a | dd seek=999999999 >sparse 0+1 rec...
dd copies more data than exists in .img?
1,688,314,265,000
I am trying to create an image of a HDD connected to a Promise Fastrack TX2300. I am trying to do this with the live Linux 'grml'. The hardware on which this is taking place is long past its best days: [email protected], 1GB Ram, mainly running Windows XP. The PC is installed in an industrial machine that I would not ...
As GracefulRestart wrote, it was simply due to the incorrectly chosen file system. FAT32 can only handle files up to 4GB. Switching to NTFS, ext4 or extFAT will remedy this.
Reading an image with dd from a hard disk connected to a raid controller does not make it over 4GB
1,688,314,265,000
I'm making a backup of Raspbian (I know, this isn't the Raspberry Pi SE, but it's a Linux question and it probably isn't just Raspbian that has this problem and BTW, the size of the drive is 128GB). The first backup is only 68GB after compression. Then, I deleted the first backup. The next backup is over 100GB in size...
Will this command do that? It is missing the = after the if, but apart from that: Yes. I do not know whether it is the most efficient way to achieve it, but it will to the job. Though I recommend a dd-only variant like this: dd if=/dev/zero of=~/zeros.txt bs=16M status=progress No need for pv. For complete root fil...
How can I completely zero out all free blocks (deleted files)
1,688,314,265,000
Is it necessary to synchronize cached writes to persistent storage with the sync command when wiping a USB, or any device, with /dev/urandom? This is a common practice, i.e. dd if=/dev/urandom of=/dev/sdx && sync. But is that really necessary? Is it okay to omit the sync command? Please note this question is not refer...
sync isn’t used specifically because /dev/urandom is involved; it’s used to ensure that all pending writes have been sent to the device. This is especially important when using removable devices: running sync, and waiting for it to finish, ensures that the device can be safely removed. When wiping a device, if you omi...
Using 'sync' when wiping a device with /dev/urandom
1,688,314,265,000
I'm trying to do an 'advanced case' of cloning. There is a pipe writing to a block device, at the end of which there is a partition that should not be touched. I know where this partition starts. In this case I want to override the partition table. For the sake of simpilicty the pipe starts with dd if=myfile. dd if=my...
dd bs=1 is very inefficient as it does one read() and one write() system call per byte. It doesn't make much sense to use dd anyway on a block device (unless you want to use special flags like conv=noerror,sync... to handle errors or offsets) Here you could do: offset=$(($(cat /sys/class/block/sda3/start) * 512)) && ...
Pipe limit data in bytes
1,688,314,265,000
I have a huge memory image I'm investigating and digging through (64gb+). Too large to load into memory/vim. I ran strings on the memory file with the offsets included and saved it to a file so that I can search for the indicators I'm interested in. Example output: 332327467 Washington1 332327514 Redmond1 332327536 ...
If you want to use dd, you can use skip= bs is how much to read/write at a time, offset=bs*skip. Count is how many times to read/write. Example: $ dd if=input of=output bs=1 skip=332327467 count=128
Print line at offset X in memory dump +/- 10 lines on each side
1,688,314,265,000
I am trying to create a Live USB using the dd utility. The first thing I did was wipe the USB using the following command: ~ $ dd if=/dev/zero of=/dev/sdb bs=512 count=1 The 8GB USB has a total memory of 7.6GB, as told by using the command. ~ $ fdisk -l ... Disk /dev/sdb: 7.6 GiB, 8097103872 bytes, 15814656 sectors U...
So it turns out the space was there but was just not showing up in gparted. For any future users, here is the series of commands I used to utilise the extra space. ~ $ parted GNU Parted 3.2 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print devices /dev/sda (128GB) /dev/sdb (...
dd not using entire disk space
1,688,314,265,000
I tried to test the write speed of some SSDs and when writing to the disk directly is somehow slower that writing to the disk when it is formatted as ext4. How does this work? Is this correct or am I measuring something wrong? for i in {1..5}; do dd if=/dev/zero of=/dev/sda1 bs=1G count=1 oflag=dsync; done 1073741824 ...
mkfs TRIM / discard the entire device, thus providing optimal benchmark conditions. Also with /proc/sys/vm/block_dump enabled (warning - TONS of output), I'm seeing writes of 8 sectors (dd on raw block device) vs. writes of 16384 sectors (dd on ext4) so it might be due to how the kernel decides to split things up, sin...
Writing to EXT4 faster than writing to disk directly?
1,688,314,265,000
My goal is to create a bootable backup of my system without restarting, I will use qemu-img to convert a raw dd image to vhdx and run it in Hyper-V. If I boot into a liveCD and run: dd if=/dev/sda of=/nfs/sda.raw conv=noerror,sync,notrunc I can convert that to a vhdx and run it directly in Hyper-V without much effort....
You could loop-mount the whole-disk image with partition support, and then dd the updated sda2 image into place within it: losetup -P /dev/loop0 /nfs/sda.raw #this will create /dev/loop0p1 and loop0p2 dd if=/nfs/sda2.raw of=/dev/loop0p2 losetup -d /dev/loop0 Alternatively, your partition table indicates that your fi...
Create bootable disk from ext4 partition image
1,558,363,372,000
I have a system that generates embedded Linux systems. The system outputs three files: a tarball containing rootfs excluding the kernel modules a tarball containing the kernel modules uImage The system is deployed on a 1 GB SD card, of which 10 MB is given to a FAT boot partition and the rest to an ext4 root partiti...
If you are sure that the SD card always is of the same size (or greater) as the one you actually have, and the 1G is enough for what you want to copy there, you could proceed as follows: Manually partition an appropriate SD card, but leave the partitions empty (but create the required filesystems on them) Copy the wh...
Creating dual-partition SD card image by a script
1,558,363,372,000
This is perhaps too specific/personal a question for S.O. but here it is: I've inherited a server currently running a single hard drive, which through default Ubuntu 16.04 server setup, is running its disk in the following partition scheme: sda1 : 512 Mb : Boot : primary/physical partition sda2 : Rest of Disk : Extend...
There doesn't seem to be anything particularly wrong (or complicated) with what you're doing, though since you're using LVM you have another option: you can use pvmove to move the data to the new array. The advantage is you can do that online, almost eliminating downtime. To use pvmove, you'd extend the existing volum...
Less complicated way to do Server Data Migration?
1,558,363,372,000
How to use dd command to download mtd block from embedded Linux-based device? # cat /proc/mtd dev: size erasesize name ... mtd3: 003a0000 00010000 "DRTI2" I need download mtd3 block, so dd if=/dev/mtdblock3 bs=BYTES count=BLOCKS | nc 192.168.1.30 5555 What should be correct bs and count values and how to calcu...
dd and cat are equal if you want to read full mtdblock3. With dd it will be: dd if=/dev/mtdblock3 | nc 192.168.1.30 5555. Just omit optional bs= and count=.
Using dd command to download mtd block
1,558,363,372,000
here is the image I used dd command to create a new floppy. First I tried it with a folder filled with naber.bin, test.bin, blabla.bin and boot.bin. And then i deleted all except boot.bin. ls -a command shows there is no file, except boot.bin. I also deleted them in trash. Then I used dd command for this folder and ...
Post output of sw_vers + the exact commands you use for your dd. Also the output of - file aramok - which will fail if aramok is a file or directory (see below). Posting an image is difficult to read. Actual commands are better. It appears you're attempting to somehow write (dd) to a floppy with no formatting. Meaning...
using dd command for folder, but deleted items don't seem deleted [closed]
1,558,363,372,000
My java-based installer couldn't copy itself to target dir eating all disk space and I thought it was a java bug, but then I reproduced it with plain dd. When I try to read my own executable using a large enough buffer (131072), the read operation suddenly returns value greater than the actual file size and never retu...
Complete test script. I can't report the bug, because I'd have to pay for that. #!/bin/bash set -e # systemd #SMB_START="systemctl start smbd.service nmbd.service" #SMB_RELOAD="systemctl reload smbd.service" # initscripts SMB_START="service smb start" SMB_RELOAD="service smb reload" cleanup() { echo cleanup... >&2...
No EOF, when a program reads its own executable file on cifs mount
1,558,363,372,000
I used a dd command to write directly to /dev/sdc (an externally mounted hdd 1TB size) to test various writing speeds in a raw mode. (I don't care about any data on the disk). Now the size of the disk as reported by fdisk or gparted is the size of the data I wrote, and I cannot figure out how to get the full disk si...
For some reason the block special device file /dev/sdc didn't exist, perhaps because the drive wasn't connected at the time. The dd command then created the file as a normal file, probably on the root filesystem, which gives the observed results.
dd command writing to /dev/sdc changed size of disk