Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How I Moved Gentoo to A Large Hard Drive on the Same Machine
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
carney1979
Tux's lil' helper
Tux's lil' helper


Joined: 01 Mar 2004
Posts: 145
Location: Maine

PostPosted: Sun Mar 07, 2004 11:56 pm    Post subject: How I Moved Gentoo to A Large Hard Drive on the Same Machine Reply with quote

Here's how I moved a Gentoo install from a small 20 gig hard drive (/dev/hdb) to a larger 80 gig hard drive (/dev/hda). I performed all steps as root.

1. Partition the target hard drive. I used good old fdisk. In my case, I setup three partitions. /dev/hda1 is my boot partition. I made it 100 megs. /dev/hda2 is my swap. I made it 512 megs. /dev/had3 is my new root partition. I filled the rest of the drive. They should all be primary partitions and /dev/hda1 (boot) should be bootable.

2. I formatted /dev/hda1 and /dev/hda3 with mkreiserfs. Use your file system of choice, but make sure it's "hard compiled" into the kernel (not as a module). This is especially important with your boot partition.

3. I mounted my current boot partition (/dev/hdb1) to /boot. I mounted my new boot partition (/dev/hda1) temporaily to /mnt/floppy. I used mc (Midnight Commander) to copy the CONTENTS of my current /boot partition to the new boot partition mounted at /mnt/floppy. Make sure you copy the CONTENTS and not the /boot folder or your new system won't boot later! I then unmounted my new boot partition (/dev/hda1) mounted at /mnt/floppy.

4. I then mounted /dev/hda3 (new root partition) to /mnt/cdrom. Then, using Midnight Commander (mc), I copied my folders over to the new drive mounted at /mnt/cdrom. I DID NOT copy over the following folders: /boot /proc /mnt /tmp. I used Midnight Commander to manually create these folders. I also manually created the mount points in the /mnt/folder. Keep in mind that some folders, especially your /usr folder will take some time to copy over. Also, change the permissions on the new /tmp folder to read/write/execute enabled for all.

5. I then typed:

mount -o bind /proc /mnt/cdrom/proc

This mounts /proc on the new drive.

6. I then chrooted over to the new drive:

chroot /mnt/cdrom /bin/bash
env-update
source /etc/profile

7. I changed the drives from /dev/hdb1 & 3 to /dev/hda1 & 3 in /etc/fstab. I then mounted /dev/hda1 to /boot (new drive). Seeing as how I'm chrooted into the new drive, I did this like:

mount /dev/hda1 /boot

I edited my /boot/grub/grub.conf to add a new operating system. It is exactly the same as the old entry, except the drives have to changed to /dev/hda1 & 3 to reflect the new operating system. Adding an entry for the copied-over system and leaving the original entry is a good idea, in case you need to boot into the old system to fix a mistake you made setting up th new system.

8. ALMOST DONE!! All that's left is to setup grub. Do it like this:

grub
root (hd0,0)
setup (hd0)
exit

9. Type exit at the command prompt. This will end the chroot enviroment and put you back in the old system. Then reboot your system and you can enjoy your new drive!
Back to top
View user's profile Send private message
froke
Apprentice
Apprentice


Joined: 16 Dec 2003
Posts: 174
Location: Westside USA

PostPosted: Mon Mar 08, 2004 12:31 am    Post subject: Reply with quote

What about non-root users? Especially their home directories? Since you wrote them to the new drive as root, wouldn't their owner change to root? Or does mc preserve file owners/modes?
_________________
Top notch image hosting. Great for screen shots! http://www.imagelink.org
Back to top
View user's profile Send private message
carney1979
Tux's lil' helper
Tux's lil' helper


Joined: 01 Mar 2004
Posts: 145
Location: Maine

PostPosted: Mon Mar 08, 2004 12:59 am    Post subject: Ownership Reply with quote

In my situation, permissions stayed the same. My home folder still belongs to 'david' in the' users' group.

/tmp won't copy over, so when you create it on the new drive, you have to be sure it has the permissions of the original /tmp. I discovered this when KDE wouldn't boot. :wink:

David
Back to top
View user's profile Send private message
skyfolly
Apprentice
Apprentice


Joined: 16 Jul 2003
Posts: 245
Location: Dongguan & Hong Kong, PRC

