Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > NZ Computing > Copying Linux partition

Reply
Thread Tools

Copying Linux partition

 
 
Graham
Guest
Posts: n/a
 
      09-17-2004
Is there a tool to do this? I'd like to copy my Linux partition to a
newer hard drive.
I'm using Redhat 9.
 
Reply With Quote
 
 
 
 
Graham
Guest
Posts: n/a
 
      09-17-2004
Graham wrote:
>
> Is there a tool to do this? I'd like to copy my Linux partition to a
> newer hard drive.
> I'm using Redhat 9.


Minor correction: I meant, *extended partition*, which holds the two
Linux partitions. Presumably copying the Linux partitions, within
Linux, should mean copying the two Linux partitions to a new Ext.
partition.
 
Reply With Quote
 
 
 
 
Barry
Guest
Posts: n/a
 
      09-17-2004
Graham wrote:

> Graham wrote:
>>
>> Is there a tool to do this? I'd like to copy my Linux partition to a
>> newer hard drive.
>> I'm using Redhat 9.

>
> Minor correction: I meant, *extended partition*, which holds the two
> Linux partitions. Presumably copying the Linux partitions, within
> Linux, should mean copying the two Linux partitions to a new Ext.
> partition.


If the two partitions are exactly the same size (or the destination
partition is slightly larger) then:

dd if=/dev/hdaX of=/dev/hdbY

but be very very careful.

Much better is to create your partitions on destination drive - they can
be any sort of partition - and use tar or cp.

For example:

fdisk /dev/hdb
... create partitions ...
mke2fs /dev/hdbY
mount /dev/hdbY /mnt/dest
cp -ax /mounted_filesystem /mnt/dest/

You still have to be careful.
And you might have to mount your partition to copy, or perhaps
remount a live one as read-only.

If you are copying your root partition then it is best to boot up
on a bootable cdrom and do it.

 
Reply With Quote
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      09-17-2004
In article <(E-Mail Removed)>,
Barry <(E-Mail Removed)> wrote:

> cp -ax /mounted_filesystem /mnt/dest/


This will work, but I prefer rsync:

rsync --archive --delete --one-file-system
/mounted_filesystem /mnt/dest/

One reason is that, should the transfer be interrupted for any reason,
rsync makes it much easier to resume from where you left off--just
reexecute the same command, and it'll figure it out. That's why I put in
the "--delete", so it'll keep track of any changes to the source
filesystem in the meantime.

Also put in "--verbose", and it'll list the name of every file as it
transfers it.
 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      09-17-2004
Barry wrote:
> Graham wrote:
>
>
>>Graham wrote:
>>
>>>Is there a tool to do this? I'd like to copy my Linux partition to a
>>>newer hard drive.
>>>I'm using Redhat 9.

>>
>>Minor correction: I meant, *extended partition*, which holds the two
>>Linux partitions. Presumably copying the Linux partitions, within
>>Linux, should mean copying the two Linux partitions to a new Ext.
>>partition.

I'd look at least to going to journalled ext3. Possible take this
opportunity to change to reiserfs or xfs for improved data security.
>
>
> If the two partitions are exactly the same size (or the destination
> partition is slightly larger) then:
>
> dd if=/dev/hdaX of=/dev/hdbY
>
> but be very very careful.
>
> Much better is to create your partitions on destination drive - they can
> be any sort of partition - and use tar or cp.
>
> For example:
>
> fdisk /dev/hdb
> ... create partitions ...
> mke2fs /dev/hdbY

at least mke2fs -j, or maybe even use reiser or xfs instead.
> mount /dev/hdbY /mnt/dest
> cp -ax /mounted_filesystem /mnt/dest/


cd /mounted_filesystem
find . -depth -xdev | grep -v '/proc/' | cpio -dump /mnt/dest

There used to be problems with device files and cp. I'm never certain
whether they've been properly fixed. You also don't want to copy things
like /dev/kmem!
>
> You still have to be careful.
> And you might have to mount your partition to copy, or perhaps
> remount a live one as read-only.
>
> If you are copying your root partition then it is best to boot up
> on a bootable cdrom and do it.
>

Imperative!

Steve


 
Reply With Quote
 
Barry
Guest
Posts: n/a
 
      09-17-2004
Steve wrote:

> Barry wrote:
>> Graham wrote:
>>
>>
>>>Graham wrote:
>>>
>>>>Is there a tool to do this? I'd like to copy my Linux partition to a
>>>>newer hard drive.
>>>>I'm using Redhat 9.
>>>
>>>Minor correction: I meant, *extended partition*, which holds the two
>>>Linux partitions. Presumably copying the Linux partitions, within
>>>Linux, should mean copying the two Linux partitions to a new Ext.
>>>partition.

> I'd look at least to going to journalled ext3. Possible take this
> opportunity to change to reiserfs or xfs for improved data security.
>>
>>
>> If the two partitions are exactly the same size (or the destination
>> partition is slightly larger) then:
>>
>> dd if=/dev/hdaX of=/dev/hdbY
>>
>> but be very very careful.
>>
>> Much better is to create your partitions on destination drive - they can
>> be any sort of partition - and use tar or cp.
>>
>> For example:
>>
>> fdisk /dev/hdb
>> ... create partitions ...
>> mke2fs /dev/hdbY

> at least mke2fs -j, or maybe even use reiser or xfs instead.
>> mount /dev/hdbY /mnt/dest
>> cp -ax /mounted_filesystem /mnt/dest/

