Tag Archives: freebsd

Changing a User’s Password on FreeBSD

Before getting into how to change a user’s password on FreeBSD, let’s have a quick revision on how that can be done on a Linux system.

As a user we can change the password by typing:

$ passwd
Changing password for user kenno.
Changing password for kenno.
Current password: 
...

Or with a root account, we can change/set the password for another user:

# passwd kenno
Changing password for user kenno.
New password: 
...

How about a FreeBSD? It should be the same way as how it’s done on Linux right? Right? Well, not quite.

On a FreeBSD system, in addition to run the passwd command, we also need to generate the password databases to be “in sync” with the plain text files.

# pwd_mkdb /etc/master.passwd

You can learn more about both passwd and pwd_mkdb, by running:

$ man passwd
$ man pwd_mkdb

Ref: Can’t change user password

FreeBSD 11 Blank Screen After Login via SLiM

After rebooting my FreeBSD 11.0, I wasn’t able to login to Mate desktop manager via SLiM (Login Manager).
I spent sometimes to try to fix it, but failed. I’ll try it again later when I have a bit of free time.

Here’s a quick note of a work around, so I won’t forget what I’ve done.

1) Disable loading slim on start up by editing /etc/rc.conf and commented out the following line:

...
#slim_enable="YES
...

2) Run this command manually to start mate-session:

$ xinit mate-session

So, it appears SLiM is the culprit here since Mate-session can be started up manually.

FreeBSD upgrade pool ‘zroot’

Today I successfully upgraded my FreeBSD home nas server from 10.3 to 11.0. This is the final release of version 11.0, though the official announcement is expected to be made on September 28.

After the system upgrade, I need to also upgrade the 2 zpools (tank and zroot) so they can have new features. Upgrading tank was easy, all I needed to do was running this command:

# zpool upgrade tank
This system supports ZFS pool feature flags.

Enabled the following features on 'tank':
  sha512
  skein

For zroot, in addition to running the above command (by replacing the actually zpool name to zroot), I also need to update the boot code.

root@nas:~ # zpool upgrade zroot
This system supports ZFS pool feature flags.

Enabled the following features on 'zroot':
  sha512
  skein

If you boot from pool 'zroot', don't forget to update boot code.
Assuming you use GPT partitioning and da0 is your boot disk
the following command will do it:

        gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0

What’s the boot code? Good question. Not sure what it is, I’ll find out later by reading the FreeBSD document.

The boot disk in my server is not da0. How do we find out what it is?

root@nas:~ # gpart show
=>       34  125045357  ada4  GPT  (60G)
         34       1024     1  freebsd-boot  (512K)
       1058    4194304     2  freebsd-swap  (2.0G)
    4195362  120850029     3  freebsd-zfs  (58G)

In my case, it’s ada4, and the partition the boot sits on is ada4p1.
So, I can now proceed to update the boot code:

root@nas:~ # gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada4
partcode written to ada4p1
bootcode written to ada4

Reboot the machine, and voilla it’s “still” working.

Fix corrupted GPT on FreeBSD

One of the disks in my FreeBSD server reported an issue:

Jul 14 18:00:56 nas kernel: GEOM: da0: the primary GPT table is corrupt or invalid.
Jul 14 18:00:56 nas kernel: GEOM: da0: using the secondary instead -- recovery strongly advised.
Jul 14 18:00:56 nas kernel: GEOM: diskid/DISK-67304734999999999999: the primary GPT table is corrupt or invalid.
Jul 14 18:00:56 nas kernel: GEOM: diskid/DISK-67304734999999999999: using the secondary instead -- recovery strongly advised.

To verify it, first I used gdisk command:

root@nas:~ # gdisk /dev/da0
GPT fdisk (gdisk) version 0.8.10

Caution! After loading partitions, the CRC doesn't check out!
Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!

Warning! One or more CRCs don't match. You should repair the disk!

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************

Command (? for help): q

An alternative way to verify this is to use gpart command:

root@nas:~ # gpart show da0
=>       34  976773101  da0  GPT  (466G) [CORRUPT]
         34  976773101       - free -  (466G)

I think it’s possible use gdisk to repair the corrupted GPT table, but I tried gpart and it worked:

nas:~ # gpart recover /dev/da0
da0 recovered
root@nas:~ # gpart show da0
=>       34  976773101  da0  GPT  (466G)
         34  976773101       - free -  (466G)

FreeBSD git fatal: Unable to find remote helper for ‘https’

I just found out that git is not fully functional on my FreeBSD (11) box. It was installed from port (using portmaster git). I can clone a repo using SSH key, but not with HTTPS.

I’m not quite sure if it’s always been this way. Here is how to fix it:

1) Reinstall curl

# pkg remove curl
# portmaster curl

2) Reinstall git

# pkg remove git
# portmaster git

Why did I install git from port? Well, ‘cuz there is no binary package for FreeBSD 11 arm, which runs on my Raspberry Pi B+.