On Sat, Jan 16, 2010 at 03:21:32PM +0200, Nikos Chantziaras wrote:
> On 01/15/2010 07:33 PM, Jarry wrote:
>> Hi, I'm facing this problem:
>>
>> I want to exchange hard-drive in my computer for other, bigger
>> one. I do not want to add new hard-drive somewhere on mount-point
>> permanently, I just want to copy everything from the old drive
>> to the new one and then get rid of the old one. And of course,
>> I'd like to use my computer as before. What is the best (maybe
>> I should ask for safest) way to acomplish this?
>>
>> First I thought about "cp -a". But I'm not sure which directories
>> I should skip (/proc, maybe some other like /dev?). And I do not
>> know how cp handles links (if I first copy link and later target,
>> where is the link pointing? to the original file or its copy?).
>>
>> Maybe dump/restore is better solution? Or something else?
>
> I'll just copy the instructions I have someone else here:
>
> You can clone the existing Gentoo installation into the new partition  
> and boot from it.  You can do this while the system is actually running.  
>  The new partition can be anything you want (different size, different  
> file system).  This usually means:
>
>
> rsync your existing / to your target / (except /dev, /sys and /proc and  
> of course mount points that belong to a different filesystem, /boot or  
> /home for example if you're using dedicated partitions for those).  If  
> you mounted your target / as /root/newpart, this is done with:
>
> rsync -ax / /root/newpart
>
> If this copied directories it shouldn't have (like /sys or /proc),  
> simply delete them again.
>
> Then:
>
> mkdir /root/newpart/dev
> mkdir /root/newpart/proc
> mkdir /root/newpart/sys
> mknod /root/newpart/dev/console c 5 1
> mknod /root/newpart/null c 1 3
> touch /root/newpart/dev/.keep
> touch /root/newpart/proc/.keep
> touch /root/newpart/sys/.keep


If you are doing it this way (on a running system with mounted
dev/proc/sys...), you can just bind-mount your current / to another
directory. That "copy" will not contain any "sub-mounts" (as if you
accessed it from a livecd), so you could just do

(mount your /mnt/new_root)
mkdir /mnt/current_root
mount -o bind / /mnt/current_root
rsync -aHAX /mnt/current_root/ /mnt/new_root/

i always remout / readonly first, for that you usually have to go to
single user, or stop most of the services and programs...

yoyo


>
> Now chroot into it to set up the boot loader (I assume you use Grub):
>
> mount -t proc none /root/newpart/proc
> mount -o bind /dev /root/newpart/dev
> chroot /root/newpart /bin/bash
>
> Now edit /etc/fstab to use the new partition and edit  
> /boot/grub/grub.conf and reinstall grub:
>
>
> grub
> root (hd0,0) <-- sustitute with what you really have/want
> setup
> quit
>
> You're ready. Leave the chroot and unmount:
>
> exit
> umount /root/newpart/dev
> umount /root/newpart/proc
>
> If you've set up grub correctly while in the chroot, you can now reboot
> and the system should come up using the new partition.  If you used a  
> different filesystem for the new partition (for example going from ext3  
> to ext4), make sure your kernel supports the new filesystem.
>
>

Reply via email to