Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to clone an 8.1gig bootable disk to an 8.0gig disk and have the clone remain bootable.

dd causes problems because the destination disk is a few mb smaller than the source.

Can "cat" help me here?

cp and rsync didn't work either for some reason.

And yes I am not copying the drive I'm booted into.
And yes I am running the commands as root.

So can someone show me how to use cat?

share|improve this question
add comment

2 Answers

Typically I'd just manually duplicate the partition layout on the target disk (as close as is this case) and then rsync all of the files over between disks or across a local network connection. And the you'll need to reload the bootloader using it's tools (grub-install, lilo, etc) because of the different partition tables.

If you were going from smaller to larger disks you could use dd and skip all of the rest of this, but to go from larger to smaller you have to be a bit more careful. Cat puts (concatenates) files (or things like files) together and dd duplicates disks.

You can use which ever fdisk you prefer from sfdisk and cfdisk up through qt-parted (so can use the mouse!). rsync arguments you want to use are definitely -a and probably -v and --progress to give some status as it goes. Mind your trailing slashes and use --dry-run in rsync until you are sure you have everything lined up right :)

If you need a bootable environment for this sort of work I can recommend sysrescd as it has all of this stuff available in a bootable cd image. There are plenty of others to choose from as well.

share|improve this answer
add comment

No, in this case cat will not give you anything that dd can't do better.

You could try using a tool such as GNU Parted to resize your source filesystem and partition to smaller than 8GB, use dd to clone it to a partition on the target disk, and then install a boot loader.

Alternatively, you could create a filesystem within the target disk, use a file-level command such as tar or cp -a to copy the data across, and then install a boot loader.

share|improve this answer
    
I still don't get why I would need to deal with bootloaders after using dd. Shouldn't all the bootloader info have copied over after using that? I was hoping that CAT would help me clone a drive without worrying about the size of the destination drive too much. –  Joshua Robison Jun 5 '11 at 9:20
    
Can you give me an example of how to use tar to copy the data across, including locked and invisible data? –  Joshua Robison Jun 5 '11 at 9:29
    
If you were cloning the whole disk, you wouldn't need to deal with bootloaders. However, the target disk is too small to just clone the whole disk. If you clone just the one partition, you need to install a bootloader because the MBR is not cloned. Same if you copy the filesystem contents. There's nothing magical about cat - it basically does the same thing as dd. –  Tom Shaw Jun 5 '11 at 9:32
    
See this site for an example of copying a directory tree with tar. –  Tom Shaw Jun 5 '11 at 9:38
    
that makes no sense that cloning the partition with the bootloader using dd, would clone everythingexcept the bootloader O_o –  Joshua Robison Jun 5 '11 at 9:41
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.