Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I heard the dd command can make an image of an entire harddisk. What is the procedure ? I 'd like to make an image of my entire harddrive (hda) to a second slave IDE (hdb). Is the process similar to tool like ghost where you have to boot from a boot disk? I know about partimage but I'd rather try dd.
dd is the ultimate power tool. It will copy **anything** to **anything**, and will also quite happily destroy your entire system.....Proceed with caution
This copies the first 100 blocks (blocksize 512) from partition 1 of hda to a new file called "backupfile" (Better, I think, to use a full pathname---eg: /home/user/backupfile)
Instead of "of", you can also pipe, eg:
dd if=/dev/hda1 bs=512 count=100 | backupfile
OR,
dd if=/dev/hda1 bs=512 count=100 |hexdump -C| more (to read the data on the fly)
Beyond this example, I suggest you read man dd and run some tests** to be sure you understand how it works.
Just make sure your "target" hdb is bigger than the "source" hda. Best is identical size.
I use bs=32768 which is 64 sector x 512 bytes per Sector. This is about the optimum. Not specifying bs will make dd to default to 512 bytes in each transfer and slows it down.
I often have cloned 300Gb disk with about 60 partitions (mix of Dos, Windows and Linux inside) by
Code:
dd if=/dev/hda of=/dev/hdb bs=32768
If you clone the whole disk it will boot as the original. It is impossible to make dd not producing a 100% mirror image because no filing system is involved and the disk binary patterns are faithfully duplicated.
Should try to clone XP with dd sometime and appreciate how ignorant PC users are being milked by big corporations for doing simple backups.
Remember dd copies only the binary patterns of the hard disk and so an operating system totally foreign to Linux will still be replicated. Kind of magic, isn't it?
Exactly! It is only one line of command and dd has been in existence as long as PC.
Nowaday dd is available in every Linux Live CD, so a Windows user can backup his/her XP without Linux being installed or have any knowledge to run Linux!
In my signature I described dd could work faster and able to cope with more difficult cases than the commercial software.
I used Ghost exclusively before coming into Linux and now I have not had a need to use Ghost again except for bench mark dd's performance.
People who use Ghost should know the cloning is also done by copying the binary pattern sector by sector using a DOS program. Ghost is quite respectable in its abity and speed because one can also use hard disk manufacturer's softeware to clone disks at possibly 1/3 to 1/10 the speed and still be unsuccessful in the end. In Linux dd is just a tiny part of the weaponry available.
Thanks a lot pixellany and saikee for your help.
Two more questions:
- Can I do the cloning from the harddrive that I want to backup (hda). I mean if I execute the command dd if=/dev/hda of=/dev/hdb bs=32768 from the Linux OS (hda) I want to clone?
From my exeperience the answer is yes because dd is reading from a "raw" device.
Since submiiting a long train of data in a once-through operation the cache memory is not going to be effectively and so it is not a bad idea to use a Live CD to do the job. I find over 50Mb/s transfer rate possible and therefore running from a hard disk gains very little.
There is definitely no need to format and I don't even partition the target disk. In cloning the whole disk the MBR, boot sector, partition table, filing indices are all data are "mirrored" 100%.
You never need to format in dd but if you only clone one partition then you need to ensure the target partition "identical" in size to the source partition.
If the boot loader is not required and you are only interested in the files then Linux has better back up commands like tar, cpio and rsync to name a few. Those are the ones you can play tones with.
Thanks a lot pixellany and saikee for your help.
Two more questions:
- Can I do the cloning from the harddrive that I want to backup (hda). I mean if I execute the command dd if=/dev/hda of=/dev/hdb bs=32768 from the Linux OS (hda) I want to clone?
- Do I have to format the hdb in ext3 ?
cheers
**I think** the only thing that can happen in copying from the same disk from which you are running the command...IS: Whenever the OS is running (and any apps), certain files--eg logfiles are being updated on the fly---sometimes in background. What this means is that the clone may not be perfect.
The above is normally of no consequence--eg if you just want critical files backed up.
And of course, that 80Gig is a marketing number - 156250000 512-byte records gets you somewhere around 74.5Gig.
I would guess that's not always the same, although you would expect to get the same number of cylinders from the one manufacturer.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.