Install Hack font on FreeBSD 10

FreeBSD 10 comes with a pkgng package manager which allows to install binary packages faster and easier.

Unfortunately, there is no binary package available for hack-font for FreeBSD 10. What is hack-font? It’s a very good font which looks very good for source code.

Here’s how to install it from source.

Check /usr/ports/x11-fonts to see if there is a directory named hack-font. If not, you might need to download or update the ports first. If you don’t have ports installed at all, do this:

# portsnap fetch
# portsnap extract

If you already have ports install previously, but just need to run the update:

# portsnap fetch update

Then navigate to /usr/ports/x11-fonts/hack-font, run make command as the following:

# cd /usr/ports/x11-fonts/hack-font
# make install clean

That’s it. If you use portmaster command to install package from source, you probably can just run:

# portmaster x11-fonts/hack-font

Enjoy hack-(font)ing!

Puppetserver failed to start after upgrading to 2.5.0

I upraded puppetserver from 2.4.0 to 2.5.0 on a server running Centos 6.8. Then, puppetserver no longer starts.

The log (I think it was puppetsrver-daemon.log) said:

Exception in thread "main" java.lang.IllegalArgumentException: Specified bootstrap config file does not exist: '/etc/puppetlabs/puppetserver/bootstrap.cfg'

As the error reported, /etc/puppetlabs/puppetserver/bootstrap.cfg was not there. The disappearance must have happened during the puppetserver upgrade. I can confirm this by looking at my backup directory and finding the boostrap.cfg file there: /srv/backup/etc/puppetlabs/puppetserver/bootstrap.cfg.

According to this issue #1247, the boostrap.cfg file is broken into 2 files and relocated to a different directories. This issue was raised sometimes in May, and the problem only happened on my server today in August. How is that possible? This should affect more people right? So far, I haven’t seen any one reported it yet.

I need to get puppetserver running again and fast. Here is a quick fix.

Edit /etc/sysconfig/puppetserver, and make change to BOOTSTRAP_CONFIG variable:

#BOOTSTRAP_CONFIG="/etc/puppetlabs/puppetserver/bootstrap.cfg"
BOOTSTRAP_CONFIG="/etc/puppetlabs/puppetserver/services.d/,${INSTALL_DIR}/config/services.d/"

Start puppetserver and it is working again (for now).

# service puppetserver start
Starting puppetserver:                                     [  OK  ]

How to remove a user password

Sure, you Linux gurus must be laughing at me to see this post. However, this is my 2nd time needing to remove a user’s password and I had to Google for it! So here is just a quick tip to mind your truly:

# passwd -d your_username

In case you’re wondering why I need to remove a password for an account, it’s for my 4 year old daughter who enjoys playing supertuxcart. She wants to have her own user account on a Fedora 24 box without a password.

Ref: https://ask.fedoraproject.org/en/question/47102/how-to-remove-user-password/

បង្កើត RSS feeds ពី SoundCloud និង iTunes urls

ខ្ញុំ​​ចូល​ចិត្ត​ស្តាប់ ផត់ខាស់​ណាស់ ពីព្រោះវាមាន​អត្ថប្រយោជន៍​ជាច្រើន។ តើផត់ខាស​បានការអ្វី​ខ្លះ? បើសិន​ជាអ្នក​ចង់ដឹង សូម​សួរ​ក្នុង​ខំម៉ិន​ខាង​ក្រោម។

ថ្ងៃ​នេះ ខ្មុំ​ចង់ប្រាប់​របៀបបង្កើត RSS feeds ពីផត់ខាស់​ដែល​ត្រូវការ អាយធូន​ដើម្បីស្តាប់បាន។ ជាមួយ RSS feeds យើង​អាច​ប្រើ​កម្មវិធី​ផ្សេងៗ​ដូចជា អាម៉ារ៉ុក។

មុន​ដំបូង​ យើងត្រូវ​ចំលងលិង អាយធូន ហើយ​ចូល​ទៅ http://getrssfeed.com/ និង​បិទលិងនោះ។ វិបសាយ​ getrssfeed.com និង​ផ្តល់​លិងថ្មី ដែល​ជា RSS feed.

វិធីខាងលើអាច​ប្រើជាមួយ​ SoundCloud urls ផងដែរ៕

Resizing an LVM logical volume

