I would like to copy/clone/move my CentOS (which is on a 20GB hard drive) to a smaller hard drive (5GB)...

Can someone tell me how to do this?

  • Does your current system occupy more than 5GB of actual used space? – mattdm Mar 16 '11 at 13:26
  • @mattdm: nope... less than 4GB – Wolfy Mar 16 '11 at 13:27
  • imo, easiest way, install centos on new system... sync /etc/ and /home maybe /var if you need it – xenoterracide Mar 17 '11 at 1:16

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
mount /dev/sdb1 /mnt/destination
# Copy everything
cp -rp /mnt/source /mnt/destination

Don't reboot just yet, you have to install Grub on the destination drive, something like:

grub-setup -d /mnt/destination /dev/sdb

You can also use an intermediate drive if you can't connect the second drive to the same computer, but the steps are similar. Finally remember, don't use those commands as is, always check and double check that they apply to your system.

(In case someone has a slightly different requirement that doesn't include a smaller destination drive, Clonezilla is definitely a better choice.)

  • 1
    I'd like to mention that you have to make sure that you don't try cloning virtual filesystems... – xenoterracide Mar 17 '11 at 1:15
  • why doesn't grub copy over with the cp command. And you mentioned tarring but never explained how???? – Joshua Robison Jun 5 '11 at 8:32
  • @Joshua Parts of grub is stored in the MBR, which doesn't get copied with cp. tar is an archiver, like zip or rar. Basically you make an archive from the source drive, then extract it to the destination drive. Refer to man tar for how to use it, or ask in another question. – phunehehe Jun 5 '11 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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