Correction noted
Quote:
I have made the correction |
You need partitions first
Quote:
dd if=/dev/hda1 of=/dev/usbpartition bs=4096 conv=notrunc,noerror dd if=/dev/hda5 of=/dev/usbpartition bs=4096 conv=notrunc,noerror I know you can do it. I have faith in you. |
Partitions
Quote:
dd if=/dev/hda1 of=/dev/usbpartition bs=4096 conv=notrunc,noerror dd if=/dev/hda5 of=/dev/usbpartition bs=4096 conv=notrunc,noerror |
Would it be possible to copy a directory tree to an image file and vice versa?
|
Quote:
|
DD Hard Drive to a File
I have read through this article. Very in-depth and I appreciate what you have done to explain DD. I might be asking something that you give in your example, so I will apologize in advance, if not, here is my question.
I would like to copy either the entire hard drive or each partition to a single file for which I could restore back to another hard drive later. Kind of like copy one drive to another (making a duplicate), but I don't want to do that. I want to make a copy of a hard drive to a file, store the file some where and then be able to restore that file to another hard drive. End result would be an exact copy of the first drive. The reason I don't want to do a disk to disk copy is, that the new hard drive might be the same size or larger and I do this later. Scenario # 1 PC has 2 hard drives. 1. I would like to DD the entire Hard Drive to a single file on the 2nd hard drive A. What would that command look like if I can do it. However, if possible, can I only copy actual data or will it copy sector by sector. In other words if /dev/sda is 20 Gigs, my file will be 20 Gigs. Let's say there was only 7 Gigsof data on drive, can my file be just 7 Gigs? Scenario # 2 PC has 1 hard drive and a DVD Burner 1. Hard drive is 20 Gigs. I have 4 gigs of Data that I would like to copy to a single file and burn it to a DVD. A. What would the command look like to do that if possible. |
You could better use tar (standard Linux) or star (enhanced tar, freely downloadable from the Internet) for this purpose. It does exactly what you want, preserves everything from the files, compresses if you want, and when unpacking you re-create the entire tree structure.
The advantage is that is does not matter on which disk or which partition you do this, even if your partition scheme is greatly different. Since your partitions are different, you'd have to partition your disk anyway. (I know it works, I cloned several machines like this) The only problem might be your boot sector. You recreate that most easily by running grub-install from a live CD after you copied all the files. jlinkels |
would you mind posting the steps to do this? I know it's not the topic of this thread but....
|
Quote:
|
Quote:
man star jlinkels |
I've got a question and I read through thr first page of this thread but I was wonddering if you knew of a way to do the thing I am trying to do. First this is my system setup:
1 DVD Burner 1 80 GB Hard Drive - used for my iso files and backups 1 30 GB Hard Drive - Used for my linux system 1 Swappable hard drive What I would like to do is we have a lot of servers for our hosting service and we would like to copy the hard drives that are in each type of machine onto a DVD disc and a hard drive so in case we have a problem with a machine we can either copy the extra hard drive for that machine to a new one and put in the machine and get it working or have a copy on a dvd and jsut copy the dvd to a new hard drive. The only way I can do it right now is I use dd to copy the hard drive from our server in my swappable hard drive bay over my 80 GB hard drive and then I can pull it out and put in the new one and copy over the data back. I have noticed you can use dd to make iso's but I don't know if the dvd will have all the partitions like the hard drive. I also noticed if the hard drive being copied is bigger than the source you need to skip the first part of the drive. Can you help me know which commands I would need to use to do the following? 1. Copy a hard drive to a directory on my computer as a ISO. I think this one will do it: dd if=/dev/hda of=/data/beta.iso bs=2048 conv=notrunc 2. Take an iso and copy it onto the hard drive to make it look like the previous hard drive. 3. Also be able to use the same ISO and burn a DVD. Thanks for your help and if you have any suggestions on how I could do it differently I am open to suggestions. Thanks Blake |
I just read this last page and it looks like other have suggested to use tar, could I use the if=/path/my.iso ? If so that would help a lot.
p.s. sorry about posting and not reading this last page, you have a great FAQ on this command Thanks Blake |
.iso files and dd
Quote:
DD is a bitstream duplicator. It reads/writes bit for bit. The copy is an exact bitstream duplicate of the original. Therefore, whatever file system is used for the original will be used for the copy. In other words, naming a file with an iso extension does not cause dd to write an iso9660 filesystem if the source file system is not iso9660. You can, however, write other file systems to a DVD with mkisofs and growisofs. There are linux programs available to back up to DVD, if you don't want to learn the other two commands. The fact that dd won't write to optical media is an endless pain, but that is the way it has to be. |
I would like to add something about the "you copy a file system" statement.
Recently I copied a disk to another one with a bigger size. I used to use tar for this, but I did it with dd this time. The new disk booted & worked fine, but when I issued a "df" command, all my partition sizes were reported wrong. Indeed, "df" reported all partition sizes like they were on the old, smaller disk. This obviously happened because I copied the entire FILE SYSTEM, not the data. At the end of the day I tar-ed all the partitions, put the tar files on a different partition. Reformatted the partitions and un-tar-ed everything again, and all was fine. IMHO this demonstrates clearly that if you want to CLONE a disk, you should use "dd". But if you want to copy a [disk | partition] to something with a different size, you should use "tar". jlinkels |
You could copy it (with dd) and use a resizing tool to make the filesystem occupy the full space of the new partition.
|
All times are GMT -5. The time now is 11:17 PM. |