(Apology in advance to those who are already familiar with the Monta Vista
Software/Ziatech-specific features of Hard Hat Linux: please bear with me
as I include a little bit of information about these for the benefit of
those who may not be familiar either company or the products thereof.)
A few days ago I was attempting to copy one Linux system disk to another,
partition by partition (for the most part). I tried all 3 methods for doing
this as given in the "Hard Disk Upgrade Mini How-To" (see
http://www.linuxdoc.org/HOWTO/mini/Hard-Disk-Upgrade.html#Part6).
To summarize the examples from that document:
1. cp -ax / /mnt/root
Where "/mnt/root" is substituted for the "/new-disk" in the example
given in the "Hard Disk Upgrade Mini How-To" -- it was the top-level
mount point for the second hard disk (/dev/hdc7 if I remember the
partition identification correctly). I had originally planned to do
this separately for each partition/file system. I tried this and
several variations on it, all with the same results of not staying
within 1 file system, and not even avoiding the "/proc" directory.
See below for a more complete explanation. Other variations that I
tried were including the "-v" option to show me exactly what was
going on, "-f" to force overwrite of previous botched copying
attempts, and putting all of the options together (for example,
"-axvf") or separately (for example, "-a -x -v -f"), but none of
them made any difference.
2. cd / && echo cp -a `/bin/ls -1Ab | egrep -v "^mnt/root$|^proc$"`
/new-disk | sh
This did not avoid either the "new-disk" directory tree nor
the
"/proc" directory. A variation of this in which I prepended a
"/" to each of "mnt/root" and "proc" also did not avoid either
directory tree. I cannot determine whether the failure of this
example had anything to do with the "cp" command itself, but I
am including it for completeness.
3. cp -a /bin /boot /dev /etc /home /lib /lost+found /mnt /root /sbin
/tmp /usr /var /mnt/root
This is essentially what I ended up doing that worked (or would have
worked if the destination hard drive hadn't gone on the fritz
towards
the end), except that instead of doing it in 1 command all at once,
I
did this to only 1 top-level directory tree at a time.
The basic problem -- at least in example #1 above -- seems to be that the
"-x" option of the copy command is not staying within just 1 file system,
and not even avoiding the "/proc" directory, although in the case of
example #1 above ("cp -x" etc.), it does successfully avoid attempting to
copy the second hard drive to itself. It does occur to me that "Stay
within 1 drive but span file systems" might be desirable under some
circumstances, including some drive-to-drive copying operations, but if
this is to be implemented on purpose, it should be a separate capital "-X"
option or something like that, and it still should avoid the "/proc"
directory. The lowercase "-x" option should really avoid spanning file
systems, even on the same drive. The latter behavior is what the
documentation provided by "man cp" or "cp --help" indicates will occur,
and is thus what I expected, and is obviously what the "Hard Disk Upgrade
Mini How-To" expects.
The system I was using was a Ziatech 5541A with 2.5" IBM hard drives:
source drive (Model DARA-206000, 6 Gibytes) as /dev/hda, and destination
drive (Model DARA-212000, 12 Gibytes, with formatted partitions occupying
approximately 8 Gibytes) as /dev/hdc, mounted as "/mnt/root" directory tree.
Each drive had several partitions (a greater number and in some cases larger
on the destination drive, and never smaller). The operating system was
Hard Hat Linux 1.1 Ziatech Edition (originally installed from a CD obtained
directly from MontaVista Software), which is in turned derived from RedHat
6.x, including kernel version 2.2.12-20b and "cp" version (GNU) 4.0. The
installation was a full install from the CD, with the only additional
software being "gcc" version 2.95.2 (obtained from http://www.gnu.org as the
gzipped source version, and used to upgrade from the originally-installed
version 2.91.6), and ORBacus 4.0.2 (home page http://www.ooc.com/ob/).
(Hard Hat Linux 1.1 Ziatech Edition includes the (non-RedHat) Ziatech
software CompactNET 1.3, but this does not run in single-user mode or
runlevel 1.) In most of the attempts, I had the system booted in single-
user mode ("linux s" or "telinit s"), but this didn't seem to make a
difference in the results relative to those obtained in runlevel 3. In all
cases of failure, no error messages appeared (except for messages about not
overwriting existing files or symlinks in some cases) until a destination
partition got full, usually as a result of "cp" attempting to copy
/proc/kcore to it.
--
-- Lucius Chiaraviglio