Tag Info

Hot answers tagged

100

dd is most certainly the best cloning tool, it will create a 100% replica simply by using the following command. I've never once had any problems with it. dd if=/dev/sda of=/dev/sdb bs=32M Be aware that while cloning every byte, you should not use this on a drive or partition that is being used. Especially applications like databases can't cope with this ...


71

To save space, you can compress data produced by dd with gzip, e.g.: dd if=/dev/hdb | gzip -c > /image.img You can restore your disk with: gunzip -c /image.img.gz | dd of=/dev/hdb To save even more space, defragment the drive/partition you wish to clone beforehand (if appropriate), then zero-out all the remaining unused space, making it easier for ...


32

CAUTION: dd'ing a live filesystem can corrupt files. The reason is simple, it has no understanding of the filesystem activity that may be going on, and makes no attempt to mitigate it. If a write is partially underway, you will get a partial write. This is usually not good for things, and generally fatal for databases. Moreover, if you screw up the ...


17

Copying from source to target where target has sshd running: dd if=/dev/sda | gzip | ssh root@target 'gzip -d | dd of=/dev/sda' Copying from source to target via sshd_host when target is not running sshd. Target: nc -l -p 62222 | dd of=/dev/sda bs=$((16 * 1024 * 1024)) Source: ssh -L 62222:target:62222 sshd_host & Source: dd if=/dev/sda | nc ...


17

dd just reads from block 0 to block 99999 and copies the data. Clonezilla understands filesystems and understands when there is nothing to be copied (because that's empty space or data from a file that's been deleted). Once you know not to copy all the useless data, it is much easier to copy the real data. From the web page "For unsupported file system, ...


16

