pw add user slow
frank at woodcruft.co.uk
Tue Oct 18 14:05:56 UTC 2016
On Tue, Oct 18, 2016 at 07:46:13AM -0500, Valeri Galtsev wrote:
> On Tue, October 18, 2016 1:44 am, Steve O'Hara-Smith wrote:
> > On Mon, 17 Oct 2016 23:36:33 +0100
> > Paul Macdonald <paul at ifdnrg.com> wrote:
> >> Hi,
> >> I have to migrate an imap server, which uses about 6000 local accounts
> >> for mail delivery
> >> I'm using a script that creates system acounts using:
> >> /usr/sbin/pw adduser $LOCAL_USER -u$UID-gGID-d $PATH -s/bin/false
> >> I'm finding this grows ever more slow, up to 10 seconds per account on a
> >> SATA box , and on a test SSD box ( 20 acc's per second initially) even
> >> that slows to about 1 account created per second.
> >> why does this slow down as more accounts are added?
> > Because for each one it updates text files (passwd and
> > master.passwd) and regenerates databases (pwd.db and spwd.db) from the
> > text
> > files. The fastest way to do this sort of thing is to directly update
> > passwd and master.passwd and then run pwd_mkdb.
> It appears to be sufficient to only edit master.passwd; pwd_mkdb will
> re-generate passwd file from master.passwd.
There's a tool for that: vipw(8)
It uses $EDITOR if set, vi as default.
If using vi/vim then fire up vipw and:
will stick stdout from myscript into the buffer where the cursor is. Then:
and vipw will write it if it's conformant and then call pwd_mkdb to do it's
The OP will also have to edit /etc/group to add his users to the appropriate
Doesn't the imap server have an option for using a relational database rather
than filling passwd up? I'd go for that option if it does.
More information about the freebsd-questions