0

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?

2 Answers2

3

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.

Tom Shaw
  • 3,752
  • 16
  • 23
  • 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 05 '11 at 09: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 05 '11 at 09: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 05 '11 at 09:32
  • See [this site](http://linuxdevcenter.com/pub/a/linux/lpt/18_16.html) for an example of copying a directory tree with `tar`. – Tom Shaw Jun 05 '11 at 09:38
  • that makes no sense that cloning the partition with the bootloader using dd, would clone everythingexcept the bootloader O_o – Joshua Robison Jun 05 '11 at 09:41
  • Suggest you look up the difference between MBR and VBR. – Tom Shaw Jun 05 '11 at 09:59
  • Indeed, there may be two bootloaders that you need to bring up your OS. The one in the MBR hands off to the one in your system's boot partition. This is why MBR grub can boot linux, windows, or almost anything else without having to have boot loaders for each OS. That's another reason why dd can't do what you want here. – adric Jun 05 '11 at 12:22
0

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.

adric
  • 531
  • 2
  • 7