-
Copying Users
The hardware on one of my servers is aging, so I need to replace it with a
machine on new hardware. The old server needs to remain in uninterrupted
service until the new server is complete with all the data from the old
server.
My primary concern is moving users from the old machine to the new machine.
My understanding is that I need to
copy /etc/passwd, /etc/passwd-, /etc/shadow, /etc/shadow-, /etc/group,
and /etc/group- user entries (user and group IDs between UID_MIN and
UID_MAX for users, and GID_MIN and GID_MAX for groups) from the old machine
to the new machine in order to get the basic user information copied. Is
this correct?
While I'm on the subject of IDs, are the above files the only places where
user and group IDs are defined? If I want to change a user and/or group ID
manually (just assume I have a good reason for doing so) when moving the
files from machine to machine, are the above files the only ones that are
of concern? Users that already exist on the target machine will not be
altered, so file ownership issues won't come into play.
My last question is whether a utility for moving users between machines
already exists, which would save me a bunch of time and effort. If not,
then I'll make one once I'm sure my methodology is correct.
-
Re: Moving Users
On Mon, 09 Oct 2006, in the Usenet newsgroup comp.os.linux.admin, in article
<hIxWg.21187$Ij.7187@newssvr14.news.prodigy.com>, AND IN the Usenet newsgroup
comp.os.linux.redhat in article
<mqzWg.11300$e66.3486@newssvr13.news.prodigy.com>,Tony O'Bryan wrote:
[Please do not separately post the same article to multiple newsgroups. If
you are sure it should be seen in multiple groups, list the groups in the
"Newsgroups:" header as I've done here, and set a "Followups-To:" header.
Neither comp.os.linux.admin or comp.os.linux.redhat are "valid" big-8
newsgroups, but the redhat group sees more articles (~1200/yr) than the
admin group (~240/yr). comp.os.linux.setup (~9000/yr) would have been more
useful and appropriate.]
[color=blue]
>The hardware on one of my servers is aging, so I need to replace it with a
>machine on new hardware. The old server needs to remain in uninterrupted
>service until the new server is complete with all the data from the old
>server.[/color]
Missing details. Same distribution and version? (may not be a good idea
if the "old" distribution is something ancient like Red Hat 9).
* Upgrade Upgrading Your linux Distribution mini-HOWTO
Updated: Mar 2002. Hints and tips on upgrading from one linux
distribution to another.
There is also an Update mini-HOWTO.
-rw-rw-r-- 1 gferg ldp 24960 May 28 2002 Update
-rw-rw-r-- 1 gferg ldp 19504 Mar 10 2002 Upgrade
[color=blue]
>My primary concern is moving users from the old machine to the new machine.
>My understanding is that I need to
>copy /etc/passwd, /etc/passwd-, /etc/shadow, /etc/shadow-, /etc/group,
>and /etc/group- user entries (user and group IDs between UID_MIN and
>UID_MAX for users, and GID_MIN and GID_MAX for groups) from the old machine
>to the new machine in order to get the basic user information copied[/color]
That's a big-old "That depends". Same distribution/version - yes. If the
old and new distributions use different password algorithms, things may
get dicey. But don't forget the mail directories in /var/spool/
[color=blue]
>While I'm on the subject of IDs, are the above files the only places where
>user and group IDs are defined?[/color]
If you looked at the Inodes, the UID and GID are numbers, and the
translation of numbers to names is done in /etc/passwd and /etc/group. (The
files with a - ending [/etc/passwd-] are previous versions of the "current"
files.)
[color=blue]
>If I want to change a user and/or group ID manually (just assume I have a
>good reason for doing so) when moving the files from machine to machine,
>are the above files the only ones that are of concern? Users that already
>exist on the target machine will not be altered, so file ownership issues
>won't come into play.[/color]
Depends on how you are transferring the files (man cp, man tar, and probably
a few dozen other methods), you will _probably_ be able to retain the user
and group _numbers_ from old to new system. But the user/group _name_ is
only tied in through the passwd and group files. If you want to change user
103 from 'Hector" to 'Vivian' then editing the passwd, shadow, home-directory
and mail-spool-directory names will do the trick. If you are going to
change user _number_ then things get trickier. While there is a -R option to
chown, a better solution is to use 'find' as in
find / -user oldname -exec chown newname {} \; or
find / -user oldname -exec chown newname:newgroup {} \;
Oldname and newname can be UID numbers. Where the cheese gets binding is
when you have the same UID or GID used by different people on the old and
new systems. A solution to that is BEFORE you move the old stuff, change
the username (and thus the UID) using that find command to something that
won't conflict - example 'find / -user hector -exec chown 61001 {} \;'
and then make the move.
[color=blue]
>My last question is whether a utility for moving users between machines
>already exists, which would save me a bunch of time and effort. If not,
>then I'll make one once I'm sure my methodology is correct.[/color]
The way we've been doing it for 25 years (long before Linux) is that the
users are backed up to a different tape (actually, we have the "system"
on one partition, /var/spool/ on another, and the /home/ on yet another)
so an upgrade consists of making a new install, then restoring those
tapes onto similarly separate partitions on the new system.
Old guy