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?
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?
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.)
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 05 '11 at 13:11
/etc/
and/home
maybe/var
if you need it – xenoterracide Mar 17 '11 at 01:16