Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[FAQ] Howto move the system on to a bigger harddrive ?
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
tragor
Apprentice
Apprentice


Joined: 21 May 2003
Posts: 168
Location: Freiburg i.Br., Germany

PostPosted: Thu Aug 07, 2003 11:48 am    Post subject: [FAQ] Howto move the system on to a bigger harddrive ? Reply with quote

Running out of disk space ? Your root partition has only some MBs free ? Can't find a spot to install that new app to ?

Method 1: (Source: This post from tecknojunky)
Using dd to duplicate the drive including partition table.

Note: This method has the disadvantage, that only the last partition can be resized and that requireing a tool to resize the file system on it. If you have to resize a partition other then the last one, use Method 2. The advantage is, that you do not have to reinstall your bootloader, since the MBR will be copied too.

These 5 easy and safe steps will transfer the data on the current hard drive onto a new bigger one. The last partition will hold the newly aquired free space.

I have drawn this from my own setup which is based upon the x86 installation howto from Gentoo. My hard drive was partitioned this way:


- /dev/hda1 : ext2 boot partition
- /dev/hda2 : swap partition
- /dev/hda3 : reiserfs root partition.


Also, I have a dvd-rom on /dev/hdb and the new disk was the primary drive on the second controler: /dev/hdc. Where is located the new disk is irrelevant. Just be sure you know that you are accessing the new drive and not another disk that hold crucial data!!!

These steps insure that your hda is untouched and will serve as a backup until you are sure the new drive is functional.

Prerequisites: make sure you have the tools for each of the file systems on the drive. Also, a partition program is essential (fdisk, cfdisk, ...).

1- Tranfer the data.

Code:
# dd if=/dev/hda of=/dev/hdc


This copies integraly the whole drive onto the new one, including the MBR and partition table. It can take a very long time depending on bus speed and drive size.

2- Fix the partition table.

Code:
# cfdisk /dev/hdc


You can use any disk partition program you wish.

You will see that on the new drive, you'll have the same partition table with additionnal free space trailing it.

Make the boot partitition bootable if it is not so.

Delete the last partition and recreate it using the whole free space. Write the partition table. This only changes the partition table, not the data in the partition.

3- Resize the filesystem on last partition.

Depending on the type of file system you had, use the proper tool to resize it. I had reiserfs:

Code:
# resize_reiserfs /dev/hdc3


4- Check file system integrity

Code:
# reiserfsck --fix-fixable /dev/hdc3
# e2fsck /dev/hdc1


5- Swap the drive and reboot.

Working? Congrat, you succefully duplicated your disk.

This is based on my setup. I'm guessing other setups may fail with this. If so, post your unsuccess here (with preferably a fix).


Method 2: (Source: This thread and own experience)
Formatting and repartitioning the new drive and copying all data with permissions - then reinstall the bootloader.

You will need a LiveCD and the usual fdisk and mk<yourfstype> stuff and cpio for this method.

1- Partitioning the new drive

Use fdisk or cfdisk (or any other program that does the job) to partition the new harddrive. I will assume that you will create the same number of partitions as on the old drive. But you can surely add more partitions as you like (and maybe even create fewer - would be a bit more complicated I guess)... Don't forget the swap partition !

2- Creating the filesystems

Use mkreiserfs or mke2fs or another tool to create your filesystems. (See this if you are unsure.)

3- Booting from the LiveCD and mounting the new drive

Boot up your favorite LiveCD and mount the empty partitions of the new drive. You should mount them as /mnt/hdb[X] according to the current drive/partition names to avoid confusion. Further on I will assume you have the old drive partitions mounted as /mnt/hda[X] and the new drive partitions as /mnt/hdb[X].
Don't forget, you need not to mount the swap...

5- Copying the files without loosing permissions

Now cd to /mnt/hda1 (your old system boot partition) and copy the files:
Code:

# cd /mnt/hda1
# find . -print | cpio -pamd /mnt/hdb1


Do that for alle of your old partitions.

6- Swap system-drive and reboot with LiveCD

