How to recover or replace a lost /etc/passwd file?

chris1381

New Member


Messages: 5

Short story:
fsck "zero-sized" my /etc/passwd file. What's the best way to recover or recreate this file?

Full story:
I'm currently testing FreeBSD 9.0-RC3 on a Foxconn nT-A3500 Nettop computer.

After using chsh to change the default shell, I ran [cmd=]startx[/cmd] to start the Xorg desktop. The desktop was running fine with only a Firefox window open for about a minute, but then the system locked up and had to power cycle it.

fsck ran while rebooting and fixed some things on its own. Back on the login prompt, I was unable to log in: system was rejecting the password for my user account and the root account.

Rebooted once again and went into single user mode and found my /etc/passwd file had zero bytes in size. Now I'm thinking about how to get this file back. Is there any place where fsck puts broken files? Another way would probably to unpack this file from the distribution package and just add the missing user. But I've installed some packages which propably have added additional users into the system.

Any ideas on this?
 

DutchDaemon

Administrator
Staff member
Administrator
Moderator
Developer

Reaction score: 2,964
Messages: 11,354

If you still have the full /etc/master.passwd, you can recreate /etc/passwd using pwd_mkdb(8) (-p). If not, see if /var/backups/master.passwd fits your needs and use that. And before the entire forum says what it always says, and with good reason: make backups.
 
OP
C

chris1381

New Member


Messages: 5

Thanks for your help.

/etc/master.passwd was zero-sized, too. But the copy in /var/backups was intact and I got the system up and running again.

I didn't have backups, as this is a fresh install to find out whether the hardware is supported by FreeBSD. I didn't get FreeBSD 8.x to install on this system. FreeBSD 9.0 installs and runs, but there are still issues with the network interface not working properly and apparently Xorg sometimes freezes the system.

Now that the passwd files are restored I can take a deeper look at this.
 
Top