1 |
On Sat, Jan 16, 2010 at 03:21:32PM +0200, Nikos Chantziaras wrote: |
2 |
> On 01/15/2010 07:33 PM, Jarry wrote: |
3 |
>> Hi, I'm facing this problem: |
4 |
>> |
5 |
>> I want to exchange hard-drive in my computer for other, bigger |
6 |
>> one. I do not want to add new hard-drive somewhere on mount-point |
7 |
>> permanently, I just want to copy everything from the old drive |
8 |
>> to the new one and then get rid of the old one. And of course, |
9 |
>> I'd like to use my computer as before. What is the best (maybe |
10 |
>> I should ask for safest) way to acomplish this? |
11 |
>> |
12 |
>> First I thought about "cp -a". But I'm not sure which directories |
13 |
>> I should skip (/proc, maybe some other like /dev?). And I do not |
14 |
>> know how cp handles links (if I first copy link and later target, |
15 |
>> where is the link pointing? to the original file or its copy?). |
16 |
>> |
17 |
>> Maybe dump/restore is better solution? Or something else? |
18 |
> |
19 |
> I'll just copy the instructions I have someone else here: |
20 |
> |
21 |
> You can clone the existing Gentoo installation into the new partition |
22 |
> and boot from it. You can do this while the system is actually running. |
23 |
> The new partition can be anything you want (different size, different |
24 |
> file system). This usually means: |
25 |
> |
26 |
> |
27 |
> rsync your existing / to your target / (except /dev, /sys and /proc and |
28 |
> of course mount points that belong to a different filesystem, /boot or |
29 |
> /home for example if you're using dedicated partitions for those). If |
30 |
> you mounted your target / as /root/newpart, this is done with: |
31 |
> |
32 |
> rsync -ax / /root/newpart |
33 |
> |
34 |
> If this copied directories it shouldn't have (like /sys or /proc), |
35 |
> simply delete them again. |
36 |
> |
37 |
> Then: |
38 |
> |
39 |
> mkdir /root/newpart/dev |
40 |
> mkdir /root/newpart/proc |
41 |
> mkdir /root/newpart/sys |
42 |
> mknod /root/newpart/dev/console c 5 1 |
43 |
> mknod /root/newpart/null c 1 3 |
44 |
> touch /root/newpart/dev/.keep |
45 |
> touch /root/newpart/proc/.keep |
46 |
> touch /root/newpart/sys/.keep |
47 |
|
48 |
|
49 |
If you are doing it this way (on a running system with mounted |
50 |
dev/proc/sys...), you can just bind-mount your current / to another |
51 |
directory. That "copy" will not contain any "sub-mounts" (as if you |
52 |
accessed it from a livecd), so you could just do |
53 |
|
54 |
(mount your /mnt/new_root) |
55 |
mkdir /mnt/current_root |
56 |
mount -o bind / /mnt/current_root |
57 |
rsync -aHAX /mnt/current_root/ /mnt/new_root/ |
58 |
|
59 |
i always remout / readonly first, for that you usually have to go to |
60 |
single user, or stop most of the services and programs... |
61 |
|
62 |
yoyo |
63 |
|
64 |
|
65 |
> |
66 |
> Now chroot into it to set up the boot loader (I assume you use Grub): |
67 |
> |
68 |
> mount -t proc none /root/newpart/proc |
69 |
> mount -o bind /dev /root/newpart/dev |
70 |
> chroot /root/newpart /bin/bash |
71 |
> |
72 |
> Now edit /etc/fstab to use the new partition and edit |
73 |
> /boot/grub/grub.conf and reinstall grub: |
74 |
> |
75 |
> |
76 |
> grub |
77 |
> root (hd0,0) <-- sustitute with what you really have/want |
78 |
> setup |
79 |
> quit |
80 |
> |
81 |
> You're ready. Leave the chroot and unmount: |
82 |
> |
83 |
> exit |
84 |
> umount /root/newpart/dev |
85 |
> umount /root/newpart/proc |
86 |
> |
87 |
> If you've set up grub correctly while in the chroot, you can now reboot |
88 |
> and the system should come up using the new partition. If you used a |
89 |
> different filesystem for the new partition (for example going from ext3 |
90 |
> to ext4), make sure your kernel supports the new filesystem. |
91 |
> |
92 |
> |