Halt the system and replace the old system-drive with the new one. Don't forget to set the jumper right ! Then start up again with the LiveCD.

7- Reinstalling the bootloader

Once you have rebooted, mount your system drive as described in the installation guide. Then chroot into the system and run lilo (or grub):

Code:

# chroot /mnt/<where you mounted the system> /bin/bash
# lilo


8- Reboot the system

So that would be all. If all went the right way, your system should start now properly.

Note: I had a problem with the x-server immediately shutting down after startx without telling any error... But for all I know, that does not happen normally. But if it does, you can just reemerge xfree, that did the trick for me.

Thanks to the forum for all the great help!
tragor
Back to top
View user's profile Send private message
teknomage1
Veteran
Veteran


Joined: 05 Aug 2003
Posts: 1239
Location: Los Angeles, CA

PostPosted: Sun Aug 10, 2003 7:45 pm    Post subject: Reply with quote

what i did was load up a knoppix cd and mount the partions i needed as writeable. the I used cp -a /mnt/olddrive /mnt/newdrive. I chrooted to the new drive and updated the fstab and ran lilo. no problems
Back to top
View user's profile Send private message
fimblo
Guru
Guru


Joined: 19 Feb 2003
Posts: 306
Location: European Union, Stockholm

PostPosted: Fri Jan 09, 2004 11:32 am    Post subject: Reply with quote

I followed all the instructions in your howto, and also the grub part in the installation guide, and when I rebooted I got "Grub Error 17". The system won't boot.

anyone recognise this problem?

EDIT: I forgot to search the forum first. I found a few tips, Ill try them first :)
_________________
http://blahonga.yanson.org - little geekblog
http://blahona.yanson.org/howtos/livecd - yet another livecd howto
Back to top
View user's profile Send private message
fimblo
Guru
Guru


Joined: 19 Feb 2003
Posts: 306
Location: European Union, Stockholm

PostPosted: Fri Jan 09, 2004 11:37 am    Post subject: Reply with quote

K I searched and didnt find any help. Anyone got any tips?
_________________
http://blahonga.yanson.org - little geekblog
http://blahona.yanson.org/howtos/livecd - yet another livecd howto
Back to top
View user's profile Send private message
gonzalo
Tux's lil' helper
Tux's lil' helper


Joined: 05 Jan 2004
Posts: 104
Location: CL

PostPosted: Fri Jan 09, 2004 12:15 pm    Post subject: Reply with quote

teknomage1 wrote:
what i did was load up a knoppix cd and mount the partions i needed as writeable. the I used cp -a /mnt/olddrive /mnt/newdrive. I chrooted to the new drive and updated the fstab and ran lilo. no problems

Same here, mounting the new partitions and cp -a. Nothing else
Back to top
View user's profile Send private message
fimblo
Guru
Guru


Joined: 19 Feb 2003
Posts: 306
Location: European Union, Stockholm

PostPosted: Fri Jan 09, 2004 12:24 pm    Post subject: Reply with quote

gonzalo wrote:
Same here, mounting the new partitions and cp -a. Nothing else

hmm did you do a lilo/grub?
_________________
http://blahonga.yanson.org - little geekblog
http://blahona.yanson.org/howtos/livecd - yet another livecd howto
Back to top
View user's profile Send private message
gonzalo
Tux's lil' helper
Tux's lil' helper


Joined: 05 Jan 2004
Posts: 104
Location: CL

PostPosted: Fri Jan 09, 2004 12:29 pm    Post subject: Reply with quote

Sure, you modify your lilo ot grub with the new root and/or boot partitions.
Back to top
View user's profile Send private message
fimblo
Guru
Guru


Joined: 19 Feb 2003
Posts: 306
Location: European Union, Stockholm

PostPosted: Fri Jan 09, 2004 1:05 pm    Post subject: Reply with quote

exactly what I did (I use grub). and I got an Grub error 17 at boot. I looked at the list of grub errors, and it seems to be the error you get when the problem doesnt match any of the other error codes...