PostPosted: Wed Mar 17, 2004 9:33 am    Post subject: Reply with quote

sounds useful, thanks a lot.

same applies to new versions of gentoo?
_________________
I am the only being whose doom
No tongue would ask no eye would mourn
I never caused a thought of gloom
A smile of joy since I was born.
emily bronte
Back to top
View user's profile Send private message
carney1979
Tux's lil' helper
Tux's lil' helper


Joined: 01 Mar 2004
Posts: 145
Location: Maine

PostPosted: Wed Mar 17, 2004 7:13 pm    Post subject: Probably.... Reply with quote

Quote:
same applies to new versions of gentoo?


Probably. Don't see why not. But your mileage may vary...... :wink:

David 8O
Back to top
View user's profile Send private message
hetman
n00b
n00b


Joined: 05 May 2003
Posts: 29
Location: Canada

PostPosted: Wed Mar 17, 2004 10:01 pm    Post subject: Reply with quote

re: permissions,
if you just use cp (copy) u can throw in a -p switch to keep the permissions.
i usually just do:
cp -pr /oldhome /newhome

but using mc might be easier for some.
Back to top
View user's profile Send private message
hpux
n00b
n00b


Joined: 24 Nov 2003
Posts: 14
Location: Oregon State University

PostPosted: Thu Mar 25, 2004 7:18 am    Post subject: Reply with quote

Another thing that I ran into is that if you are using a 2.6 kernel you shouldn't copy the /sys dir.
Back to top
View user's profile Send private message
hetman
n00b
n00b


Joined: 05 May 2003
Posts: 29
Location: Canada

PostPosted: Thu Mar 25, 2004 7:20 am    Post subject: Reply with quote

is there a big advantage to using 2.6 over 2.4? assuming you dont need it for any hardware reasons?
i know the question is kinda out of place, just wondering tho.
Back to top
View user's profile Send private message
hpux
n00b
n00b


Joined: 24 Nov 2003
Posts: 14
Location: Oregon State University

PostPosted: Thu Mar 25, 2004 5:08 pm    Post subject: Reply with quote

there are alot of things that I really like about 2.6

the lm-sensors project's work is getting merged-in (all the i2c sensor stuff)
kernel drm is better
the compile process kicks ass... the first time you compile it takes a long time,
but after that the compiles are very fast, and they dont print the whole gcc command-line
but a summary of it :

Code:
 [CC] whatever.c


so it's easier to see what is going on...

oh, the acpi support is better
and there are more target types (processors)
and the kernel alsa is awesome :)

Yah, I think it's worth it, but there is less support on the 'net for it because fewer people use them.....

oh, yah, and the /sys directory is 100% cool :)
for example, when I get my cpu frequency scaling working all I have to do is

Code:
echo performance > governor

(or something like that :) to change the way scaler works...)


I hope that answers some questions.. :)

I like it...
Back to top
View user's profile Send private message
HardenCoonor
n00b
n00b


Joined: 19 Feb 2004
Posts: 54

PostPosted: Fri Mar 26, 2004 1:54 pm    Post subject: Reply with quote

Yes, the 2.6 kernel series is very good.

I also have something to say about the original topic.

I recently migrated my gentoo from a 40 to an 80GB harddisk, also using mc.

There are of course some problems, which were already mentioned. I use a 2.6 kernel with udev(without tarball).

Some directories need special treatment:
/tmp
/proc
/dev
/sys

These cannot be copied that easily, but have to be created. Of course watch permissions.

Another way how to move all data is using dd.

Here is how i did it:

I wanted to move a Mandrake 10 install from on partition to another, not existing partition(same disk, but can also be another disk).

I used a knoppix-cd(3.4 with kernel 2.6).

1. make a backup of important data(of course)

2. reboot the pc with the knoppix-cd (use knoppix 2.6 for systems with kernel 2.6, to be able to chroot)

3. created the new partition with the same size as the original(resize later), reboot with knoppix again(no need to make an fs, you just need the partition)

4. lets assume the original partition is /dev/hda4, and the target partition is /dev/hdb1, in a root shell type:
dd if=/dev/hda4 of=/dev/hdb1 bs=64k conv=notrunc
this might last some time, depends on the size of the partition

5. repeat the steps 3 and 4 for /boot(maybe swap) and other partitions you want to transfer from one disk to another

