Thread: changing hdd
View Single Post

   
  #4 (permalink)  
Old 02-21-2008, 11:27 AM
Arthur Hagen
 
Posts: n/a
Default Re: changing hdd

jf <cestpasjihef@free.fr> wrote:
> Hi u all,
>
> Does anybody know the best way ( the more simple and.....the faster
> ) to copy all my linux, except boot partition, to a new hard disk ?
> My PC is like that :
>
> - primary master -> 200 Go ( grub+Windows XP !)
> - secondary master -> 40 Go ( linux gentoo on several partitions "/"
> "/home" etc..)
>
> I'd like to change this 2nd HD wich is becoming very slow, and....
> narrow . The new one will be at least 80 Go, but I can create the
> same partitions I've on my Linux HD.
> The question is : wich is the safest way replace the disk, and start
> with a working linux ?


If you use dd, like Aragorn recommended, you won't be able to increase more
than the last partition of your disk (if the file system supports growing,
that is). So no, since you have several partitions, I wouldn't recommend
that.

Add the new disk, partition it with the partitions in the same order as your
original disk, boot to a liveCD, and mount both the old and new partitions.

What kind of file system? If ext2/3 or xfs, you can use dump/restore or
xfsdump/xfsrestore to copy the files over and still retain all attributes,
special files, quotas, streams and everything else. For xfs, the following
should work:
xfsdump -J - /old | xfsrestore -J - /new

If using reiserfs, there's no dump utility (among the plethora of missing
things which makes it my least favourite file system), and you can't do much
better than a tar through a pipe:
cd /old && tar cpf - . | (cd /new && tar xvpf -)

(You may have to use --numeric-owner if the user IDs on your liveCD don't
match the ones you've used)

After copying over the data, change your existing grub/lilo to point to the
new disk instead of the old, or (if daring) remove the old drive, put the
new one in instead, and boot. I'd keep the old disk -- even if slow, an
extra drive is always useful. :-)

Regards,
--
*Art

Reply With Quote