:(
_________________
http://blahonga.yanson.org - little geekblog
http://blahona.yanson.org/howtos/livecd - yet another livecd howto
Back to top
View user's profile Send private message
scr7b
n00b
n00b


Joined: 27 Oct 2003
Posts: 12
Location: Scotland

PostPosted: Mon Jan 12, 2004 6:45 am    Post subject: Reply with quote

teknomage1 wrote:
what i did was load up a knoppix cd and mount the partions i needed as writeable. the I used cp -a /mnt/olddrive /mnt/newdrive. I chrooted to the new drive and updated the fstab and ran lilo. no problems

Shouldn't you add "--preserve=all" to the cp command? Were all the original permissions preserved after the copy?
_________________
I am a dyslexic agnostic insomniac. I lie awake at night, wondering if there really is a dog.
Back to top
View user's profile Send private message
gonzalo
Tux's lil' helper
Tux's lil' helper


Joined: 05 Jan 2004
Posts: 104
Location: CL

PostPosted: Mon Jan 12, 2004 11:32 am    Post subject: Reply with quote

cp -a, Equivalent to -dpPR

-p Preserve the original files' owner, group, permissions, and timestamps

$man cp ;)
Back to top
View user's profile Send private message
RaaR
Tux's lil' helper
Tux's lil' helper


Joined: 24 Jul 2003
Posts: 125

PostPosted: Tue Jan 13, 2004 11:07 pm    Post subject: Reply with quote

fimblo wrote:
exactly what I did (I use grub). and I got an Grub error 17 at boot. I looked at the list of grub errors, and it seems to be the error you get when the problem doesnt match any of the other error codes...

:(


Did you reinstall grub or just edit grub.conf?

In case you did reinstall (which I think you should), are you sure you installed grub to the correct hd?
Back to top
View user's profile Send private message
fimblo
Guru
Guru


Joined: 19 Feb 2003
Posts: 306
Location: European Union, Stockholm

PostPosted: Thu Jan 15, 2004 8:52 am    Post subject: Reply with quote

I reinstalled grub, and I have only one drive :)

But I just got a hint from a Unix veteran (+15years) who has fiddled with pretty much every os which resembles unix- he told me to dd 512k of /dev/zero onto the first part of hda then reinstall grub.

gonna try this!
_________________
http://blahonga.yanson.org - little geekblog
http://blahona.yanson.org/howtos/livecd - yet another livecd howto
Back to top
View user's profile Send private message
fimblo
Guru
Guru


Joined: 19 Feb 2003
Posts: 306
Location: European Union, Stockholm

PostPosted: Mon Feb 02, 2004 11:42 am    Post subject: Reply with quote

oops 8O

don't dd the first 512 bytes onto the hd! I managed to remove the partition table as well... :( Afterwards, I looked into the specs and the last 64 bytes of the first 512 bytes of a hd contains the partition table.

I managed to rescue the partion table using gpart... and fixed my bios,, which was the original problem :P
_________________
http://blahonga.yanson.org - little geekblog
http://blahona.yanson.org/howtos/livecd - yet another livecd howto
Back to top
View user's profile Send private message
Becks
Tux's lil' helper
Tux's lil' helper


Joined: 06 Dec 2002
Posts: 90

PostPosted: Mon Feb 02, 2004 1:27 pm    Post subject: Reply with quote

And another method which can be used over network:
Asumed you have computer1 and want to move the content of a drive to computer2.

Computer1 is still alive and can be booted:

1) On computer1:
emerge nfs-utils
nano -w /etc/exports
add the drive you want to copy
/etc/init.d/nfs start

2) On computer2:
Start the LiveCD
run net-setup
/etc/init.d/nfs start
mkdir /mnt/import
mount -t nfs IP:/exporteddrive /mnt/import
mkdir /mnt/newdrive
mount /dev/XXX /mnt/newdrive

And then just cp -a /mnt/import /mnt/newdrive on computer2.

If computer 1 is broken - boot from a LiveCD, edit /etc/exports, start the network and start nfs. And then copy the drive like shown above.

Moving a system and making the new machine bootable:
create all needed partitions on the new machine (like shown in the installation manual) and copy the contents of computer1 to the correct drives on computer2 (including /boot) using the above mentioned method

