Lost root account during upgrade

When upgrading from 13.2 to 13.3, on my way to 14, I must have messed up an edit of one of the files it asked me to edit and I can't log into root anymore but I can log in as a user.
su doesn't work either. I can reboot and get into single user mode with toor.

Looked in /etc/master.passwd and /etc/passwd but root is not in either of those but it is in /etc/group in wheel.

How do I go about restoring root?
 
I just had to deal with the same thing. 13.2 to 13.3 failed because of passwd complaining on upgrade.

I had to boot into single user mode, set disk read-write mount -o rw / then create a new password for root with passwd
.
 
Phishfry But I don't have a root user. I'm not sure if I can create root.
Erichans Since I don't have a root user, I'd have to use toor to mount everything.....I think.

So I guess my question now is, can I just copy the passwd files from /var/backups to restore root?
 
If you boot into single user mode as suggested, you won't actually login. All you need is physical access to the computer.
 
Phishfry That got my root back but I still can't change the password. I went into toor and tried to mount / and change it there but only managed to change toor's prompt to root somehow. I have to leave for a bit so can't think right now.
 
Depending on which file system You use, the root password can be reseted with passwd. For UFS you can follow this tutorial; for ZFS you need to use chroot after the zpool import and mount.
 
Just noticed this. Something's not right. Ran bectl list

Code:
BE                                 Active Mountpoint Space Created
13.2-RELEASE-p10_2024-03-28_133956 -      -          16.5G 2024-03-28 13:39
13.2-RELEASE-p11_2024-07-12_111938 -      -          33.2M 2024-07-12 11:19
13.2-RELEASE-p12_2024-07-14_095824 -      -          6.93M 2024-07-14 09:58
13.2-RELEASE_2023-05-22_173026     NR     /          7.13G 2023-05-22 17:30
13.2-RELEASE_2023-06-23_083916     -      -          1.70G 2023-06-23 08:39
13.3-RELEASE-p3_2024-07-14_095952  -      -          6.85M 2024-07-14 09:59
default

This should be pointing to 13.3 RELEASE. But I've got to go to my son's birthday dinner.
 
/etc/passwd (or maybe it is /etc/master.passwd) is definitely one of the files that you have to watch out for in 13.2 to 13.3 upgrade with freebsd-update.

So maybe you deleted both the root user lines (one for 13.2 the other for 13.3) completely and that's when the root user vanished.

My mistake was leaving the 13.3 line in place (deleted all the <<<s and the 13.2 line) - IIRC that meant a blank root password.
 
Well. I thought I didn't know what I was doing and I'm never, EVER wrong.

Even though I set bectl -t activate, and it showed I activated what I upgraded to, I rebooted and it shows I'm back on the previous 13.2-RELEASE and I have the same issue with no way to log into root.

I might tinker for a few more minutes but need to go to bed soon.
 
I had a quite similar issue a couple of weeks ago while tinkering on my experimenting machine: killed my root by messing up the /etc/passwd while updating.
(btw: When I want my root stick to csh, will I be asked this every update, again and again?)
Wouldn't be a problem since that machine is for experimenting throw away.
But I didn't want to give up quickly, tinkered a bit and got me my root back.
That's one of those moments to feel good about using FreeBSD:
There always is a solution.

As adorno pointed out:
physical access to the computer
is pretty much all you need.

Don't boot the machine's installed system, boot a life system on it instead (FreeBSD iso.install-image on a USB-stick will do; instead of "Install" goto "Live")
As already some mentioned above mount your partition/pool containing /etc/ writeable.
Then edit /etc/passwd, and /etc/master (/etc/group is okay, you say), add/correct the line for root.
Watch out for to get all this ..:0:0::0:0:.. right, and the password empty.
Or - easier/better - copy the according lines from your last /etc/-backup.

This might feel be a bit "dirty", but hey, 'quick-n-dirty' is my middle name.
When your machine is up and running again with a root account you can calmly clean up,
such as give root a password again, anyway,
so all according files are correctly set by the system again.
Worked for me.
 
So my issue with rebooting into the previous version was caused by my using bectl activate -t That -t means it will reboot that version just once. You need to activate the version you want permanently by removing the -t.
 
Back
Top