Category Archives: Tips

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

Zpool Not Automatically Mounted on Boot on Fedora

I love ZFS, but there is something that has annoyed me for quite sometimes – the zpool doesn’t get automatically mounted on boot. To work around this, I had to login as root and run:

# zpool import tank

to import tank pool before I login with my normal user account.

Well, I finally found a solution. This is what’s written on zfsonlinux/zfs WIFI about Fedora specifically:

Systemd Update:

When upgrading to the zfs-0.6.5.8 release it’s recommended that users manually reset the zfs systemd presets. Failure to do so can result in the pool not automatically importing when the system is rebooted.

systemctl preset zfs-import-cache zfs-import-scan zfs-mount zfs-share \
zfs-zed zfs.target

Okay, here’s how I fix my issue. First, ensure that a pool that I want to automatically mounted is manually mounted first. Then just run that lengthy command shown above:

# zpool import tank
# systemctl preset zfs-import-cache zfs-import-scan zfs-mount zfs-share zfs-zed zfs.target
Created symlink /etc/systemd/system/zfs-mount.service.wants/zfs-import-cache.service → /usr/lib/systemd/system/zfs-import-cache.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-import-cache.service → /usr/lib/systemd/system/zfs-import-cache.service.
Created symlink /etc/systemd/system/zfs-share.service.wants/zfs-mount.service → /usr/lib/systemd/system/zfs-mount.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-mount.service → /usr/lib/systemd/system/zfs-mount.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-share.service → /usr/lib/systemd/system/zfs-share.service.
Created symlink /etc/systemd/system/zed.service → /usr/lib/systemd/system/zfs-zed.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-zed.service → /usr/lib/systemd/system/zfs-zed.service.

Now, that makes me a much happier ZFS user!

Ref: zfsonlinux/zfs

របៀប​លុប​អត្ថបទ​ចម្រៀង​​ចេញ​ពី​ mp3

ខ្ញុំ​មាន​បទ​ចម្រៀង mp3 ពីរ​ឬបី​ដែល​មាន​អត្ថបទ​ចម្រៀង​ភ្ជាប់ជាមួយ (embedded lyric)។ ខ្ញុំ​ចង់លុប​អត្ថបទ​នោះចេញ។

នេះ​ជា​វិធី​មួយ​ដែល​អាច​សម្រេច​បំណង​ខាងលើ ដោយប្រើកម្មវិធី​ឈ្មោះ id3v2 នៅ​លើហ្វេដ័ររ៉ា។ ឧទាហរណ៍​ថា​ ចម្រៀង​ដែល​ខ្ញុំ​ចង់លុប​អត្ថបទភ្ជាប់​នោះ​ មាន​ឈ្មោះ​ថា “01 love you.mp3” ខំម៉ានដែល​យើង​ត្រូវ​វាយ ដូច​ខាង​ក្រោម​នេះ៖

$ id3v2 --remove-frame 'TEXT' 01\ love\ you.mp3
  • --remove-frame – លុប​ id3v2 frame
  • 'TEXT'

បើសិន​ជា​យើង​មាន​ mp3 ច្រើន​ក្នុង​ directory តែ​មួយ​ ហើយយើង​ចង់​លុប​​ ‘TEXT’ frame ចេញ យើង​អាច​ប្រើ​ខំម៉ាន​ដូច​នេះ៖

$ for i in *.mp3; do id3v2 -r 'TEXT' $i; done
Deleting Frame TEXT in file 01 love you.mp3 ...
Deleting Frame TEXT in file 02 Ima demo Aitai yo….mp3 ...
Deleting Frame TEXT in file 03 Brand New World.mp3 ...

សូម​កត់​សំគាល់​ថា ក្នុង​ខំម៉ាន​ខាង​លើ ខ្ញុំ​ប្រើ -r ជំនួស​អោយ​ --remove-frame។ អផសុន​ (options) ទាំង​ពីរ​នោះ វា​ដូច​គ្នា​ទេ៕

Install ZFS on Fedora 25 with kernel 4.8.13-300

After I had my Fedora 24 upgraded to 25 on my desktop, ZFS no longer worked. I tried to remove zfs package and reinstalled; it didn’t work.

Here’s how I got it working after trying many things. There could be a different way to fix it, though.

Let’s check the version of the kernel:

[root@sangkae ~]# uname -r
4.8.13-300.fc25.x86_64

Check if spl, zfs are already installed:

[root@sangkae ~]# dnf info spl
Last metadata expiration check: 1:01:18 ago on Thu Dec 15 22:42:25 2016.
Installed Packages
Name        : spl
Arch        : x86_64
Epoch       : 0
Version     : 0.6.5.8
Release     : 1.fc25
Size        : 48 k
Repo        : @System
From repo   : zfs
Summary     : Commands to control the kernel modules
URL         : http://zfsonlinux.org/
License     : GPLv2+
Description : This package contains the commands to verify the SPL
            : kernel modules are functioning properly.

[root@sangkae ~]# dnf info zfs
Last metadata expiration check: 1:01:26 ago on Thu Dec 15 22:42:25 2016.
Installed Packages
Name        : zfs
Arch        : x86_64
Epoch       : 0
Version     : 0.6.5.8
Release     : 1.fc25
Size        : 808 k
Repo        : @System
From repo   : zfs
Summary     : Commands to control the kernel modules and libraries
URL         : http://zfsonlinux.org/
License     : CDDL
Description : This package contains the ZFS command line utilities.

Manually install spl, dkms:

# dkms install spl/0.6.5.8
# dkms install zfs/0.6.5.8

Load zfs module:

# modprobe zfs

Voilla, I got ZFS working again.

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.

Perl IO::Socket::INET6::sockaddr_in6 redefined error

Yesterday I installed spamassassin package on a server running RHEL 6.8. Then this morning, I received an email alert with the following message:

Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/share/perl5/IO/Socket/INET6.pm line 21.
Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/share/perl5/IO/Socket/INET6.pm line 21.
Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/share/perl5/IO/Socket/INET6.pm line 21.
Subroutine IO::Socket::INET6::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/share/perl5/IO/Socket/INET6.pm line 21.

This seems to be a bug exists in an old version of IO::Socket::INET6. Upgrading this package should fix the problem:

# cpan IO::Socket::INET6

Ref: http://stackoverflow.com/questions/23909848/perl-iosocketinet6sockaddr-in6-redefined-error

Warning: Use of “localtime” without parentheses is ambiguous

While looking at the log produced by Request Tracker (RT) 4.2.12, I noticed there was a warning message about using “localtime” without parentheses.

Here’s the actual error message:

[warning]: Warning: Use of "localtime" without parentheses is ambiguous 
at /opt/rt4/sbin/../lib/RT/Interface/Email.pm line 526.

The solution which I found from here, fixed the problem:

On line 526 of file /opt/rt4/sbin/../lib/RT/Interface/Email.pm, replace:

localtime with localtime().

Thanks to the chap who posted the solution.

Make Gnome Title Bar Small Again

Sometimes in life greater is not always better. Here’s a config which I used to make the Gnome 3 title bar smaller.

Create a file in ~/.config/gtk-3.0/gtk.css:

headerbar.default-decoration {
    padding-top: 3px;
    padding-bottom: 3px;
    min-height: 0px;
    font-size: 0.7em;
}

headerbar.default-decoration button.titlebutton {
    padding: 0px;
    min-height: 0px;
}

Here’s how the title bar looks like before and after applying the custom css file:

Default title bar size

Default title bar size

Small title bar

Small title bar

All credits go to the folks from these links: