date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,558,363,372,000 |
I have been following a tutorial online to teach myself some basic command line stuff and accidentally I used the dd command (which I haven't gotten to and don't understand), but it seems to have done something to my computer.
The image below shows exactly what I typed (dd, followed by hitting enter, another d, a few ... |
dd with no arguments reads from its standard input and writes to its standard output; you haven’t done anything to your computer.
| Accidentally used dd command |
1,558,363,372,000 |
What's the right command to copy the content from file X and File Y to create a new File XY with all letters being lowercase?
|
Use a combination of cat and dd:
cat LIST_OF_FILES | dd of=OUTPUT_FILE conv=lcase
An example:
$ cat file1.txt
I am File 1.
$ cat file2.txt
Here is File 2!
$ cat file1.txt file2.txt | dd of=file12.txt conv=lcase
0+1 records in
0+1 records out
29 bytes (29 B) copied, 0,000301417 s, 96,2 kB/s
$ cat file12.txt
i am... | Copy content from files X and Y to create file XY but XY content is all lowercase |
1,558,363,372,000 |
When is executed the sudo fallocate -l 2G /swapfile command, then 2 GB is created, but with that kind of content or data? Can be it customized? If yes How?. I did do some research but there are no details about this. I want to know if is good use fallocate for swap file purpose.
For example sudo dd if=/dev/zero of=/sw... |
Swap files do not need to full of zeros. The kernel keeps track of what blocks are being used.
However, man mkswap may warn you against using fallocate:
Note that a swap file must not contain any holes. Using cp(1) to create the file is not acceptable. Neither is use of fallocate(1) on filesystems that support ... | What kind of content/data does "fallocate" command generate? |
1,558,363,372,000 |
I'm trying to use dd to clone a hard drive I repaired. I'm trying to make dd copy data off of the drive in 10GB chunks, however it is transferring more data than the drive should contain. The drive itself functions, and the partition on it can be mounted.
Using df -h I got the drive's size to be 1000204886016 bytes (1... |
I discovered the reason my solution failed was misunderstanding what the seek flag did. It was only shifting the write location on the output drive. So the script was just copying the first 10GB over and over again onto the output. It would never reach the end of the device.
To shift the input the skip flag needed to ... | dd running past end of input device |
1,558,363,372,000 |
I've recently made multiple images of several SD cards on multiple machines using dd. I haven't done a stellar job with my naming, and have some duplicates. How can I quickly determine if two images are equal? I've been using diff but it takes a while.
|
md5sum *.img | sort
Should make any duplicates obvious.
| Determine if two iso images are equal |
1,558,363,372,000 |
The question is common, but I am not able to solve it with the explanations I found here.
Situation:
4GB usb stick
Manjaro operaing system
iso image file of linux mint
First, I did:
lsblk # and got /dev/sdb for my usb stick
# I left it unmounted
dd if=/dev/zero of=/dev/sdb # filled it up with zeros
fdisk # Her... |
You should verify the .iso image : Steps to verify an ISO image
The available linux image come wiht the .iso extension and not .iso.part
Before unplugging your USB it is recommanded to run sync
There is an example:
dd if=linuxmint-18-xfce-64bit.iso of=/dev/sdb bs=4M status=progress oflag=sync
Edit
The syncis to make... | How to make a bootable usb from commandline? |
1,558,363,372,000 |
I have recently done some performance tests on a new server (using dd) and wonder why read performance is so much worse than write performance? Shouldn't it be another way around?
file size was in both tests 550GB,
read:
in seconds: 3704
in MB/s: 148
and write:
in seconds: 1539
in MB/s: 357
write command:
time sh -c... |
You need to use the write sync flags to test performance, to ensure you are actually writing on disk and not on cache. Use conv=fdatasync to force a sync of buffers after writing has ended. See here for details.
time dd .... conv=fdatasync
for read test, discard caches before testing:
flush
echo 3 | sudo tee /proc/s... | dd write vs read performance |
1,558,363,372,000 |
dd is a handy tool for backing up a whole drive or filesystem in some situations. Now I am thinking about what if I use the tool for backing up Windows file-systems / drives (Windows 2003/2008) which is mounted as second hard disk within Linux?
|
dd is not a backup tool. It is a binary file manipulation tool. cat works just as well. The magic is in the block devices (/dev/sdz99 and the like). See dd vs cat -- is dd still relevant these days?
If you do a whole-partition backup, it doesn't matter what filesystem (if any) is on the partition. You just copy the wh... | dd command for windows filesystem |
1,558,363,372,000 |
I have a dd command with bs=1M and count=40960M (40GB) and it's consistently running past its count every time I try to run it. This is the exact command, and the output captured before I stop it:
dd if=/dev/zero of=/swap/swapfile bs=1M count=40960M status=progress
50383028224 bytes (50 GB, 47 GiB) copied, 458 s, 110 ... |
You have to multiply the bs and count parameters to get the siez fo the data it will actually write. You're asking it to write 40 billion (40960 million) blocks, each block being 1 MB large. That's... quite a large amount of data.
If you want to write 40 GB, you can use bs=1 count=40960M, bs=1M count=40960, or some si... | Why is this dd command with a count and bs param running past its count? |
1,558,363,372,000 |
As per my understanding, READ/WRITE etc are file system operations in linux. The file systems registers callbacks with the Kernel (VFS) and are in turn called by it when the particular FS is detected during a READ/WRITE operation.
For example:
EXT4_write:
VFS write request -> ext4_writepages()
F2FS_write:
VFS write r... |
In order for the VFS layer to be able to do read/write operations on a file, then that file must be opened in one way or another. If you have a medium that has no filesystem, then you cannot mount it. If you cannot mount it, then you cannot have a path to it for use by open(). If you cannot open a file on it, then ... | Can VFS read/write operations be performed on an unformatted storage device in Linux? |
1,558,363,372,000 |
A while ago I made a backup of an entire disk using
dd if=/dev/nvme0n1 conv=sync,noerror bs=64K | gzip -c > backup.img.gz
Today I restored this backup to the same disk using
gunzip -c backup.img.gz | dd of=/dev/nvme0n1
dd exited with the following error message:
dd: writing to '/dev/nvme0n1': No space left on device
... |
It's possible for dd conv=sync,noerror (or dd conv=noerror,sync) to corrupt data in some cases.
However in your case it's probably simply surplus zeroes at the end of file. If your device is not exact multiple of 64K, your dd command would have filled the last 64K block with zeroes in the image file. And those additio... | dd: "No space left" when restoring backup to exact same disk |
1,558,363,372,000 |
I regularly dd a drive to erase them for ZFS resilver, when something goes awry with read/write or checksum error, to put the drive back into service. Frequently, removing the partition table at the beginning is not enough for ZFS to not recognize the drive.
I would like to both remove both partition table at beginnin... |
the seek argument to dd is the number of output blocks to seek
With no bs= or obs= in your command, this defaults to 512 bytes
You can see that 726443928 blocks were written
Simplest solution is to use that number in the seek
dd if=/dev/zero of=/dev/disk/by-id/scsi-35000c50084818db7 seek=726443928
By the way, the doc... | how can I dd ONLY last portion of drive that hasn't already been dev/zero'd |
1,558,363,372,000 |
I try to prepare an nvme for encryption, so i first follow this post on SO.
But the speed of dd is really really slow (less than 100 mb/s). I see there is new option to speed up dm-crypt on kernel 5.9 (see this post), but before updating my kernel, i want to know if using nvme-cli format zero tools is equivalent to /d... |
Found the answer, this is much much better with oflag=direct, jumping from 45 Mb/s to 536 Mb/s :)
dd if=/dev/zero of=/dev/mapper/ecrypt oflag=direct bs=1M status=progress
Thanks to these two posts :
NVMe performance hit when using LUKS encryption
https://stackoverflow.com/questions/33485108/why-is-dd-with-the-direct... | Slow /dev/zero format using dd with nvme to prepare crypto, is there nvme specific tool? |
1,558,363,372,000 |
I'm trying to create a full disk ISO image of a 250GB HDD but I had to cancel the operation about 80% of the way through, it'd taken nearly 16 hours to get to this point and I'd rather not have to wait through that all again. I used the command:
dd if=/dev/sdc of=ssd.iso
When I had to cancel it with Ctrl+C it showed
... |
Yes, you can resume. Note if any data on /dev/sdc changed since the first try, you're risking something similar to panorama fail (but with binary data, not graphics).
Use the same input and output files with identical value of skip and seek, which in your case should be at most 445056121.
But this assumes the default ... | Resume DD on creating a disk ISO? |
1,558,363,372,000 |
After running 'sudo apt-get update && sudo apt-get upgrade' on my raspberry pi 3 running raspbian jessy, I get:
E: Failed to fetch http://mirrordirector.raspbian.org/raspbian/pool/main/g/ghostscript/libgs9-common_9.06~dfsg-2+deb8u5_all.deb rename failed, Structure needs cleaning (/var/cache/apt/archives/partial/libgs... |
That would also copy the file system corruption (dd copies the contents of the block device, without caring about their structure).
To fix your problem, I would suggest running apt-get clean to clear your package cache, and fsck. If your file system has detected errors, rebooting the Pi should force a full fsck.
| Will a backup and restore with dd solve filesystem corruption? |
1,558,363,372,000 |
After copying the last version of Stretch distro on a 4GB USB drive with sudo dd bs=4M if=debian-testing-amd64-netinst.iso of=/dev/sdb1 && sync on a Lubuntu 16.04 system, the file system of sdb1 shows as 'unknown'. This is the case after creating a ms-dos or gpt partition table, a single partition, and formatting it w... |
You need to overwrite the USB key including its partition table:
sudo dd bs=4M if=debian-testing-amd64-netinst.iso of=/dev/sdb
(sdb instead of sdb1). The download contains its own partition table.
See the official instructions, which suggest
sudo cp debian-testing-amd64-netinst.iso /dev/sdb
sync
instead.
As pointed ... | Unknown file system after copying Debian ISO with dd |
1,558,363,372,000 |
I'm trying to modify a byte with bash,
So I will write the bytes before the offset, then the byte to modify, and the rest of the file.
But the following script doesn't work as expected
Anyone please take a look? Couldn't figure out which part is wrong
#!/bin/bash
file=/etc/passwd
out=passwd.mod
offset=0x5
dd if="$fi... |
If I understood you correctly, I believe that this will work for you:
#!/bin/bash
file=passwd.orig
out=passwd.mod
offset=0x5
dd if="$file" of="$out" conv=notrunc bs=1 count=$(($offset))
printf '\x41' | dd of="$out" conv=notrunc bs=1 seek=$(($offset))
dd if="$file" of="$out" conv=notrunc bs=1 seek=$((offset+1)) skip=... | Modifying a byte with bash, dd isn't working |
1,558,363,372,000 |
This is my dd command which I need to modify:
dd if=/tmp/nfs/image.dd of=/dev/sda bs=16k
Now I would like to use pv to limit the speed of copying from NFS server. How can I achieve that? I know that --rate-limit does the job, but I am not sure how to construct pipes.
|
If for some reason you must read the block device using a block size of 16K:
dd if=/mnt/nfs bs=16k | pv -L <rate> > /dev/sda
Where <rate> is the maximum allowed amount of bytes per second to be transferred, or the maximum allowed amount of kibibytes, mibibytes, gibibytes, [...] per second to be transferred if K, M, G... | How to redirect dd to pv? [duplicate] |
1,558,363,372,000 |
Using oflag=direct in dd seems always to make operations much faster than either not using it, or using pv etc. to do the operation instead.
Under what circumstances might I not want to use oflag=direct?
|
Just off the top of my head:
If the destination file is mmapped by another process, then using direct IO to write to it may result in data loss (usually of the direct IO writes).
Some filesystems either don’t support direct IO, or do not work correctly with direct IO. The second possibility was historically the case ... | Why not always use 'oflag=direct' in 'dd'? |
1,558,363,372,000 |
I've been trying to make a backup of this raspberry pi SD card and I keep failing. I just needed it a little bit smaller so it would fit on another 32GB SD card that I have. After a lot of failures following tutorials (like pishrink) I shrank my root fs down to around 8GiB which should fit just fine. Then I copied it... |
Don't try copying a filesystem that's in use - at best you'll get a bad copy that falls but at worst you'll get a filesystem that has hidden corruption. Instead, use a different system to copy the SD Card.
Remember that although you now say you use a separate system to perform the copy,
The filesystem must still not ... | Copying image with dd results in ext4 filesystem as unknown |
1,558,363,372,000 |
I am reading many tutorials about the dd command. There are some examples including the bs and count parameters. Some of them where each one is isolated over the other and other where both are used together, but is not very clear the explicit relation about their values.
At a first glance seems enough and straight use... |
When and why is mandatory use both together?
It's important to know what your goal is. Without supplying count, dd will copy until EOF is reached (which for some block devices, like /dev/zero, will never be the case).
Otherwise, dd will copy count blocks of size bs.
Is there an explicit relation and rate for the va... | dd: when is mandatory use bs and count together? |
1,642,425,773,000 |
I recently upgraded my home server and wanted to increase my cloud disk to 2TB from 600gb. After some research I found the dd command which can fully copy a disk, which in my case seemed like a good option since I'm having all data for the docker & databases for my nextcloud intstance on the same disk.
I, successfully... |
As far as I know, that just means that the filesystem in the partition itself still uses its old size. When resizing a disk on linux, you have to resize it twice, most of the time. First in the partition scheme (eg GPT or MBR) with commands like parted or fdisk, and then in the file system, with commands like resize2f... | 'dd' command disk copy retains old size |
1,642,425,773,000 |
When writing an ISO image to USB flash drive with dd, how do I know I can remove the stick? Obviously I'll wait until the command completes and I'm back at the terminal prompt. But even then the device might still be busy from a cache/buffer. Because I'm writing to the device itself, nothing is mounted, so I also don'... |
There are short descriptions of fsync and fdatasync in man dd and with slightly more details in info dd.
If I don't want to use the separate and global sync, I would use conv=fsync in ddbecause it writes both data and metadata before finishing. From info dd:
‘fdatasync’
Synchronize output data just before finis... | When writing an ISO image to USB flash drive with dd, how do I know I can remove the stick? |
1,642,425,773,000 |
I'm having a bit of difficulty understanding parallel procedures. Atm I'm trying to mass wipe hard drives, so have created a script, however it won't run in parallel.
for i in "${!wipe[@]}"; do
dd if=/dev/zero of=/dev/${wipe[$i]} &
wait
The dd zeros the disks but it does this one after the other so when doing... |
The script as given shouldn't run at all, because you are missing the done on the for loop. This must be an excerpt, and you've left out important parts.
Assuming the missing done is after this snippet, the wait is inside the for loop, so you start the dd in the background and then wait for it to finish before going... | Getting an array into a parallel bash script |
1,642,425,773,000 |
Show character at position in a file
The above page shows how to use dd to print the nth char in a file. Is there a way to print a file starting from the nth char? Thanks.
|
You could use tail, for example, from the 5th character onwards:
tail -c +5 FILE
| How to print a file starting from the nth char? |
1,642,425,773,000 |
I created an image from a 256GB HDD using following command:
dd if=/dev/sda bs=4M | pv -s 256G | gzip > /mnt/mydrive/img.gz
later I tried to restore the image to another 512GB HDD on another computer using following command:
gzip -d /mnt/mydrive/img.gz | pv -s 256G | dd of=/dev/sda bs=4M
the 2nd command shows very l... |
Following command is not exactly doing what you are intending to do
gzip -d /mnt/mydrive/img.gz > /dev/sda
The command is decompressing the file /mnt/mydrive/img.gz and creating a file called img which is the ungzipped copy of img.gz. The > /dev/sda is not doing anything useful because nothing is sent to /dev/sda via... | restoring hdd image using gzip throws error no space left on device |
1,642,425,773,000 |
Here I read:
$ cd /media/mmcblk1p2
$ tar xf /media/sda1/mfg_images/st-image-bootfs-openstlinux-weston-stm32mp1-som.tar.xz
but as source file I don't have a compressed file, instead I have an ext4 image for that partition. Should I use dd with of=/dev/mmcblk1p2 or I need to use another approach?
|
You can mount the filesystem image directly into your filesystem:
mkdir -p /mnt/img
mount -o ro,noload imagefile.img /mnt/img
and then you can retrieve the file directly from the appropriate place underneath /mnt/img. (The ro,noload options mount the filesystem read-only. Omit them both if you want read/write access.... | Extract file from ext4 image and copy file to device |
1,642,425,773,000 |
Consider this sample 1MiB file:
$ dd if=/dev/zero of=input.img bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00100595 s, 1.0 GB/s
If I try to cat it and pipe it into dd without using iflag=fullblock I can't read more than 128KiB per block:
$ cat input.img | dd of=output.img bs... |
Any block size greater then PIPE_BUF (5k on modern UNIX, 4k on Linux) is not granted to pass a pipe without fragementation.
This means, it may be split, but there is no grant for a split.
Whether you are able to read more than PIPE_BUF at all depends on the memory state of the kernel that controls when the write side ... | cat | dd pipe causes partial reads without iflag=fullblock, why truncated to 128KiB? |
1,642,425,773,000 |
I am installing Linux on a machine and got the Ubuntu 18.04 LTS image. I formatted a 32 GB Sandisk drive on macOS with MS-DOS (FAT) format and GUID Partition Map scheme.
I found the name of the disk as disk2s2 (either with Disk Utility or diskutil list in Terminal), unmounted and copied the image with dd following the... |
I think you've made a mistake in where you write the image to.
The disk image contains a partition table of it's own so you need to write the image to the disk, not to a partition.
The partition is mounted as disk2s2 so you do need to diskutil unmount /dev/disk2s2 that. You should ensure that no other partitions on t... | Burning a Linux Ubuntu bootable USB with dd |
1,642,425,773,000 |
I need to change one byte at a well-known position of a binary file to a specific value, and am looking for a way to achieve that using command line tools.
Constraints:
I need to change one single byte.
I know the position of the byte in the file.
I know what value I want in the byte. This may be anything, including ... |
First of all, your example is wrong, it would overwrite the first byte instead of the 9th (you want seek output, not skip input). It would also truncate the file to 1 byte, if it's a regular file instead of a block device (use conv=notrunc to avoid).
dd bs=1 seek=8 count=1 conv=notrunc if=/dev/zero of=somefile
Triple... | Bit banging with dd? |
1,642,425,773,000 |
I have a clone of an entire Mac OS HDD that I created using dd, as:
sudo dd if=/dev/sda of=/media/mint/backup/mac-backup.img
I verified the integrity of the image at creation time using diff. Now I have the machine back in my hands and I'd like to restore the backup. Can I simply do:
sudo dd if=/media/mint/backup/mac... |
Short answer: yes this works fine.
Longer answer: I used dd to restore the data as above, and it was successful. However, the Mac wouldn't load the OS upon power-on. Picking the HDD from the startup device menu allowed it to boot fine and all of the data was there. I loaded the Mac into recovery mode and ran first aid... | Can I restore a Macintosh disk image using dd? |
1,642,425,773,000 |
I would like to setup a Raspberry Pi 3 running Rasbian to automatically copy a DVD disk when a disk is inserted in a coupled disk station. To achieve this, I have written a udevrule and a script to run when this rule is triggered.
The udev rule seems to work fine and runs the script when the disk is inserted.
The scri... |
udev rules are not meant for longer running tasks, like copying a DVD. From man udev:
This can only be used for very short-running foreground tasks.
Running an event process for a long period of time may block all
further events for this or a dependent device.
Starting daemons or other long-... | dd command in script not running when executed from udev rule |
1,642,425,773,000 |
I keep getting disk space errors when using dd to write to raw disk on SD cards in an external, USB connected SD card reader.
➜ ~ gzip -cd < image.dd.gz | sudo dd of=/dev/rsda
dd: writing to '/dev/rsda': No space left on device
2598977+0 records in
2598976+0 records out
1330675712 bytes (1,3 GB, 1,2 GiB) copied, 7,... |
Linux has no concept of raw devices.
You are using /dev/rsda as the output device. However, there is no such device on linux, so what you are doing is writing to a plain file on the filesystem containing /dev. This is the reason why it seems so quick: you are not writing to the SD card, you are writing to disk.
| Disk space error when using DD to write to raw disk in external reader? |
1,642,425,773,000 |
I run dd with of param which was a new file. I did seek (by mistake) to a large adrees (3gb) and wrote there the input file(3 gb) . Suprisingly, the file created was 4,29gb which is larger than the limitation of FAT32 if i am not mistaken.
Did it possibly damaged the disk(if it wrote past the last file block) or it i... |
You created something that's called a "sparse file".
A sparse file is a file with one or several "holes" in it.
The holes do not take up any space on the disk, and a program reading across a hole will get zeroes.
ls -l will report the apparent size of the file (large), whereas du will tell you the real size (on disk).... | dd past end of file |
1,642,425,773,000 |
I'm trying to process the realtime progress of dd, which, with pipes awareness, should be done via:
gzcat "$input" | dd bs="$block_size" count="$count" of="$output" 2>&1 | awk '/copied/ {print $1}'
gzcat "$input" | dd status=progress of="$output" 2>&1 | awk '/copied/ {print $1}'
but they don't print anything, until t... |
You can change AWK’s record separator to split its input on carriage returns instead of newlines:
gzcat "$input" | dd status=progress of="$output" 2>&1 | awk -v RS='\r' '/copied/ {print $1}'
| How to process realtime progress of dd? |
1,642,425,773,000 |
It's for a bash script. Basically, I want to format, or erase a USB (or SD) storage device; with a single command line.
I was going to use fdisk, but it seems to require user interaction where I want automation.
So then I decided to try zeroing it out with:
dd if=/dev/zero of=/dev/<target disk>;
but it only seems ... |
If you want to use fdisk, with only one partition, with all blocks used, this will suffice:
echo -e "n\np\n1\n\n\nw\n"|
fdisk /dev/<target disk> &&
mkfs.ext4 /dev/<target disk>
Change mkfs.ext4 to whatever filesystem type you want it to use.
If you just want to delete data, your dd command should be fine.
| What's the quickest way to format a disk? |
1,642,425,773,000 |
I am working with the RAID6 configuration with 4 disks involved, each of size 8TB. Hence the total capacity = (n-2) * s, where n = number of disks and s = size of disks. So in my case it is 16TB.
Below is the information before the dd operation is performed:
df -h /mnt/raid6/
Filesystem Size Used Avail Use% Mou... |
What you did is completely erasing all file system metadata, thus irrevocably making it unusable.
You have to do the partitioning again or better to re-create the array according to this guide.
If you want to check the filesystem on the array is doing fine, just create a file on the mounted array e.g.:
dd if=/dev/zero... | Confused with results after dd operation on RAID6 configuration |
1,642,425,773,000 |
I'm using the following command to wipe an external drive.
sudo shred -v -z -n 1 /dev/sdb
Is it possible to wipe an external drive of the files and not empty space? So it would overwrite where there is data but not where there isn't. This would save a lot of time when there aren't many files on the hard drive and I j... |
You can do it with find like so (to stay close to your original command)
sudo find /mnt/sdb/ -type f -exec shred -v -n 1 {} +
You should run it without -exec first so you can verify the list of files.
However, if you've already removed files using regular rm, or overwritten files by editing or copying them, those file... | Wipe files from an external hard drive but not empty space |
1,642,425,773,000 |
I have a failed hard drive which I need to extract data from. My dd kung fu is failing me right now. I know that the drive is failing at sector 60515007 to 60517093 (512b per sector), and multiple other locations. and I need to skip that area. How do I do it in dd? And I need to compress it on the fly (piping maybe?)... |
If you really want to do this with dd, you need to split your reads up:
dd if=/dev/sda bs=512 count=60515006 | gzip -9 > dump1.gz
will dump the first 60515006 sectors of /dev/sda to dump1.gz, compressing with gzip. Then
dd if=/dev/sda bs=512 skip=60517093 count=... | gzip -9 > dump2.gz
will skip the failed part and ... | How to image certain portions of hard drive only |
1,642,425,773,000 |
I am talking about disk signatures in context of the MBR. The area from 440 to 444 bytes.
Let's say I got a bootable raw image (bootable in a virtual machine).
How can I set the disk signature to a fixed (non-random) value while keeping the raw image bootable? How to automate (script) that?
(If you are wondering if th... |
Take your image, extract the first sector:
dd if=image of=mbr.dat bs=512 count=1
write "AAAAA" to position 440-444 and do not truncate the file:
echo -en "\x41\x41\x41\x41\x41" | dd of=mbr.dat conv=notrunc seek=440 bs=1
Use a hexeditor like okteta to verify that it did what you wanted. Then write it back:
dd if=mbr.... | How to change the disk signature of a raw image? |
1,642,425,773,000 |
I am trying to backup a remote server to my machine. I am trying something like
ssh user@ip "dd if=/dev/sda" | dd of=~/backup.img
But that obviously doesn't work. Other variants that don't work.
ssh user@ip "sudo dd if=/dev/sda" | dd of=~/backup.img
ssh user@ip -t "sudo dd if=/dev/sda" | dd of=~/backup.img
I have p... |
Something like this should work:
ssh user@ip sudo -S dd if=/dev/sda > backup.img
You don't need to pipe to dd, you can just redirect the output into a file.
| SSH remote backup script |
1,642,425,773,000 |
I have disk image from VirtualBox, it is a raw image, just like dd makes it, now I would like to restore the system to real machine using Clonezilla. However Clonezilla does not recognize the image (there is no "restore" option which means Clonezilla does not see it).
The question is -- how to convert dd disk image fi... |
Restore it with dd and then resize the partition(s) with gparted running from bootable media. It should work as long as you didn't use LVM on the virtual machine.
If you have LVM, you can increase the LVM partition size with fdisk or parted, and then pvresize, lvresize, and resize2fs (or whatever is appropriate for yo... | How to convert dd disk image to Clonezilla? |
1,642,425,773,000 |
I have an embedded device with a flash memory running linux.
I want to do raw read writes on the flash part but I also want to avoid any file system cache. How can I do this? Any pointers?
|
If the flash has a filesystem on it and you just want to open a file but bypass the cache for IO to that file, then open it with the O_DIRECT flag. If it has no filesystem on it, then you just open the block device directly.
| Embedded device: How to do raw reads and write to flash (emmc/movinand) bypassing file system cache |
1,642,425,773,000 |
I have two flash drives, for example, and due to USB speeds prefer have the contents of one on the other and vice versa. This includes the MBR and EFI bootloaders. I am not referring to swap space. How can this be achieved without requiring a lot of RAM for buffering and error corrrction for example?
Thanks for reachi... |
Here you go. I'm somewhat hesitant to post this at all, but on testing with images files it worked correctly. There is very little (no!) error checking so use it at your own risk.
I repeat my warning from the comments:
How valuable is the data on these two USB sticks? How upset would you be if the data was lost? If th... | Swapping contents of two drives with the same capacity |
1,642,425,773,000 |
I'm currently playing with building disk images (based on Debian) for a raspberry-like computer.
My current workflow looks like:
create disk image (about 16GB uncompressed; or 3GB compressed)
power-down the target system
eject the SDcard on the target system
insert the SDcard into the build computer
dd the image onto... |
Brian's answer is what I'd recommend: receive the image from the network as you go. There's no other way, because you clearly can't put the image on the storage device you're overwriting.
But that exact problem will also become with Brian's approach: Assuming you did the image receiving from your currently booted full... | Write image to current root-partition |
1,642,425,773,000 |
I got a couple of old disks I'm trying to copy over to a HDD. Some of the disks worked fine and I was able to copy them using just mount and rsync, however as is it with old disks, some of the disks were failing to mount. I tired using dd to make an image of them and then ran photorec to get the files out. This worked... |
Use ddrescue
(In Debian and Ubuntu: use aptto) install the package gddrescue.
Read a good tutorial via the command info ddrescue before starting to recover.
Clone to one drive and write a log file to another drive.
The first step is to use a fast process to clone what is easy to read.
Then a slow process can usuall... | dd stops copying mid-way through a CD |
1,642,425,773,000 |
The flag iflag=nocache of dd seems to take effect only at the second time onwards.
I don't understand why.
I was thinking maybe it is related to readahead cache, but it doesn't explain the results in the table below:
Results - Effect of iflag=nocache: from big SATA SSD file to /dev/null:
Test_Name dd_fl... |
That's because iflag=nocache drops caches… after it's been read, not before.
You can see this if you use strace:
# strace dd iflag=nocache … |& grep -Pi 'read|dontneed'
[…]
read(0, "\0"..., 65536) = 65536
read(0, "\0"..., 65536) = 65536
fadvise64(0, 393216, 131072, POSIX_FADV_DONTNEED) = 0
read(0, "\0"..., 65536) = 65... | dd: `iflag=nocache` ineffective for the first usage |
1,642,425,773,000 |
What I did so far
I wanted to create a disk image of my server HDD partition and copy it to my desktop (client).
I used the following command on the server:
dd if=/dev/md3 status=progress bs=500k | bzip2 --best > /mnt/client/image.bz2
where /mnt/client/ is an sshfs mount to my client.
Unfortunately, my client doesn't... |
You've confirmed that you're using a rescue image, so the 1TB source disk is currently unused. That's really good news.
Now, to copy the disk over an unreliable medium you need either a transport layer that can automatically re-establish itself (for example, OpenVPN over UDP), or a means to send restartable "chunks" o... | Resume incomplete disk image with dd over ssh |
1,642,425,773,000 |
I understand that one cannot do VFS operations on a medium with no filesystem.
Given that, how does a utility like fio perform VFS-like read/write/seek operations on raw devices?
|
I understand that one cannot do VFS operations on a medium with no filesystem.
The question becomes "just which operations are we talking about?" which you clarify below...
Given that, how does a utility like fio perform VFS-like read/write/seek operations on raw devices?
While read/write/seek can be done on thing... | How does a utility 'fio' perform VFS like operations on raw unformatted devices with no filesystem on them? |
1,642,425,773,000 |
Is there something about process substitution (which I think is implemented with unnamed pipes) that is incompatible with dd?
For example, this fails:
$ dd if=<(unzip -p raspbian.zip) of=/dev/sdb status=progress
dd: unrecognized operand ‘/dev/fd/4’
Try 'dd --help' for more information.
But this works fine:
$ ... |
This seems to be caused by your shell adding leading whitespace (or otherwise performing argument splitting) when expanding the process substitution. We can demonstrate this:
$ echo if=<(:)
if= /dev/fd/4
Assuming that this behaviour is reproducible on the most recent version you can get, I think there's nothing you ... | Why does dd dislike taking input from process substitution? |
1,642,425,773,000 |
I've an image of a bootable 16GB SD card. I've created the image with:
cat /dev/sdd | gzip >sdcard.img.gz
And I was happy because
$ du -h sdcard.img.gz
482M sdcard.img.gz
482MB instead of 16GB, yay!
Here're the details of the (uncompressed) image:
$ du -h sdcard.img
15G sdcard.img
$ partx -s sdcard.img
NR STA... |
Answering your first question: given you have an MBR there, I suggest you do something like dd'ing the first megabyte of the original drive (that contains the boot record and possibly the boot loader), then iterating over the partitions contained therein:
dev=/dev/sda
fdisk -l "$dev" | sed -ne '/^\//s,\(^[^ ]*\) .*,\... | disk image without free space |
1,642,425,773,000 |
I am trying to format this external hard drive but I've failed. I have tried to use gparted but I get an error: "Error de E/S en la máquina remota during write on /dev/sdb"
Also tried to use dd command on the terminal but it goes the same way:
root:# dd if=/dev/zero of=/dev/sdb bs=1024
dd: error al escribir en '/dev/s... |
"The drive is dead or dying. Recycle and replace it. Hint: when smartctl gives you a non-zero value for reported uncorrected errors it means that the drive has exhausted the supply of spare sectors set aside by the manufacturer and failure is imminent. – AlexP"
| How to fix I/O error on external HDD? |
1,642,425,773,000 |
To install an OS, the official raspberry pi site proposes to run
dd bs=4M if=myiso of=/dev/sdb
followed by
pkill -USR1 -n -x dd
In order to show the progress.
Executing this last command, I do not have any output.
Why do I have any output and how can I monitor dd with pkill?
PS: Text from site
|
The dd command need to be run in the background (i.e. with an ending &) or in another window in order to be able to be monitored. As written, the pkill command is launched after dd has completed its job.
Otherwise, you might run pgrep dd to see if it is still running.
| How to monitor dd progress with pkill? |
1,469,235,459,000 |
This is with OSX.
When I run this in a terminal
scottcarlson$ sudo dd if=Downloads/CentOS-7-x86_64-Everything-1511.iso of=/dev/disk2 2> Desktop/out.txt
and then this in another
tail -f Desktop/out.txt
it only updates the log when I press Ctlt in the first terminal with the dd. Is this because of the nature of dd?
I... |
It only updates the log when I press Ctlt in the first terminal with the dd. Is this because of the nature of dd?
Yes. It is in the nature of dd to output its current status when it receives a given signal. Under most OSes, this signal is SIGUSR1, a standard signal but on OS X, it uses for the same a non standard si... | How come dd only outputs when I press Ctl+t? [duplicate] |
1,469,235,459,000 |
The question is whether the fact the device is a hybrid disk has any (and what) importance when using dd or other such tools, or if all operations run the same as for a HDD.
The context
The device in question is a Seagate ST1000LM014.
I used this command to make a backup before sending the laptop in for repairs (soun... |
It looks like you know what you're doing! If sdb worked before (on Linux), then it should definitely work again after a restore like you describe. If it happened to me I would be suspecting some kind of user error. But either way, I just can't see what could have gone wrong. E.g. if gunzip was fed the files in the... | SSHD cloning - something special to keep in mind, compared to HDD? |
1,469,235,459,000 |
Currently, my whole system is located at the end of my hdd. I'd like to move that data to the beginning and still have booting and other details working.
dd seems to do exactly what I want (to copy my data exactly how it is placed), but I'm not sure about things like booting, grub configs and so on. Will I need to set... |
(warning: this is very dangerous if you do not know what you are doing)
Yes, you can, but I do not recommend it (though I did it a few times, mostly to transfer a partition to another HDD).
dd if=/dev/sdaA of=/dev/sdaB
will transfer the data from sdaA to sdaB, but no checking will be done, all the partition will be c... | Can I use dd to move my system to another partition? |
1,469,235,459,000 |
Here it says that when using dd through dm-crypt to overwrite a block device, only the default dd block size should be used because dm-crypt's block size is the same (512 bytes), and increasing dd's block size might prevent the final blocks from being written to.
Does this also apply to openssl (in Linux)?
Here Gilles... |
TLDR it doesn't matter (if I guessed right)
First, openssl commandline does about 50 different things; only two of them take bulk input data: enc to encrypt or decrypt a "file" or encode/decode base64 as a special case that isn't really encryption, and dgst to hash and optionally sign or verify a "file". Of those only... | dd, cat & openssl: block size & buffer size |
1,469,235,459,000 |
I have a micro sd card that contains these partitions:
Disk /dev/sdb: 29,7 GiB, 31914983424 bytes, 62333952 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
Disk identifier: 0xa6202af7
Device B... |
Problem was that I didn't copy the last 512 bytes of the last sector. This way the last partition was incomplete. By copying one more sector everything mounted properly.
| Cloning and remounting sd card |
1,469,235,459,000 |
My ZFS pool consists of two mirrored disks. I have two more disks which I plan to use for rotating offsite backups. The first backup disk was added to the zpool and has nearly completed resilvering.
My question is: if I remove the resilvered backup disk from the machine can I dd it to the second backup disk, and hav... |
No, you can't use dd and have any semblance of safety for your data.
If you're running Oracle Solaris, then you can use the 'zpool split' command.
Please see https://docs.oracle.com/cd/E36784_01/html/E36835/gjooc.html for details
| Can I use dd to quickly resilver a ZFS mirror disk? |
1,469,235,459,000 |
I am installing a Raspbian Linux image onto an sd card inserted into my BeagleBone Black. I will use this later in my Raspberry Pi.
To do this, I am using the dd command from my MacBook Pro (via ssh).
dd if=/Users/user/Downloads/2014-09-09-wheezy-raspbian.img | ssh [email protected] "dd of=/dev/mmcblk0"
It initially... |
Looks like you found the answer already. But another possibly easier to remember one is
killall -USR1 dd
(which would signal every dd process, which there is usually only one)
The output shows up on the original window because you are sending a signal to the existing 'dd' command, and dd has a feature where it dumps... | How can I see processes being run by another instance of root on my Beaglebone |
1,469,235,459,000 |
I'm doing some Android development on Ubuntu 11.10. I'm building a set of SD card and eMMC card Android images using a Bash script.
Due to Android's idiosyncrasies, I have several file system images that need to be copied to the target card. There are several lines in my script to copy over the images that look like... |
The first thing that jumps to mind is "files with holes". If a program opens a file, and uses the lseek() system call to set the file offset to greater than one file-system-block, then writes some bytes, the file system code only allocates a block for the data that got written. The first file-system-block does not get... | Why does a disk clone using dd take up more space on the target than the source image? |
1,469,235,459,000 |
I have a USB drive which has around 7MB of 'empty' space at its beginning. The first partition in MBR starts at 8225kB, according to Parted.
How can I back up this space using something like dd? I've already backed up the MBR table using dd if=/dev/sdX bs=512 count=1 of=device.mbr. How can I give dd a byte range in t... |
Using the skip flag, bs flag, and count flag, you can control how much data dd reads in and when to start.
dd if=/dev/sdX bs=1M count=7 skip=1 of=test.img
That command would start off at the second Megabyte of the disk, and backup seven megabytes.
| Backup 'empty' parts of disk drive |
1,469,235,459,000 |
My current HDD is failing and I've backed it up using dd. After restoring the images onto a new HDD, also using dd, the new system will not boot. It goes through the BIOS initialization, then screen goes black, and restarts and back through BIOS.
This is the old HDD setup:
Device Boot Start End Bl... |
As I see it, your new HDD lacks its Master Boot Record (MBR). That is why there's no GRUB coming up, and your system will simply report "OS not found!" or similar.
In order to transfer the old MBR to your new drive, you may want to take a look at this howto: http://www.cyberciti.biz/faq/howto-copy-mbr/
In short, it bo... | Restore using dd will not boot |
1,469,235,459,000 |
I am currently using a simple way to back up the drive dd if=/dev/sda of=/dev/sdb.
However, before each operation, I have to check fdisk -l to see if sda and sdb have been swapped during boot.
This is quite inconvenient and error prone.
Is using symbolic identifiers from /dev/disk/by-id/ instead of sda and sdb complet... |
Note the files in /dev/disk/by-id are actually just links to a device file.
$ ls -l /dev/disk/by-id/
total 0
lrwxrwxrwx 1 root root 9 Aug 1 18:31 ata-Hitachi_HDS723030ALA640_MK0331YHG99T1A -> ../../sdb
lrwxrwxrwx 1 root root 10 Aug 1 18:31 ata-Hitachi_HDS723030ALA640_MK0331YHG99T1A-part1 -> ../../sdb1
lrwxrwxrwx 1 ... | Is it safe to use /dev/disk/by-id/ instead of /dev/sda? |
1,469,235,459,000 |
In my Buildroot Linux image I try do
dd if=/mnt/disk.img of=/dev/sda bs=4M conv=fsync status=progress
But I get error
dd: invalid argument 'progress' to 'status'
Why?
|
in your Buildroot's buildroot/.config set
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
BR2_PACKAGE_COREUTILS=y
If still problem, check this options in your BusyBox's .config
CONFIG_DD
CONFIG_FEATURE_DD_THIRD_STATUS_LINE
To check you can watch file buildroot/output/build/busybox-1.35.0/.config (Please don't try to edit this fil... | dd: invalid argument 'progress' to 'status' |
1,469,235,459,000 |
So from what I know conv=fsync means that the cache is fully written before dd quits. But does that mean otherwise the writing is not complete when dd quits? Like if I shut down the computer (after dd is seemingly done) the file might be left incomplete?
What about using dd to write all zeroes to a hard drive?
|
dd conv=fsync causes dd to flush the OS cache for the file it is writing before it exits.
Normally,without this option, dd will exit as soon as the OS has accepted all the data to write. If you shut down the OS, it will flush things to disk and unmount the filesystem before shutting down.
So, if you shut down normall... | Does not putting conv=fsync mean that if you shut down your computer the copy might not be complete? |
1,469,235,459,000 |
I'm trying to clone a bootable 1GB compactflash to a second 1GB complactflash, but when I try to mount it, i get an error like so,
sudo mount /dev/sdb1 /media/frank/cloned/
frank@ThinkPad2:~$ sudo mount /dev/sdb1 /media/frank/cloned/
mount: /media/frank/cloned: wrong fs type, bad option, bad superblock on /dev/sdb1,
... |
If you want to clone a bootable drive, it is not enough to clone a partition, but you should clone the whole drive, including the head end. You can do that with dd with source (and target) as /dev/sdx (not /dev/sdx1 which is cloning partition number one and not the whole drive).
But using dd this way is risky because ... | Unable to mount cloned compact flash after using dd to clone bootable compact flash |
1,469,235,459,000 |
when I run command dd if=/dev/random count=1 bs=32 I get some random junk binary data but after receiving them, there is still some characters (as I see always 1;2c) after termination of dd process.
[amirreza@localhost ~]$ dd if=/dev/random count=1 bs=32
¾¿܄ÌYLÔAëEÔr/f&-È<>ýø1+0 records in
1+0 records out
32 bytes co... |
This is one of the situations that reveals that a Linux/Unix GUI terminal window is not actually a single integrated thing, but three things working more or less together:
the terminal emulator (the actual GUI terminal application, or the built-in terminal emulator of the Linux text console)
the TTY or PTY (pseudo-TT... | why reading from `/dev/random` put `1;2c` character behind the cursor? [duplicate] |
1,469,235,459,000 |
[EDIT: simplified and corrected]
I would like to use the same method as Raspbian install which relies on dd deployment to a µSD. Meaning, from a minimal image file, deploy the "augmented" Raspbian system partitions with dd on a SD card, resulting into two partitions and their files.
Is there a way to augment (inject f... |
@sudodus helped me find the answer.
How to augment the image? -> mount the image file as loop disk/partitions. Use a mounting point. Add the files.
For details: another loop question
How to use dd to write the augmented image to another µSD?
sudo dd bs=4M status=progress of=/dev/sdf if=/dev/loop1 conv=fsync
| How to append files to an image file and deploy it with `dd` to a device? |
1,469,235,459,000 |
How do I go about making DD use the entire space of a drive when I write an image to it? When I write a 1gb image to an 8gb USB, I get a 1gb partition, and the rest of the storage space is unused. I want to write the 1gb IMG to the drive and have the entire drive all be one partition. I'm trying to figure out how to d... |
The task of dd is to write the image as it is, so dd does not expand the partition. What you can do is after the operation to expand the partition, try GParted. To do it by a command line, I need to know what kind of file system you create (Reiser, ext3, ext4, fat32?)
| Use entire drive when writing disk with DD |
1,469,235,459,000 |
I'm going to move the data from a 2Tio drive to an SSD, whick is only 120Gio. The drive only has one partition and only contains like 16Gio. To make sure I get everything when transferring with ddrescue, I want to make sure all data is in the beginning of the partition. Any tools to do that?;)
|
If ddrescue is involved, it suggests the source drive is not exactly in good health. In that case, you should not modify the source drive in any way before copying, as it might make the problem worse.
Only if the source disk is healthy, and the filesystem type on the source disk supports shrinking the filesystem, you ... | Move data to beginning of partition |
1,469,235,459,000 |
I have some ext4 and LVM partitions on a disk. I executed dd to dump this disk content to a file.
Now I can mount ext4 partition by using offset but don't know the way to mount the LVM partition.
What is the command to mount the LVM partition from dd file.
|
You could create a loop device out of the image. LVM should be able to automatically detect all the VGs and LVs. Then you can mount/change whatever you want. Use lsblk and vgs or lvs to check what was detected.
Example:
lodev=$(losetup -f --show -P $YOURIMAGEFILE)
If you don't need the partitions/LVs/filesystems anym... | Offset LVM mount |
1,469,235,459,000 |
I have a dual boot system with this partition layout:
# fdisk -l
Disk /dev/sda: 596.2 GiB, 640135028736 bytes, 1250263728 sectors
Disk model: SAMSUNG HM640JJ
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: do... |
dd if=/dev/sda of=boot.img bs=512 count=63 conv=fdatasync
You're backing up the Master Boot Record and 62 other sectors, so 31.5 kilobytes. But the part of GRUB2 embedded on the first track of the disk after the MBR can easily be bigger than that.
Yes, you may have checked the size of /boot/grub/i386-pc/core.img and ... | Can I restore a Grub installation using dd? |
1,469,235,459,000 |
I have a home-brew media server based on a 800MHz Intel Atom with two big LVM drives and Debian 9 on a 250GB 2.5" drive. The latter is showing bad blocks, so I am intending to replace it.
I booted from a Debian live CD and dd'd the entire 250GB disk surface onto a new WD Blue 1TB drive with dd if=/dev/sda of=/dev/sdd ... |
Prelim
I assume youve backed up — redundancy proportional to the value of the data!
dds as well as tarballs
So… You did a full-device dd uh…uh.
Double that for badblock source disk. And again for quite different source and target disk architectures
Following are slight improvements (for completeness only) I dont real... | Why does replacing drive with a dd clone cause machine to hang at boot? |
1,469,235,459,000 |
The size of a partition is close to 2Gb and the actual used size is 1.5Gb, I am trying to make image of this partition using dd with conv=sparse flag enabled.
The generated image by dd is of size 1.8Gb.
du shows that the actual used size of partition is 1.5Gb.
What puzzles me the most is that, earlier in the day, wh... |
Your guess is correct. dd has no concept of filesystem usage, it just copies data (or not, if conv=sparse is set and the entire block is zero).
It's also possible to have a 100% full filesystem, and yet a tiny dd sparse image. Assuming your files are full of zeroes.
There's a difference between free space and intenion... | df size of partition and dd-ed image with sparse flag does not match |
1,469,235,459,000 |
This is my root volume, it is 32GB and contains /boot, and on LVM LV's are / and swap.
sdb 8:16 0 29.8G 0 disk
├─sdb1 8:17 0 200M 0 part /boot/efi
├─sdb2 8:18 0 256M 0 part /boot
└─sdb3 8:19 0 29.4G 0 part
... |
You're missing a step. After resizing the sdb3 partition and booting into the new system, you'll need to use the pvresize command to tell LVM that it is allowed to use the new space within the extended sdb3.
So:
2.5. Boot into the new system, then pvresize /dev/sdb3
In step 3, I would generally prefer using lvextend i... | How do I clone a SSD containing LVM LV's and /root to a larger one? |
1,469,235,459,000 |
I need to securely erase a CD without marks of intentional data loss (can't scratch or break it), so I was wondering: how could I use growisofs or dd to burn all non burned spaces in the disk to render it unreadable?
|
growisofs works only with DVD or BD media. dd cannot write to unformatted
CD (only CD-RW but not CD-R could be formatted).
A CD-R medium might be still writable (aka "appendable") on its unused
area. But it cannot be blanked in any way. You may only overwrite the
unused area by some harmless bytes. (Question is why yo... | Can growisofs or dd be forced to erase a CD-R? |
1,469,235,459,000 |
I am currently working on a custom initrd based on the CentOS 6.7 (2.6) kernel with the following modules loaded.
The initrd is designed to backup files off a old RHEL system into memory, unmount the disk, wipe the disk and then finally dd a prebuilt CentOS system onto the disk.
The CentOS system was built on VMware ... |
Since you wipe the disk, the running kernel will not know about the partitions available.
You can run partprobe (as comes with the parted partitioning utility) to reload the correct partitioning info in your running kernel.
If you don't have partprobe (small discs not requiring parted?), you can use hdparm -z /dev/yo... | LVM devices not showing in initrd but working on boot [duplicate] |
1,469,235,459,000 |
I have a MacBook with Linux installed on the primary hard drive. On an external USB 3.0 drive, I have OS X installed.
The external drive has plenty of space so I would like to boot up OS X and make regular copies of the primary drive using dd.
Performing the backup the other way would be simply done using something l... |
diskutil list
will show you the Drives.
A Partition is /dev/diskXsY.
So
dd if=/dev/diskXsY of=/BACKUPIMAGE.img
with the appropriate X and Y should do it for you.
| how to use dd to backup second linux hard drive from os x? |
1,469,235,459,000 |
I've been cloning complete HDD images to restore OS crashes using DD and GZIP for a while now using dd if=/dev/sda | gzip > img.gz and gzip img.gz | dd of=/dev/sda
This always working fine, but the process is a little slow. It takes more than 2 hours to create or restore an image. I started experimenting with faster (... |
Is the restored image the same size as the original one ?
You can test restored size using :
lz4 -v img.lz4 > /dev/null
If not, maybe the following line would be a bit safer :
lz4 -d img.lz4 | dd of=/dev/sda
| HD clone using LZ4 and DD fails |
1,469,235,459,000 |
dd is a great tool for copying and conversion.
Is there any way by dd (or by any other way), to dump the first few bytes from a file to an unmounted partition?
Something like this:
dd if=hda2.pbr of=/dev/hda2 bs=512 count=1
The goal, I'm trying to achieve is to copy out the PBR of a partition to file and restore it a... |
Based on your edit, I think you might find the following pretty useful:
man wipefs
DESCRIPTION
wipefs can erase filesystem, raid or partition-table signatures (magic strings) from the specified device to make the signatures invisible for libblkid...
OPTIONS
-a, --all Erase all available signatures. The set o... | `dd` to specific location [closed] |
1,469,235,459,000 |
I'm trying to conceive a firmware update mechanism for a Linux-based embedded system without an additional initrd/initramfs/whatever. From within the running system, which has a read-only mounted root, I use dd to copy the new root image (residing on a secondary data partition).
The problem is that half of the times I... |
You're overwriting a mounted filesystem. As soon as the file system driver attempts to read anything from it, you're bound to end up in trouble.
You'll need to make sure that as soon as you're writing the new firmware, nothing else must read or write that partition.
What people usually seem to be doing to circumvent t... | live dd over a mounted read-only root partition |
1,469,235,459,000 |
I used dd to write a 2GB image to an 8GB SD card; gparted now sees it as a 2GB SD card and I can't figure out how to format it for 8GB again. ddalso sees it as a 2GB SD card when trying to format it with of=/dev/sdb if=/dev/zero bs=1M. How can I get it to know its real size?
|
you can use the following commands:
cat /proc/partitions
cfdisk YOUR_DEVICE ===> such as cfdisk /dev/sdb
| SD Card interpreted as wrong size |
1,326,545,482,000 |
I have had gnupod for a while. Still haven't figured out how to use it though. I usually just go for gtkpod. So this question, in case anyone had any doubts after reading everything below, is purely about gnupod syntax.
Recently I decided to get my ipod replaced under this replacement scheme. (I don't like proprietary... |
First, gnupod does not work directly with the iPod database, you need to convert from and to the gnupod database, so you want to run tunes2pod.pl first. This only needs to be done when you change the iTunesDB (iPod's own database) directly — if you use gnupod again without using other tool, you don't need to run this ... | Backed an ipod up with dd, how to retrieve all tracks in one go with gnupod? |
1,326,545,482,000 |
I am using an ubuntu live cd to help me recover some data off of a hard drive. I used lshw -C disk to find out which device I need to copy, /dev/sda in this case.
I am using ddrescue -n to try and recover some data from a failing hard drive. It stops at 100GB of a 500GB hard drive. After it finishes sudo lshw -C disk... |
It looks like the way in which your disk is failing is so bad that the kernel becomes unable to keep communicating with the disk.
There are probably a lot of errors concerning the disk in /var/log/kern.log. If you post its contents here, people might have tips to help you recover more. (Post only the part from the fir... | "lshw -C disk" returns but prints nothing |
1,326,545,482,000 |
I have a dual boot system with ubuntu 20.04 and windows 10. Because of being low on space I am upgrading my ssd to 512 gigs. I have booted into live ubuntu drive, and backed up each partition ubuntu, windows, efi as well as microsoft reserved from the previous 256 ssd via dd as follows
dd if=/dev/nvme0n1p6 of=/path/to... |
From the presence of the msftdata "flag" on the NTFS partition and the existence of /boot/efi FAT32 partition, I see you are using GPT partitioning and are booting in native UEFI mode, instead of legacy MBR and BIOS, respectively. These two nuggets of information have a major effect on the actions you must do.
If your... | How to edit grub file after restoring data on a new drive via dd? |
1,326,545,482,000 |
How to use dd to clone a disk but exclude some partitions?
So I got (on a Raspberry Pi 4B):
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 532479 524288 256M c W95 FAT32 (LBA)
/dev/mmcblk0p2 532480 227000319 226467840 108G 83 Linux
/dev/mmcblk0p3 ... |
"backup the first 227000320 sectors"
Start backing up the whole /dev/mmcblk0p disk, but stop copying at the end of /dev/mmcblk0p2.
Which is counted as 227000320 sectors.
NOTE: in your above input a fundamental information is missing, so I assume you have this:
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical... | How to use dd to clone a disk but exclude some partitions? |
1,326,545,482,000 |
I am creating an image of an sd-card partition (dd) and eventually the checksum (md5sum) of the image and the partition are not the same.
What am i doing wrong?
My sd card is inserted into an external reader but not mounted.
sudo fdisk -l
Device Boot Start End Sectors Size Id Type
/dev/sdc3 ... |
Your SD is dead or dying (see more below), you will need to replace it. I’ve included some advice on what to use instead:
Using a SD card for a Raspberry Pi will drastically reduce their life expectancy. There are designed for 15 years of camera use, but with a RPi you will be writing logs tens if not hundreds of time... | md5sum of image and sd-card partition differ |
1,326,545,482,000 |
I have a USB drive with Manjaro ARM on it (which is used for Raspberry Pi 4 system) and an empty SD card.
Is there a possible way to transfer the OS from USB drive to SD card, while preserving the partitions?
If it is possible, can it be done while Manjaro is running?
Here is the output of lsblk:
$ lsblk # partitions ... |
Is there a possible way to transfer the OS from USB drive to SD card, while preserving the partitions?
Yes, assuming the sd card it as least as big as the usb drive. You can run blockdev --getsize64 /dev/sda to get the size of your usb drive in bytes, and by changing the device path to the sd card you can ensure i... | Transferring OS from one medium to another |
1,548,338,493,000 |
Hard drives (non-SSD) are generally wiped with the command dd if=/dev/urandom of=/dev/sdX conv=fsync status=progress. Since power outages do occur, this lends to restarting the wipe process multiple times. Additionally, there are often requirements to move equipment.
dd as far as i know and based on my research does... |
You don't need ddrescue for this. You can use plain dd and make it print progress when wiping:
dd if=/dev/urandom of=/dev/sdX bs=256k 2>/media/usb/progress.txt &
while kill -USR1 $!; do sleep 10; done
This will begin wiping the disk, sending the process to the background, and then telling it to write its progress to ... | How can gnu_ddrescue be resumed to wipe a hard disk? [closed] |
1,548,338,493,000 |
Is there any way to mount an ext4 partition in another PC, running Windows, at the same network in my Ubuntu Live?
My HD just died earlier today and I needed to use Live Distros until I get a new one. I choose Ubuntu 18.10. I customized my Ubuntu Live and to do it I needed to make an EXT4 partition on my notebook HD(r... |
Unfortunately¹, Windows cannot even read EXT4 partitions without third-party software. There are a few of them out there that can do local read-only mounting of EXT4 partitions but only one (commercial) that can do both reads and writes.
However, none of those will allow you to share these on a Windows Network: they'r... | Mount an ext4 partition in another PC(Windows) at the same network in my Ubuntu Live? |
1,548,338,493,000 |
I'm following this guide to make a simple bootloader. It generates a file disk.img.
$ dd if=/dev/zero of=disk.img bs=1024 count=1440
$ dd if=vbr.bin of=disk.img count=512 conv=notrunc
$ file disk.img
disk.img: DOS/MBR boot sector
Running qemu-system-i386 and qemu-system-x86_64 on disk.img boots fine, displays the des... |
For some reason, the steps I took to create disk.img make it so that disk.img can only be properly written to a floppy. However, eliminating the image file entirely (writing directly to the USB) worked (make sure you're using /dev/sdX instead of /dev/sdXY):
$ dd if=/dev/zero of=/dev/sdc bs=1024 count=1440
$ dd if=vbr.... | Burn a disk image to a USB |
1,548,338,493,000 |
I have a software RAID-10 setup on Linux 3.16.6-203.fc20.x86_64, with 1.2 metadata and the default chunk size (512K):
$ cat /proc/mdstat
md0 : active raid10 sdc1[4] sdb1[0] sdd1[2] sde1[3]
3907023872 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]
bitmap: 4/30 pages [16KB], 65536KB chunk
unused de... |
RAID10 does not accelerate any form of O_*SYNC, at least not for small files. You're writing 512b at a time, and after each write forcing it out to disk (plus the metadata required to read it back, e.g., file size).
That requires RAID10 writes to at least 2 disks, probably 4 (i.e., all your disks). And all those writ... | Software RAID10 setup writes small files extremely slowly, is this normal? |
1,548,338,493,000 |
Trying to clean the mbr code part on a disk using the pfsense 2.7.0 live disk (pfsense is based on freebsd) under shell command.
being /dev/da0 my drive following the suggested code for clean just the mbr code keeping the partitions the command should be:
dd if=/dev/zero of=/dev/da0 bs=446 count=1
however... the resu... |
Ok, I did many test and came to this conclusion...
Because pfsense is a damn stripped version of freebsd and LOT of tools are missing I had to do this to clear the first 446 byes in the disk preserving the partition table located at the latest 66 bytes of the first 512 bytes block.
dd if=/dev/da0 of=/tmp/mbr_file_orig... | using dd for clean MBR code doesn't work on pfSense |
1,548,338,493,000 |
When secure erasing a disk, how can I do a "bit-wise complement" with dd? (or with other UNIX tools?)
|
I'm going to preface this by saying that bitwise complementing a disk is not a secure erase, because if someone knows what you did, all they have to do is reverse the process to restore the disk to its original state.
While bash has a complement operator, I don't think it can be used here because you can't work on raw... | bit-wise complement with dd? |
1,548,338,493,000 |
I want to clone a whole disk bytewise, something like
dd if=/dev/$SRC of=/dev/$DST bs=65536 count=$count
There are better tools for the job, which understand the file system (Windows) and work faster (I don't care), but they fail because of unreadable sectors on the old source disk.
There's actually a single invalid ... |
Do not reinvent the wheel. Use ddrescue.
GNU ddrescue is a data recovery tool. It copies data from one file or block device (hard disc, cdrom, etc) to another, trying to rescue the good parts first in case of read errors.
Do not trust dd conv=sync,noerror, unless you really know how it works.
| How to disk copy with unreadable sectors? |
1,548,338,493,000 |
i recently created a test file, because I wanted to play around with logrotate. I was searching for a solution to create a file with any size I want. I found out that this is my solution:
dd if=/dev/zero of=/path bs=1M count=30 status=progress
I also found this:
dd if=/dev/urandom of=/path bs=1M count=30 status=prog... |
As you can see from your output, both methods are quite fast. However, there is a distinct difference between the sources of your data.
/dev/zero is a pseudo-file which simply generates a stream of zeroes, which is a rather trivial task
/dev/urandom actually accesses the kernel's pool of entropy to generate random nu... | Why does it take longer to create a file with random text than with zeros? |
1,599,039,485,000 |
The command sudo dd if=/dev/sdb | pigz -c | sudo tee /sdb.img.gz (omitted sudo in the title) prints binary data to console either the output of dd or pigz. I'm wondering why since all output are caught in a pipe | and the last in the chain is redirect to file. So, there's no "leak" to stdout. What am I not getting her... |
tee duplicates its input, sending it (in your case) to its standard output and /sdb.img.gz. You can redirect its output to avoid seeing the output on your console:
sudo dd if=/dev/sdb | pigz -c | sudo tee /sdb.img.gz > /dev/null
I would run pigz directly as root instead, avoiding dd and tee:
sudo sh -c 'pigz -c < /de... | Why does dd if=/dev/sdb | pigz -c | tee /sdb.img.gz print to console? |
1,599,039,485,000 |
I have a MicroSD card that is 64GB in size. I wrote an image to it that is 16GB in size with this:
$ sudo dd if=my_image.img of=/dev/sdb bs=4M
3798+1 records in
3798+1 records out
15931539456 bytes (16 GB, 15 GiB) copied, 657.848 s, 24.2 MB/s
Now, I want to take an image of the first 15931539456 bytes (16GB) of the s... |
Few possibilities:
Use a smaller bs, yet not very small:
dd if=/dev/sdb of=new_image.img bs=512k count=30387
This is not a general solution. It works here because 15931539456 can be factorized.
Use your desired bs, read more and truncate on the fly:
dd if=/dev/sdb bs=4M | head -c 15931539456 >new_image.img
You don... | How do you have granular control of dd? |
1,599,039,485,000 |
We all have (or know someone who has) unintentionally misused the destroy-disk (dd) command. What ways exist (if any) to change the command in the following or a similar way: If /dev/sda is given as the output file (of=/dev/sda) the command doesn't run or prompts for confirmation with something like "are you sure abou... |
As Arkadiusz said, you can create a wrapper:
dd() {
# Limit variables' scope
local args command output reply
# Basic arguments handling
while (( ${#} > 0 )); do
case "${1}" in
( of=* )
output="${1#*=}"
;;
( * )
args+=( "${1}" )
;;
esac
shift || break
done
# Bui... | Can you make the `dd` command safe? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.