6. power down the pc and remove the older harddisk and make the new one the master

7. start your pc and boot with the knoppix cd

8. mount /dev/hda1 and chroot into it, install the bootloader just as you did when installing gentoo

9. Verify that the new partitions work(reboot, open files) before wiping your old harddisk

The same can be done with a partition with a redmond linux distribution installed, one does not have to bother with reinstalling when just moving to another harddisk.

For more information, please look at the man pages of dd, chroot, fdisk and others.

I found the root encryption thread in these forums very inspiring.[/b]
Back to top
View user's profile Send private message
niknik
n00b
n00b


Joined: 01 Mar 2004
Posts: 42

PostPosted: Sat Mar 27, 2004 3:12 pm    Post subject: copy over -> kde problem Reply with quote

I copied my gentoo to a larger partition by simply issueing

cp -a /mnt/hda8/* /mnt/hda6/

under Knoppix and of course adjusting Grub / fstab.
Everything works nicely, only under KDE I find a new device icon (unmounted HDD) on my Desktop,
that belongs to no actual device.
I can not delete it (unless by instructing KDE not to show unmounted HDDs).
Trying to mount it KDE tells me it points to my root partition which is naturally already mounted.

Any ideas?
Back to top
View user's profile Send private message
carney1979
Tux's lil' helper
Tux's lil' helper


Joined: 01 Mar 2004
Posts: 145
Location: Maine

PostPosted: Sat Mar 27, 2004 3:17 pm    Post subject: Try This?? Reply with quote

Back up you kde desktop folder, then try going in and manually deleting it from a tty.

David
Back to top
View user's profile Send private message
niknik
n00b
n00b


Joined: 01 Mar 2004
Posts: 42

PostPosted: Sun Mar 28, 2004 10:15 pm    Post subject: copy over -> kde problem still persists Reply with quote

Thanks for the hint, however, the device icons do not show up as files in the
/home/user/Desktop directory
Is there another place where this stuff might be saved?

I have actually grepped my entire /usr and /etc for
"Hard Disc []"
(this is the title of the offending icon).

Found nothing.
So I guess it is either some underlying configuration problem or a binary file someplace.
Of course if somethings hiding in /var maybe ?!
Have not grepped that yet as it is awfully large.

help would be great !
thanks :-)
Nik
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Mon Mar 29, 2004 11:55 am    Post subject: Reply with quote

First off, thank you very much for that guide David, I've been looking for something similar for a while. Now to my question:

I have a running Gentoo system on /dev/hda and I want to move it to a bigger harddrive. So what do I need to do? This is how I would do it, and please correct me if I'm wrong.

Hook up the bigger harddrive as the primary slave, which would make it /dev/hdb. Is that correct so far?

Then I would follow your guide and copy all the files to /dev/hdb. Now here comes my problem:

I want to unhook the smaller harddrive (/dev/hda) and only want to use my bigger harddrive (/dev/hdb). But how would this work? Since I have everything mounted using /dev/hdb I can't just unhook the harddrive and use it as my primary drive. Can I? I would be very glad if someone could clarify this.
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
carney1979
Tux's lil' helper
Tux's lil' helper


Joined: 01 Mar 2004
Posts: 145
Location: Maine

PostPosted: Mon Mar 29, 2004 2:03 pm    Post subject: Reply with quote

This is a different situation than the simpler one I outlined.

Several things would need changing. You would need to change /etc/fstab, /boot/grub/grub.conf (or the appropriate lilo config file), etc, etc, at the very least. I'm sure there is more.... Grub/lilo would need to be installed on your "new" hda drive.

Though this looks similar to what I did, there are several differences that are very important and need to be rectified to have a working Gentoo system.

Perhaps someone else has done this kind of change and could enlighten you (us) as to the right steps to be taken and in what order.

Sorry I couldn't help more.

David 8O
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Mon Mar 29, 2004 7:03 pm    Post subject: Reply with quote

Well it shouldn't be that much different. I am basically doing the same thing you did except that I want to take out the old harddrive and only use the new one. Or did I miss something?
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
carney1979
Tux's lil' helper
Tux's lil' helper


Joined: 01 Mar 2004
Posts: 145
Location: Maine

PostPosted: Mon Mar 29, 2004 9:23 pm    Post subject: Reply with quote

Well, maybe. How many different places will you have to change /dev/hdb to /dev/hda, plus all varients, such as for grub (hd1 to hd0; hd1,0 to hd0,0), etc??

David 8O
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Mon Mar 29, 2004 9:34 pm    Post subject: Reply with quote

I just conjured up a plan. I will unplug my current drive /dev/hda and set it as the primary slave. Then I will hook up my new drive as the primary master. Here comes the part I'm unsure about: I'll use the Gentoo CD to boot my sytem and get a prompt going. My old harddrive (formerly /dev/hda) should now be /dev/hdb because it's the primary slave. The new harddrive should automatically be /dev/hda because it is hooked up as the primary master. From here I should be able to follow your guide and it should work out. Anyone see any problems with my logic? :?: Or any better ways of doing this? :?:
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
niknik
n00b
n00b


Joined: 01 Mar 2004
Posts: 42

PostPosted: Tue Mar 30, 2004 9:12 am    Post subject: Reply with quote

why not just boot using a knoppix cd and copy everything over using

Code:
 cp -a /dev/hd??/* /dev/hd??/


it works ... only trouble I had with this is the superfluous device icon in KDE mentioned above.
If anybody has an idea how to get rid of that, would be great.

Of course, do not forget to edit fstab and grub.conf ...
Back to top
View user's profile Send private message
RikBlankestijn
Guru
Guru


Joined: 01 May 2003
Posts: 315
Location: Arnhem the Netherlands

PostPosted: Fri Oct 01, 2004 8:50 pm    Post subject: Reply with quote

How did you handle you the /dev directory?
Back to top
View user's profile Send private message
veal
n00b
n00b


Joined: 08 May 2003
Posts: 47

PostPosted: Tue Oct 05, 2004 6:18 pm    Post subject: Reply with quote

i am stuck with the /dev directory too.

first i just copied over from the old location, chroot'ed in, but then i got 'permission denied' whenever I tried to access something in (the new) /dev. the env-update gave some /dev/null permission denied errors and so on. (but all the relevant stuff had chmod 777 and owner was root:root)

so i thought the system should create it itself and removed the contents of the (new) /dev dir but it created only /dev/null itself and the other stuff isn't there :o

would be nice if someone could shed some light in there as i already had this problem few months ago when i gave it a try. maybe i need to compile something into my kernel? (what's this udev stuff? ;) )
Back to top
View user's profile Send private message
flybynite
l33t
l33t


Joined: 06 Dec 2002
Posts: 620

PostPosted: Wed Oct 06, 2004 4:33 am    Post subject: Reply with quote

Just like to add one thing....

This really is a common operation. The really neat thing I don't see very often is how NOT to make it harder than it should be!

problem:

1. Some dir's are special and can't be copied.

The solution:

1. Some dir's are special only when part of a LIVE filesystem!!!! NO dir is special when a kernel isn't running on it!!! This means If you boot from a floppy or cdrom then all directories on the HARD DISK can be copied including /proc /boot etc!!!

There are situations when you might have to copy a live file system as this howto suggests, but don't do it if you don't have to. You will just make it harder on yourself!!
Back to top
View user's profile Send private message
veal
n00b
n00b


Joined: 08 May 2003
Posts: 47

PostPosted: Wed Oct 06, 2004 11:45 am    Post subject: Reply with quote

good point flybynite :) i booted now from the livecd and copied everything from old to the new one and did the config stuff (grub/fstab), rebooted and it worked flawlessly :D
Back to top
View user's profile Send private message
alind
Retired Dev
Retired Dev


Joined: 13 Jan 2004
Posts: 4
Location: Bucharest, Romania

PostPosted: Tue Oct 12, 2004 5:19 am    Post subject: Reply with quote

to be able to copy all the contents of the root partition without having to care about the virtual filesystems (/proc /sys etc.) you can mount the root partition into another mountpoint:
Code:
mkdir /mnt/rootpart
mount /dev/hdXY /mnt/rootpart

This way, you won't have to think twice about copying over the virtual filesystems contents (which you must not).
Back to top
View user's profile Send private message
cylgalad
Veteran
Veteran


Joined: 18 Apr 2003
Posts: 1327
Location: France

PostPosted: Tue Oct 12, 2004 9:32 am    Post subject: Reply with quote

Use cp -a to copy the files from one disk to the other.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum