Help!

Clone root partition


Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions (archive 2) RSS
Next:  Eric Raymond tempted by Mac?  
Author Message
* Tong *
External


Since: Dec 30, 2006
Posts: 5



PostPosted: Sat Dec 30, 2006 4:24 pm    Post subject: Clone root partition
Archived from groups: comp>os>linux>misc (more info?)

Hi,

I'm trying to compile a comprehensive document on cloning root partitions.
My immediate goal is to clone my current working Linux to external USB HD,
so that I can use it wherever I go.

By comprehensive I mean it should not be as simple minded as

dd if=/dev/hda2 of=/dev/sda2

or

cp -a / /mnt/point

or

tar -p -m cf - / | (cd /mnt/point; tar xf - )

I know they work, but there are so many things have been left out. By
comprehensive, I mean I want to know all relevant things that need to be
considered.

For example for dd, let alone its rigid limitation, if you use it, at least
the 'conv=sync,noerror bs=4k' options should be used: sync,noerror just
means continue and zero fill any error blocks, bs=4k just writes 4k at a
time which will speed things up a lot. For cp, at least 'cp -ax' should be
used.

But there are still much more to it.

First, directories that don't need to copy over, like /tmp, /proc. With
modern Linux that uses udev, the /dev and /sys don't need to be copied
either. Anything else (besides distro specifics like /var/cache/apt/archives)?

2nd, the clone partition should be made bootable, by grub or lilo.

Anything else? Like the concerns of /etc/fstab...

Last, with all the above concerns, how to achieve them with various tools?

Keywords: tar rsync find cpio dd

thanks

PS. If you come across this post late, be it a week or even a month late,
please do comment, I hope this thread can be a one stop place for people
looking for concerns over cloning root partitions.


--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/

--
Posted via a free Usenet account from http://www.teranews.com
Back to top
Timothy Murphy
External


Since: May 26, 2005
Posts: 262



PostPosted: Sat Dec 30, 2006 8:26 pm    Post subject: Re: Clone root partition [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

* Tong * wrote:

> Hi,
>
> I'm trying to compile a comprehensive document on cloning root partitions.
> My immediate goal is to clone my current working Linux to external USB HD,
> so that I can use it wherever I go.
>
> By comprehensive I mean it should not be as simple minded as
>
> dd if=/dev/hda2 of=/dev/sda2
>
> or
>
> cp -a / /mnt/point
>
> or
>
> tar -p -m cf - / | (cd /mnt/point; tar xf - )
>
> I know they work, but there are so many things have been left out. By
> comprehensive, I mean I want to know all relevant things that need to be
> considered.
>
> For example for dd, let alone its rigid limitation, if you use it, at
> least the 'conv=sync,noerror bs=4k' options should be used: sync,noerror
> just means continue and zero fill any error blocks, bs=4k just writes 4k
> at a time which will speed things up a lot. For cp, at least 'cp -ax'
> should be used.
>
> But there are still much more to it.
>
> First, directories that don't need to copy over, like /tmp, /proc. With
> modern Linux that uses udev, the /dev and /sys don't need to be copied
> either. Anything else (besides distro specifics like
> /var/cache/apt/archives)?
>
> 2nd, the clone partition should be made bootable, by grub or lilo.
>
> Anything else? Like the concerns of /etc/fstab...
>
> Last, with all the above concerns, how to achieve them with various tools?
>
> Keywords: tar rsync find cpio dd
>
> thanks

I'm not an expert in this area,
but I would have thought it was advisable
not to clone / while it is mounted;
I would run knoppix, or something like that, and then copy with "cp -a".

--
Timothy Murphy
e-mail (<80k only): tim /at/ birdsnest.maths.tcd.ie
tel: +353-86-2336090, +353-1-2842366
s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland
Back to top
Dances With Crows
External


Since: Jun 07, 2006
Posts: 587



PostPosted: Sat Dec 30, 2006 8:26 pm    Post subject: Re: Clone root partition [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Sat, 30 Dec 2006 20:26:00 +0000, Timothy Murphy staggered into the
Black Sun and said:
> * Tong * wrote:
>> I'm trying to compile a comprehensive document on cloning root
>> partitions. My immediate goal is to clone my current working Linux
>> to [an] external USB HD, so that I can use it wherever I go.

This requires an x86 that can boot from USB devices in a sane and
reproducible manner. Not every x86 machine can do this, but it's more
common than it used to be.

>> By comprehensive I mean it should not be as simple minded as
>> dd if=/dev/hda2 of=/dev/sda2
>> cp -a / /mnt/point
>> tar -p -m cf - / | (cd /mnt/point; tar xf - )
>>
>> I know they work, but so many things have been left out. By
>> comprehensive, I mean I want to know all relevant things that need to
>> be considered.

cp -a all directories that aren't /proc, /sys, or /dev (if using
udev/devfs), edit /etc/fstab to reflect new position of drive, reinstall
bootloader. 3 steps--which one are you having trouble with?

>> For example for dd

dd is not a backup method. Forget it.

>> modern Linux that uses udev, the /dev and /sys don't need to be
>> copied either. Anything else (besides distro specifics like
>> /var/cache/apt/archives)?

Copy the directories that contain actual data. This excludes /proc,
/sys, /dev if you're using udev/devfs, and any removable media and
network filesystems under /mnt or /media .

>> the clone partition should be made bootable, by grub or lilo.

No, really? Are you having trouble with this step? Explain the trouble
you're having. I'd say it's a better idea to use GRUB here, since
booting from things that aren't IDE can cause weird rearrangements in
BIOS boot order depending on the x86 you're using. (Boot from IDE
CD-R*, SATA disk is (hd2). Boot from SATA disk, SATA disk is (hd0).
BTDT.) GRUB gives you a shell you can use to try to recover. LILO
doesn't.