Making the machine bootable:
Mount the drives on computer2 locally (like shown in the installation manual, f.e. /mnt/hda3 to /mnt/gentoo, /mnt/hda1 to /mnt/gentoo/boot, /proc to /mnt/gentoo/proc and so on), chroot into the so created new system (also described in the inst. manual) and run grub to install the bootloader on the new system. Then reboot.


Alex
Back to top
View user's profile Send private message
beacher
n00b
n00b


Joined: 11 Mar 2003
Posts: 30
Location: Atlanta

PostPosted: Tue Feb 03, 2004 10:00 pm    Post subject: Lilo gotcha Reply with quote

I just got through doing this in reverse (larger to smaller hard drive) and when i rebooted, I got the dreaded Lilo - Timestamp mismatch . I wish that I had read this before doing it because I found my mistake, and it's a real goofy one.... I did cp -Rp from / to the /new_hd and I didn't catch the fact that it had copied /proc. It took me a day of screwing around before I finally went into livecd, mounted hda1 and rm -rf /mnt/gentoo/proc . I made sure the new fstab had /proc in it and rebooted. That's how I got rid of it.

I felt like a dumba$$ but I couldn't find the solution on google, so I'm posting it here so someone can benefit from my mistakes....

Maybe the grub error is the same?
B
Back to top
View user's profile Send private message
befortin
Apprentice
Apprentice


Joined: 10 Feb 2004
Posts: 193

PostPosted: Thu Apr 29, 2004 5:26 pm    Post subject: Reply with quote

There's a great CD that can help to do this kind of job. Take a look at the "SystemRescueCD" (you should find it on Google).

- and it's based on Gentoo! -
Back to top
View user's profile Send private message
Nate_S
Guru
Guru


Joined: 18 Mar 2004
Posts: 414

PostPosted: Thu Apr 29, 2004 7:16 pm    Post subject: Reply with quote

fimblo: parted can recover a deleted partition table if you know approxamately where the starts and ends of the deleted partitions are.

I think the problem many of you are having with gurb/lilo is that if you set it up with the old disk still connected before the new one, eg /dev/hda was your old disk, and /dev/hdb is the disk your copying to, the numbers that grub (and presumably lilo does something similar,) would change as soon as you disconnect the first disk. I'd recommend that you try booting from the livecd and setting up your bootloader from there, once you pull out the old drive.

Also, dd_rescue deserves some mention, it's like dd, except optimized for recovering data from failing hard disks. And even if your drive is not failing, it's got some nice features like letting you see the progress with the -v flag. It's in portage, as well as on that system rescue cd that someone already mentioned.

-Nate
Back to top
View user's profile Send private message
eNTi
Veteran
Veteran


Joined: 20 Oct 2002
Posts: 1011
Location: Salzburg, Austria

PostPosted: Fri Apr 30, 2004 6:35 pm    Post subject: Reply with quote

is any of those methods working with sata?
_________________
If you fall off a cliff, you might as well try to fly. After all, you got nothing to lose.

-- John Sheridan - Babylon 5, Season 4
Back to top
View user's profile Send private message
befortin
Apprentice
Apprentice


Joined: 10 Feb 2004
Posts: 193

PostPosted: Fri Apr 30, 2004 9:15 pm    Post subject: Reply with quote

I think that the SystemRescueCD should work with SATA. Read the following :

http://www.sysresccd.org/kernel.en.php

Good luck!
Back to top
View user's profile Send private message
wskellenger
n00b
n00b


Joined: 01 Dec 2003
Posts: 52

PostPosted: Wed Oct 27, 2004 1:20 am    Post subject: Excellent Reply with quote

I went from a 7GB old clunker to a new 80GB drive in about 40 minutes, including popping the case open and putting it back together, using the method posted here.

A few things to note...

First -- My drive was configured exactly like the author's. I had ReiserFS as my last partition.

1. I got a little scared when using cfdisk and I didn't see the ReiserFS type listed when I created the new partition. I went with just "Linux" (type 83). When you use the ReiserFS tools in the next steps, it must convert the partition into that FS type. (?)

