FreeBSD: no booting GPT slices with buggy bios laptops

It seems there is a problem with some bios that refuse to boot when the disk is partitioned with GPT. My laptop is a Lenovo T420s and FreeBSD (indeed PCBSD) is installed in second disk (ultrabay), gpt style partitions and the following partitions:

1) bios boot

2) freebsd-zfs

3) freebsd-swap

Other Lenovo models as T420, T520 or E520 seem to be affected too.

I found a solution in this post:


Basically booting from other disk or a live cd/usb is needed in order to be able to modify the protective MBR in the disk. I have another freebsd in /dev/ada0, so I booted from it.

After booting from other OS, then dump the protective MBR in the freebsd disk with want to ‘fix’:

fdisk -p ada1 > ada1.txt

This file contains:

cat ada1.txt

# /dev/ada1
g c7752336 h1 s63
p 1 0xee 1 488397167

Then I modified ada1.txt as follows:

# /dev/ada1
g c7752336 h1 s63
p 1 0x00 1 488397167
a 1
p 2 0xee 1 488397167

Next, install this MBR to the disk:

fdisk -f ada1.txt    /dev/ada1


Finally reboot and cross fingers.


Posted in BSD, FreeBSD | Leave a comment

FreeBSD: Replace syscons with vt and get compositing working in KDE after suspend/resume

In my case it was necessary to recompile a kernel with the following options:

#device vga # VGA video card driver
#device splash # Splash screen and screen saver support
# syscons is the default console driver, resembling an SCO console
#device sc
#options SC_PIXEL_MODE # add support for the raster text mode
device vt
device vt_vga

Next, in /boot/loader.conf:


and in /etc/rc.conf:


I modified as well the rc.suspend/rc.resume scripts to be able to get compositing working in KDE after resume (in KDE with integrated intel video, after resume KDE menus and are displayed as black frames). The trick consist of going to console (vt) before suspend and go to graphics after resume (when all other tasks are done).

So in /etc/rc.suspend:

#go to console before suspend
vidcontrol -s 1 < /dev/console &

/usr/bin/logger -t $subsystem suspend at `/bin/date +'%Y%m%d %H:%M:%S'`
/bin/sync && /bin/sync && /bin/sync
/bin/sleep 3

and in /etc/rc.resume:

/usr/bin/logger -t $subsystem resumed at `/bin/date +'%Y%m%d %H:%M:%S'`
/bin/sync && /bin/sync && /bin/sync

#go to graphic
vidcontrol -s 9 < /dev/console &

exit 0
Posted in Uncategorized | Tagged , | Leave a comment


Sometimes, when installing some python module with pip or easy_install the following error arises:


[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed

In FreeBSD 10.1 it can be quickly fixed doing:

pkg install ca_root_nss-3.17.3_1

ln -s /usr/local/share/certs/ca-root-nss.crt /etc/ssl/cert.pem

Posted in BSD, FreeBSD | 1 Comment

FreeBSD: Calibre Patch for Sony Ebook Reader PRS-T3

Probably this patch works for others ebook readers, but only has been tested with Sony PRS-T3.

There is a thread about a hacking Calibre for a Kobo Aura HD in:

but this method didn’t work with my device.

My solution is to modify this file:


with the following patch:

Unfortunately, Calibre in FreeBSD rarely is able to unmount the device (mine is mounted as /media/Calibre-READER). This produce a failure mounting the PRS-T3 next time it’s attached. My ugly solution is to add a rule to devd.conf to umount the device and delete the mount point directory in order to prepare a clean mounting next time the device is attached.

So, add the following rule to /etc/devd.conf:

notify 100 {
        match “system”          “USB”;
        match “subsystem”       “DEVICE”;
        match “type”            “DETACH”;
        match “vendor”          “0x054c”;
        match “product”         “0x05c2”;
        #match “release”         “0x0100”;
        action  “logger Unmount vendor:$vendor product:$product ; /sbin/umount -f /media/Calibre* ; rm -fR /media/Calibre*”;

Obviosly, replace vendor and product if needed.

Then restart devd and test it.

/etc/devd restart

If someone finds out a more elegant way to mount/umount a Sony PRS-T1/2/3 in Calibre, please, let me know.

Posted in BSD, FreeBSD | Leave a comment

FreeBSD: NFS automount with AutoFS

This applies only to FreeBSD 10.1 and newer. Previous FreeBSD releases must use amd.

Personally, I dislike ‘amd’. Its configuration is a bit complex. Autofs configuration is pretty simple.

I want to automount 2 folders from my ReadyNas Duo:

First, enable autofs:



Next, edit /etc/auto_master pointing to the map file with the folders to automount:


/mnt/nas        /etc/auto.nas

Take note ‘/mnt/nas’ is the point where the folders will be mounted.

Then create a file with the map:


media -intr,nfsv3
backup -intr,nfsv3

Finally start autofs:

service start automount

service start automountd

service start autounmountd

In a terminal or file browser go to /mnt/nas/media and /mnt/nas/backup to check if autofs works.

Posted in BSD, FreeBSD | Leave a comment

OpenBSD: phpMyAdmin and NGINX

We will suppose MySQL is already installed.

# pkg_add php-fpm php-mysql phpmyadmin

 In /etc/rc.conf.local:

pkg_scripts="mysqld php_fpm"
 # cp -fR /var/www/phpMyAdmin to /var/www/htdocs

Add to /etc/nginx/nginx.conf:

location / {
     root   /htdocs;
     index  index.html index.htm index.php;
location ~ \.php$ {
     try_files      $uri $uri/ =404;
     fastcgi_pass   unix:run/php-fpm.sock;
     fastcgi_index  index.php;
     fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
     include        fastcgi_params;
location /phpmyadmin/ {
     root   /htdocs;
     index  index.html index.htm index.php;
location ~ ^/phpmyadmin/\.php$ {
     try_files      $uri $uri/ =404;
     fastcgi_pass   unix:run/php-fpm.sock;
     fastcgi_index  index.php;
     fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
     include        fastcgi_params;

Make a file ‘/var/www/htdocs/phpinfo.php with the following lines:

php phpinfo();

Start nginx and php_fpm:

/etc/rc.d/php_fpm start
/etc/rc.d nginx start

Test the PHP installation with your browser pointing to ‘localhost/phpinfo.php’. If a page with information about your PHP installation then nginx is executing php code. If what you see is php code then nginx is serving PHP pages as plain text (review your nginx configuration).


If nginx is executing PHP code then you can try phpMyAdmin, pointing your browser to:



A good article as reference:

Posted in BSD, OpenBSD | Leave a comment

OpenBSD: connection problems with some sites in internet

I’m experiencing some problems when trying to connect, via web browser, with some sites as ebay or google. I’ve discovered that I get a better experience browsing when the MTU in the wifi interface (iwn0) is lower than 1500. So I put in /etc/hostname.iwn0:


mtu 1440 up

This is a very odd thing. MTU path discovery is permitted in my firewall configuration (icmp_types = “{ echoreq, unreach }”) and even deactivating PF the problems remain.


Posted in Uncategorized | Tagged , | Leave a comment