> I'm not an expert in this area, but I would have thought it was
> advisable not to clone / while it is mounted

Why not? If you're super-paranoid, take it down to single-user and
remount / ro, but if the machine's a single-user orkstation, there
should be no problem.

--
Love is a laser.
DO NOT LOOK INTO LASER WITH REMAINING HEART.
--Tori and Greg Andrews
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
Back to top
* Tong *
External


Since: Dec 30, 2006
Posts: 5



PostPosted: Sun Dec 31, 2006 4:37 am    Post subject: Re: Clone root partition [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Sat, 30 Dec 2006 16:25:25 -0600, Dances With Crows wrote:

>>> the clone partition should be made bootable, by grub or lilo.
>
> No, really? Are you having trouble with this step? Explain the trouble
> you're having.

First of all, thank you all who replied. No I don't have problems with
that. Actually, as said in OP, I was looking for *concerns* over cloning
root partitions.

> I'd say it's a better idea to use GRUB here, since
> booting from things that aren't IDE can cause weird rearrangements in
> BIOS boot order depending on the x86 you're using. (Boot from IDE
> CD-R*, SATA disk is (hd2). Boot from SATA disk, SATA disk is (hd0).
> BTDT.)

So I read. GRUB is not very reliable for booting usb. I read that the most
reliable way is to use SYSLINUX, but having played with SYSLINUX for the
whole day, I think I'll rule out SYSLINUX and use back to GRUB.

> GRUB gives you a shell you can use to try to recover. LILO
> doesn't.

yep, that'd be the last resort to refer to. On the contrary, using
SYSLINUX would *just work*.

>>> For example for dd
>
> dd is not a backup method. Forget it.

I think so too.

> cp -a all directories that aren't /proc, /sys, or /dev (if using
> udev/devfs), edit /etc/fstab to reflect new position of drive, reinstall
> bootloader. 3 steps--which one are you having trouble with?

Actually I want to rule out 'cp' as well, since "cp -a all directories
that aren't /proc, /sys, or /dev" is easy to say than done in script.
rsync should be a much better option.

--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/

--
Posted via a free Usenet account from http://www.teranews.com
Back to top
John-Paul Stewart
External


Since: Mar 29, 2005
Posts: 1520



PostPosted: Sun Dec 31, 2006 11:29 am    Post subject: Re: Clone root partition [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

* Tong * wrote:
>
> Actually I want to rule out 'cp' as well, since "cp -a all directories
> that aren't /proc, /sys, or /dev" is easy to say than done in script.

It should be easy enough to script:

cp -a `find / -maxdepth 1 \( \! -name proc -a \! -name sys -a \! -name
dev \) -print`

Note that you need to escape the ( ) and ! (find's "not" operator) with
backslashes to avoid having the shell treat them as special characters.

You might also want to add lost+found to the exclusion list.
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions (archive 2) All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can 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