>
> cd /mounted_filesystem
> find . -depth -xdev | grep -v '/proc/' | cpio -dump /mnt/dest
>
> There used to be problems with device files and cp. I'm never certain
> whether they've been properly fixed. You also don't want to copy things
> like /dev/kmem!


No problems with cp -a.

Another way is:

cd /mnt/whatever && tar chlf - . | (cd /mnt/new && tar xf -)

But really, "cp -a" is nice and simple and has *never* given me a problem.

>>
>> You still have to be careful.
>> And you might have to mount your partition to copy, or perhaps
>> remount a live one as read-only.
>>
>> If you are copying your root partition then it is best to boot up
>> on a bootable cdrom and do it.
>>

> Imperative!


I have done it both ways and both work much the same.

 
Reply With Quote
 
Enkidu
Guest
Posts: n/a
 
      09-17-2004
On Fri, 17 Sep 2004 13:35:52 +1200, Lawrence D'Oliveiro
<(E-Mail Removed)_zealand> wrote:

>In article <(E-Mail Removed)>,
> Barry <(E-Mail Removed)> wrote:
>
>> cp -ax /mounted_filesystem /mnt/dest/

>
>This will work, but I prefer rsync:
>
> rsync --archive --delete --one-file-system
> /mounted_filesystem /mnt/dest/
>
>One reason is that, should the transfer be interrupted for any reason,
>rsync makes it much easier to resume from where you left off--just
>reexecute the same command, and it'll figure it out. That's why I put in
>the "--delete", so it'll keep track of any changes to the source
>filesystem in the meantime.
>

cp -axu will resume on interruption.

Cheers,

Cliff
 
Reply With Quote
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      09-17-2004
In article <(E-Mail Removed)>,
Enkidu <(E-Mail Removed)> wrote:

>On Fri, 17 Sep 2004 13:35:52 +1200, Lawrence D'Oliveiro
><(E-Mail Removed)_zealand> wrote:
>
>>In article <(E-Mail Removed)>,
>> Barry <(E-Mail Removed)> wrote:
>>
>>> cp -ax /mounted_filesystem /mnt/dest/

>>
>>This will work, but I prefer rsync:
>>
>> rsync --archive --delete --one-file-system
>> /mounted_filesystem /mnt/dest/
>>
>>One reason is that, should the transfer be interrupted for any reason,
>>rsync makes it much easier to resume from where you left off--just
>>reexecute the same command, and it'll figure it out. That's why I put in
>>the "--delete", so it'll keep track of any changes to the source
>>filesystem in the meantime.
>>

>cp -axu will resume on interruption.


That only looks at modification times, and I don't think it'll work
properly with partially-copied files. rsync looks at contents, so it
will correctly finish partial files.
 
Reply With Quote
 
Barry
Guest
Posts: n/a
 
      09-17-2004
Lawrence D'Oliveiro wrote:

> In article <(E-Mail Removed)>,
> Enkidu <(E-Mail Removed)> wrote:
>
>>On Fri, 17 Sep 2004 13:35:52 +1200, Lawrence D'Oliveiro
>><(E-Mail Removed)_zealand> wrote:
>>
>>>In article <(E-Mail Removed)>,
>>> Barry <(E-Mail Removed)> wrote:
>>>
>>>> cp -ax /mounted_filesystem /mnt/dest/
>>>
>>>This will work, but I prefer rsync:
>>>
>>> rsync --archive --delete --one-file-system
>>> /mounted_filesystem /mnt/dest/
>>>
>>>One reason is that, should the transfer be interrupted for any reason,
>>>rsync makes it much easier to resume from where you left off--just
>>>reexecute the same command, and it'll figure it out. That's why I put in
>>>the "--delete", so it'll keep track of any changes to the source
>>>filesystem in the meantime.
>>>

>>cp -axu will resume on interruption.

>
> That only looks at modification times, and I don't think it'll work
> properly with partially-copied files. rsync looks at contents, so it
> will correctly finish partial files.


Well then you can just add -v to your cp and if you get interrupted
then you only need delete the last file copied started!

But getting interrupted in the middle of a cp is very very rare that
it hardly seems worth doing something like:

rsync --archive --delete --one-file-system --what-a-lot-of-options

as opposed to:

cp -avx


 
Reply With Quote
 
steve
Guest
Posts: n/a
 
      09-17-2004
Graham wrote:

> Is there a tool to do this? I'd like to copy my Linux partition to a
> newer hard drive.
> I'm using Redhat 9.


I booted from CD, then copied all the files to another hard drive...Makesure
you get all the ".<name>" hidden directories

Then I installed a very basic system on the target drive....

Then booted from the CD and copied the earlier copy from the backup drive
over top of the basic system.

Then re-boot.

Linux isn't like WinXP. There is no registry or other stuff to make things
hard. Most config stuff is in straight text files.

It's much easier to move Linux around.....at least in my experience.




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dd - unequal speed from partition to partition, partition to file,file to partition bolega C Programming 1 03-28-2011 07:37 PM
Save Linux Partition-Get Rid of Linux =?ISO-8859-1?Q?=22=28Ctrl=A4+/Alt+=A4/Del=A4+=29=22?= Computer Support 43 03-06-2006 11:20 PM
Dual-boot - how to boot old XP-partition in FAT on NTFS partition next to Win XP ? Dutch Treat Computer Support 0 12-06-2004 11:13 AM
Trying to resize partition using Partition Magic 8.0 Mike Computer Support 4 01-29-2004 06:54 PM
Help..Partition magic made my partition disappear into oblivion Pierre Jarry Computer Support 6 07-14-2003 04:54 AM



Advertisments