Tag Info

Hot answers tagged

86

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 ...


62

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 ...


16

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 ...


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 ...


16

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, ...


15

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: ...


15

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 ...


12

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 ...


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

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

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

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

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 ...


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

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 ...


6

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 ...


6

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 ...


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

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

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 ...


6

You can use the free Idera R1Soft Hot Copy utility to accomplish this. This is a utility that installs as a kernel module and allow you to take a copy-on-write snapshot of a running system. You can install it and run on-the-fly without a reboot. The result is that you can create an on-demand read-write or read-only snapshot of any of your mounted ...


6

Try using dd with conv=notrunc dd if=/dev/zero of=myserver.img bs=512 count=1 conv=notrunc From the dd man page notrunc do not truncate the output file e.g. ls -l myserver.img -rw-r--r-- 1 iain users 1536 Mar 27 12:31 myserver.img dd if=/dev/zero of=myserver.img bs=512 count=1 conv=notrunc ls -l myserver.img -rw-r--r-- 1 iain users ...


5

I think you have multiple things going on here. You'll never be able to boot a non-x86/x64 operating system in VMware Workstation. It isn't a CPU emulation environment, but rather a virtualization environment for the host CPU. That having been said, it sounds like you've taken an image of a partition and turned that into a disk image. The VMWare ...


5

The most likely cause is root squashing. This is a server option that changes the the requester for file operations when coming from the clients root user. Commonly the root user is changed to nobody on the server. If /mnt/nfs is exported from the server with root squashing then the user nobody will need to have permissions to write to the directory.


5

Please, please, please do not use dd to take backups of your physical volume, for all of the reasons stated in the comments to your question. At the very least if you want to do disk-to-disk backups use something like rsync (although even that isn't without its problems), and come back here if you can't get that to work from cron.


4

You cannot create a file greater than 4GiB (2^32-1 bytes) on FAT32 partition, period. So if you want to use that image file with some VM software, you are probably out of luck, as I known no VMs which can work around limitations of braindead filesystems. But if you are just trying to store the image there temporarily, you can create it with dd by 4GiB ...


4

AFAIK, you first command is not functionnal. You are trying to pipe the output of /dev/zero into a command that takes no input. cat /dev/null is just a command that outputs nothing. Piping anything something in it will therefore do nothing at all. When you use the stdout redirect, the output of /dev/zero gets written to the file in question (/dev/null ...


4

You can use the seek parameter of dd to create a sparse file: dd if=/dev/zero of=filesystem.img bs=1k seek=1024M count=1 would create a file which can get up to 1G in size but will only occupy the necessary space.


4

Try dstat or iostat with SWAT or Cacti for charting. (This is assuming you're not using Solaris, OpenIndiana or variants in which case you'd use Dtrace.) http://freshmeat.net/projects/dstat/?branch_id=54241&release_id=251831 http://blogs.oracle.com/paisit/entry/import_iostat_data_to_swat http://forums.cacti.net/post-170326.html Also look at: ioapps ...



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