Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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

1 Answer 1

up vote 3 down vote accepted

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.)

share|improve this answer
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

 
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.