To clone a disk, all you really need to do is specify the input and output to dd: dd if=/dev/hdb of=/image.img Of course, make sure that you have proper permissions to read directly from /dev/hdb (I'd recommend running as root), and that /dev/hdb isn't mounted (you don't want to copy while the disk is being changed - mounting as read-only is also ...


16

You don't need to split this at all. Use parted to get details about the partition table: parted image001.dd In parted, switch to byte units with the command u, then B. After that, issue the command print. You will get an output that looks like this (output is from an actual system, not an image): Model: Virtio Block Device (virtblk) Disk /dev/vda: ...


16

It's much better to simply use kpartx tool. usage : kpartx [-a|-d|-l] [-v] wholedisk -a add partition devmappings -d del partition devmappings -l list partitions devmappings that would be added by -a ... Example: # kpartx -l whole_disk # only listing loop0p1 : 0 518144 /dev/loop0 2048 loop0p2 : 0 3674112 /dev/loop0 520192 # kpartx -a ...


15

When using dd to clone a disk which may contain bad sectors, use "conv=noerror,sync" to ensure that it doesn't stop when it encounters an error, and fills in the missing sector(s) with null bytes. This is usually the first step I take if trying to recover from a failed or failing disk -- get a copy before doing any recovery attempts, and then do recovery on ...


11

Sure, of course it's possible. dd if=/dev/mygroup-mylv | ssh 192.168.1.103 dd of=/dev/newvgroup-newlv Boom. Do yourself a favor, though, and use something larger than the default blocksize. Maybe add bs=4M (read/write in chunks of 4 MB). You can see there's some nitpicking about blocksizes in the comments; if this is something you find yourself doing ...


10

You have your "backup" script being executed by cron... and you shut down cron in the script in order to prevent cron jobs from running during the "backup". You really can't see where is the problem here? Your script shuts down crond, but crond is running your script, so, shutting down crond will close the descriptors connected to your script, which will ...


10

Create a disk image. The following command will create a 10G sparse image: # dd if=/dev/zero of=mydisk.img bs=1 count=0 seek=10G 0+0 records in 0+0 records out 0 bytes (0 B) copied, 1.6554e-05 s, 0.0 kB/s # ls -lh mydisk.img -rw-r--r--. 1 root root 10G Jun 17 15:27 mydisk.img Partition the image with fdisk: # fdisk mydisk.img Make sure you create ...


10

Create an image in a ramdisk containing whatever tools you require to nuke the system, then pivot_root into it, run the tool, away you go. Pivoting out of a full system isn't trivial, but it can be done if you know what you're doing.


10

This will go against most conventional wisdom on the Internet, but here we go... If this is a modern rotating disk, a simple pass of dd with /dev/zero is enough to foil almost any attempt at data recovery, even from a professional data recovery house. It might be possible to extract some data with extremely expensive specialized equipment (e.g. a ...


8

For copying CDs then both are fine although I generally expliciatlly set the block size by doing dd if=/dev/cdrom of=cdrom.iso bs=512 For other block devices then cp might not work if the block size on the device is unexpected. From http://en.wikipedia.org/wiki/Dd_(Unix) Note that an attempt to copy the entire disk image using cp may omit the final ...


8

Ok, first thing first: DO NOT REBOOT. What you need is to reinstall the master boot record (basically, relaunch grub or lilo) rebuild the partition table using tools such as gpart (which will scan your hd and try to determine boundaries of primary partitions, not logical ones) since you erased 1.4MB, what I'd suggest at this point is either try to ...


8

Send the dd process a USR1 signal: $ dd if=/dev/urandom of=/dev/null & [1] 977 $ $ kill -USR1 977 274647+0 records in 274646+0 records out 140618752 bytes (141 MB) copied, 17.3286 s, 8.1 MB/s $


8

Back in the day I ran into a similar problem with embedded Linux distributions - get rid of all the junk before compressing the image. dd if=/dev/zero of=asdf.txt. Wait until it dies. Delete asdf.txt. You've just written zeros to all free space on the device. Now take a disk image and run it through gzip. Voila, sparse image. Probably doesn't scale very ...


8

If you have to do this, and you have to be in a really bad place to even think about doing this... It's safest to copy the partitions individually. For instance: # Install a temporary ssh key so we don't have to deal with lots of # password prompts, remember to remove it from authorized_keys later ssh-keygen ssh-copy-id -i ~/.ssh/id_rsa user@host # Copy ...


8

What you have done is a read speed test. if you are actually copying blocks to another device you have pauses in the reading while the other device is accepting the data you want to write, when this happens you can hit rotational latency issues on the read device (if it's a hard disk) and so it's often significantly faster to read 1M chunks off the HDD as ...


7

Use kpartx (from multipath-tools): use losetup to get a /dev/loop? device, then use kpartx on it to create dev mappings for the partitions in the image file.


7

The source disk must not have any mounted filesystems. As a user able to read the block device (root works), run 'dd if=/dev/sda ....' Now, one of the neat things here is that you're creating a stream of bytes... and you can do a lot with that: compress it, send it over the network, chunk it into smaller blobs, etc. For instance: dd if=/dev/sda | ssh ...


7

If the source drive is damaged at all, you'll have more luck using dd_rhelp with dd_rescue (my personal preference) or GNU ddrescue. The reason behind this is that, on read errors, dd keeps trying and trying and trying - potentially waiting for a long time for timeouts to occur. dd_rescue does smart things like reading up to an error, then picking a spot ...


7

Here's an optimized version, which shows the progress using pv and uses BS for bigger chunks and also uses gzip to reduce the network traffic. That's perfect when moving the data between slow connections like internet servers. I recommend to run the command inside a screen session. That way the ssh connection to the host from where you execute the command ...


7

i've done it few times executing dd if=/dev/zero of=/dev/sda no additional preparations. it worked. system was running fine for days after dd finished [responding to pings, forwarding packets].


6

Another nice thing you can do with dd and rescue disks is copy data over the network: remote_machine$ nc -l -p 12345 local_machine$ dd if=/dev/sda | nc remote_machine 12345 You can stick gzip in both these pipelines if the network is not local. For progress, use pv. To make local_machine's netcat quit after it's done copying, you might add -w 5 or ...


6

To clone a disk, all you really need to do is specify the input and output to dd: dd if=/dev/hdb of=hdb.img Of course, make sure that you have proper permissions to read directly from /dev/hdb (I'd recommend running as root), and that /dev/hdb isn't mounted (you don't want to copy while the disk is being changed). Once complete, hdb.img will be a ...


6

If all is well up to that point then I think you just need to resize2fs the filesystem up to 40Gb: resize2fs /dev/sdc1 where /dev/sdc1 is the name of your partition. Took off the size as per womble's excellent comment below. resize2fs will grow the filesystem when it's mounted. It can also shrink it but needs to be unmounted for that.


6

With that command, you're cloning a partition to a disk, which is skipping the partition table. Try this: $ dd if=/dev/sda of=/dev/sdb


6

.Check this dd version out



Only top voted, non community-wiki answers of a minimum length are eligible