One of the logical volumes on my desktop is running out of space. I want to add 200GB to that volume. Here is one way to achieve this task.

First a bit of warning. Don’t, or never, just copy and paste what you see here if you want to apply it to your own system. You may accidentally destroy your precious data.

# lvs
  LV      VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  backup  data   -wi-ao---- 200.00g                                                    
  scratch data   -wi-ao----   1.00t                                                    
  home    system -wi-ao----  90.00g                                                    
  root    system -wi-ao---- 100.00g                                                    
  swap    system -wi-ao----  16.00g                                                    
  tmp     system -wi-a-----   4.00g                                                    
  var     system -wi-ao----  20.00g  

Let’s check the available disk space of volume groups we can use:

# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  data     1   2   0 wz--n-   1.82t 639.01g
  system   1   5   0 wz--n- 232.38g   2.38g

I want to resize ‘scratch’, which sits on ‘data’ volume group. There are about 639GB free on ‘data’.
Let’s give ‘data’ another 200GB.

# lvresize -rL +200G /dev/data/scratch
  Size of logical volume data/scratch changed from 1.00 TiB (262144 extents) to 1.20 TiB (313344 extents).
  Logical volume scratch successfully resized.
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mapper/data-scratch is mounted on /srv/scratch; on-line resizing required
old_desc_blocks = 64, new_desc_blocks = 77
The filesystem on /dev/mapper/data-scratch is now 320864256 (4k) blocks long.

Very the change:

# lvs data
  LV      VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  backup  data   -wi-ao---- 200.00g                                                    
  scratch data   -wi-ao----   1.20t                                                     

Now ‘scratch’ has a total of 1.20TB.

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)

How to convert vdi to qcow2 image

vdi file is a type of disk image used by VirtualBox. qcow2, on the other hand, is the format of disk image used by KVM.

Recently, I want to move some existing virtual machines running on VirtualBox to KVM. To do that I need to convert the disk image from vdi to qcow2. Here’s one way to achieve that:

# qemu-img convert -f vdi -O qcow2 disk.vdi disk.qcow2

Ref: How to convert VirtualBox vid to KVM qcow2

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+.

grep: error while loading shared libraries: libpcre.so.0

I have a server running CentOS 6 successfully upgraded to CentOS 7.

The only problem I encountered so far is that ‘grep’ doesn’t work.

[root@zilla ~]# grep
grep: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
[root@zilla ~]# ldd /usr/bin/grep
        linux-vdso.so.1 =>  (0x00007ffc0b639000)
        libpcre.so.0 => not found
        libc.so.6 => /lib64/libc.so.6 (0x00007f6be1c6c000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f6be2038000)

First thing I tried was to reinstall pcre package which provides libpcre.so*. It still didn’t work. Fortunately, someone has posted a solution as the following:

[root@zilla ~]# link /usr/lib64/libpcre.so.1 /lib64/libpcre.so.0
[root@zilla ~]# grep --version
grep (GNU grep) 2.20
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others, see .

Credit: update to Centos 7; libpcre.so.0 No such file or directory

Create bootable USB Fedora 24

Every time there is a new release of Linux distro, I need to create a bootable USB. And, I forgot how I did it last time. So, I tried by using the “Startup Disk Creator” program installed on my Ubuntu workstation, only to find out that it didn’t even work.

After a while I remember, it was just a matter of using dd command to copy the ISO image to the USB.

Here is how I did it last time for Fedora 24:

My USB is showed up as /dev/sdx, and the ISO image is: Fedora-Workstation-Live-x86_64-24-1.2.iso.

$ sudo dd if=./Fedora-Workstation-Live-x86_64-24-1.2.iso of=/dev/sdx bs=8M status=progress oflag=direct
[sudo] password for kenno: 
1541406720 bytes (1.5 GB, 1.4 GiB) copied, 648.041 s, 2.4 MB/s 
183+1 records in
183+1 records out
1541406720 bytes (1.5 GB, 1.4 GiB) copied, 650.655 s, 2.4 MB/s

That’s all I had to do. A few words of warning; make sure you double check the name of USB device detected by your counter. In my case, it was /dev/sdc, but I used /dev/sdx as an example.

For more details check out https://fedoraproject.org/wiki/How_to_create_and_use_Live_USB