Tag Info

Hot answers tagged

85

In appearance, dd is a tool from an IBM operating system that's retained its foreign appearance (its parameter passing), which performs some very rarely-used functions (such as EBCDIC to ASCII conversions or endianness reversal… not a common need nowadays). I used to think that dd was faster for copying large blocks of data on the same disk (due to more ...


29

Moving or cloning a Linux installation is pretty easy, assuming the source and target processors are the same architecture (e.g. both x86, both x64, both arm…). Moving When moving, you have to take care of hardware dependencies. However most users won't encounter any difficulty other than xorg.conf (and even then modern distributions tend not to need it) ...


17

Normally I would suggest a solution such as "hook up the 2nd hard drive using an external enclosure, boot from a linux CD, then use a command such as 'dd if=/dev/sda of=/dev/sdb bs=1G', but since you want to use the same technique for work, I have what may be a better solution. All of my servers and laptops get imaged at work using Clonezilla. There are ...


17

I'm not sure if this answers your question, but typically you do the exact opposite -- you move your user folder and reinstall everything. In theory all your customization and individual configuration files should be in your user folder, so that's the only thing you really need to transfer Some package managers have a way to list all installed packages ...


14

The dd command includes LOTS of options that cat is not able to accommodate. Perhaps in your usage cases cat is a workable substitute, but it is not a dd replacement. One example would be using dd to copy part of something but not the whole thing. Perhaps you want to rip out some of the bits from the middle of an iso image or the partition table from a hard ...


12

No one has yet mentioned that you can use dd to create sparse files, though truncate can also be used for the same purpose. dd if=/dev/zero of=sparse-file bs=1 count=1 seek=10GB This is almost instant and creates an arbitrary large file that can be used as a loopback file for instance: loop=`losetup --show -f sparse-file` mkfs.ext4 $loop mkdir myloop ...


12

You want dd_rescue. dd_rescue -a -b 8M /dev/sda1 /mount/external/backup/sda1.raw


9

Assuming it is an ext2-family filesystem: uuidgen tune2fs -U <output of uuidgen> /dev/sdb1 Or if you're confident uuidgen is going to work: tune2fs -U `uuidgen` /dev/sdb1 The UUID is stored in the superblock, so a byte-for-byte copy of the filesystem will have the same UUID.


8

Override specific segments of a hard-drive with something is a common example. For example you might want to delete your MBR using this command: dd if=/dev/zero of=/dev/sda bs=446 count=1 Also you can create empty files with it (say for loop disk images): dd if=/dev/zero of=10mb.file bs=1024k count=10


7

Just for completeness the call for ddrescue: $ ddrescue -S -b8M /dev/sda1 /mount/external/backup/sda1.raw Or with long option: $ ddrescue --sparse --block-size 8M /dev/sda1 /mount/external/backup/sda1.raw Or if you prefer MiBs: $ ddrescue -S -b8Mi /dev/sda1 /mount/external/backup/sda1.raw Note that GNU ddrescue and dd_rescue are different programs. ...


7

dd is very useful for backing up the boot sector of a hard drive or other storage device (dd if=/dev/sda of=boot_sector.bin bs=512 count=1 ) and then later rewriting it (dd if=boot_sector.bin of=/dev/sda). It is similarly useful for backing up the headers of encrypted volumes. cat might be able to be twisted into doing that but I wouldn't trust it on the ...


6

Indeed while under Windows it is almost impossible to move an installation to a new PC by just copying harddrive contents or switching the harddrive between the PCs, this works amazingly well under Linux. I switched from a Thinkpad R52 to a Thinkpad T400 by just copying the contents of my old harddrive to the new one (by putting the old one in an external ...


6

FSArchiver (http://www.fsarchiver.org/Main_Page) may do what you're looking for. Disk images include only data, not free space, and can be restored to disks of differing sizes.


4

You can use dd to copy the data from one device to another. dd if=/my/source/device of=/my/dest/device bs=4096 dd will do a byte-per-byte copy of the source, of course you will not be able to do this on a running filesystem, this will most likely cause corrupt data. If you are using a fileystem or some other utility like LVM with snapshot ability you can ...


4

You cannot and must not copy files in /proc, or /sys. Generally speaking, you need to arrange to copy only the disk-backed files. The files under /proc and /sys are generated by the kernel on the fly when you read them. Their contents provides information about the running system. For example, /proc/1234 is a directory where you can read information about ...


3

Introduction For a drive with PC partitions (which is what you'll find on most USB sticks), the bootloader consist in a tiny part at the very beginning of the drive (the stage 1 bootloader, in the boot sector of the drive) and a larger part elsewhere (the stage 2 bootloader, in a file). The stage 1 data contains the physical location of stage 2. If you copy ...


3

For XFS, use: xfs_admin -U <uuid> <device> Use xfs_admin -u <device> to view a UUID (note lower case option to view, versus upper case option to set). Another post on U&L pointed out the blkid command for viewing all or some of the UUIDs on the system.


3

Your first task would be to connect both disks to an existing Linux system or connect the new disk to the original system. You must be very careful since it is very simple to copy the blank disk on top of the good disk! To end up with the boot sectors and all, you would do something like: dd if=/dev/hdx of=/dev/hdy Where hdx is your 40G disk and hdy is ...


3

You should be able to tar up everything and extract it to the new drive. First plug in the second drive, then boot into something that doesn't use the source drive, such as a live CD. After that just copy everything over. For example: # Mount the source drive mkdir /mnt/source mount /dev/sda1 /mnt/source # Mount the destination drive mkdir /mnt/destination ...


3

I recently had had cause to clone some multiple-100s-of-GB partitions for the first time in my linuxing history (c.f cp -ar or rsync which have served me well many times). Of course I turned to dd 'cos everyone knows that's what you use... and was appalled by the performance. A bit of googling soon led me to ddrescue, which I've used a few times now and ...


3

Partimage makes exact copies of a partition having a supported filesystem, to the extent that it will copy the filesystem uuid as well. So you may need to change one of the uuids, if it confuses your OS or bootloader. Notable limitation - currently it does not support ext4 or btrfs. It is also free software, reliable, simple to use, well documented and ...


3

What you're looking for is a way to clone a filesystem, a disk or partition. See in particular How can I use DD to migrate data from an old drive to a new drive? Clone OS to a smaller drive Clone whole partition or hard drive to a sparse file Cloning a bootable USB stick to a different-size stick Cloning the whole disk or partition with cat or cp is the ...


3

Yes, it is possible. It is not very hard but it requires a good comprehension of boot sequence. The "copy" sequence is something like: partition you usb stick and mkfs the partitions. copy the files from source partitions to usb-stick partitions (e.g. using rsync). modify the /etc/fstab to match your new partitions. install a new boot-loader on usb-stick. ...


3

QEMU comes with the qemu-img program to convert between image formats. qemu-img convert -f qcow2 -O raw my-qcow2.img /dev/sdb


3

You can do this, if you have disks with the same type of partition tables, i.e. with the same type addressing mode in BIOS (CHS/LBA/LBA32/GPT). If you are not sure about it, I can recommend you to divide new disk to the partitions with the same size as on the old disk and copy via dd only partitions, not whole disk. Then you can use last part of disk as LVM ...


2

You asked how to do it with dd, but I had better success piping the output of dump into restore. Given the source ad1s1a and the target ad2s1a: $ mount /dev/ad2s1a /target $ cd /target $ dump -0Lauf - /dev/ad1s1a | restore -rf - I tried this on FreeBSD, actually I found it on the FreeBSD Forum


2

sfdisk -d dumps the partition table but not the rest of the boot sector, so if there was a bootloader on the disk it won't be restored. You can save the boot sector with head -c 512 </dev/sdb >bootsector.img.


2

To simply copy the partition, you can use dd if=/dev/srcDrive of=/dev/dstDrive or something like this. I would recomend you to read its man page. Sorry I can't give much more info, since I'm at work right now..


2

While you can use dd to copy a disk like that, doing so has a number of drawbacks: The destination must be exactly the same size or larger than the source After copying, you will need to resize the partitions to use any additional space You will waste time copying free space Any fragmentation present in the old disk is preserved Using an imaging program ...



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