2. I used the following dd command as recommended in this post to "save time". As I've never done this before, I didn't know how much time a "long time" would be... But at any rate, with only 7GB it wasn't that long at all.

Code:
dd if=/dev/hda of=/dev/hdc bs=2048k


Thanks again for this helpful post.
Back to top
View user's profile Send private message
nsahoo
l33t
l33t


Joined: 17 Jul 2003
Posts: 618

PostPosted: Sat Oct 30, 2004 1:03 am    Post subject: Reply with quote

gonzalo wrote:
teknomage1 wrote:
what i did was load up a knoppix cd and mount the partions i needed as writeable. the I used cp -a /mnt/olddrive /mnt/newdrive. I chrooted to the new drive and updated the fstab and ran lilo. no problems

Same here, mounting the new partitions and cp -a. Nothing else


Ya, this is the most straight forward way I believe.
Back to top
View user's profile Send private message
KingPunk
Guru
Guru


Joined: 22 Jan 2004
Posts: 442
Location: Utica, New York, USA

PostPosted: Sat Oct 30, 2004 1:30 am    Post subject: Reply with quote

my best suggestion would be to just use partimage.
clone the entire drive, in real time, or backup to dvd and then move it to the
new drive.
its quite simple, and a very good program.
i've requested this program, to be on the 2005.1 offical gentoo livecd.
;)
_________________
When the FBI/CIA/NSA/FDA/and other three-letter government agencies come looking, you don't know me, you never saw me, never heard of me. get it? got it? good!
also: ALL YOUR POLLITICAL BASE ARE BELONG TO HILLARY IN '08!!
Back to top
View user's profile Send private message
Bob P
Advocate
Advocate


Joined: 20 Oct 2004
Posts: 3355
Location: Jackass! Development Labs

PostPosted: Mon Feb 14, 2005 7:00 am    Post subject: Reply with quote

teknomage1 wrote:
what i did was load up a knoppix cd and mount the partions i needed as writeable. the I used cp -a /mnt/olddrive /mnt/newdrive. I chrooted to the new drive and updated the fstab and ran lilo. no problems

i tried this using the Gentoo live CD 2004.3.

instead of using
Code:
cp -a /mnt/olddrive /mnt/newdrive

i used this:
Code:
cp -a /mnt/olddrive/* /mnt/newdrive

using the second method results in the contents of /olddrive being copied into the root directory of /newdrive, while the first method would put the contents of /olddrive in a folder named /olddrive on the /newdrive, like this: /newdrive/olddrive, with the contents of the original drive's root directory in a folder named /olddrive on the new system. essentially, if you use the first method you end up with the contents of the original drive being deposited as children into a parent directory named /olddrive instead of having them go into the target's root directory.
_________________
.
Stage 1/3 | Jackass! | Rockhopper! | Thanks | Google Sucks
Back to top
View user's profile Send private message
Lar
n00b
n00b


Joined: 27 Jan 2005
Posts: 3
Location: N. Richland Hills, TX

PostPosted: Sat Feb 19, 2005 9:41 pm    Post subject: Re: [FAQ] Howto move the system on to a bigger harddrive ? Reply with quote

I used method 1. Worked like a champ. I have a setup very similar to tragor but my /dev/hda3 partition contains an EXT3 filesystem as per the current installation guide. I only had to make one minor alteration to the plan. Step 3 becomes:

Code:
# e2fsck -f /dev/hdc3
# resize2fs /dev/hdc3


If you attempt to run resize2fs without first e2fsck'ing the drive, it will remind you to run it. Thanks everyone for making this a very smooth migration. Now I have enough free disk space to compile OpenOffice. :)

--Lar
Back to top
View user's profile Send private message
PaoloP
n00b
n00b


Joined: 03 Feb 2004
Posts: 14

PostPosted: Mon Mar 21, 2005 1:56 pm    Post subject: Reply with quote

Usually when I need to move entire partitons I follow this HOWTO.

Never had a problem
_________________
--
Paolo Pedroni
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