Category Archives: Linux


I built PhantomJS 2.1.1 for Raspberry Pi

I built PhantomJS 2.1.1 for Raspberry Pi. It can also run on any armhf architecture machines.

I used Debian on ARM VPS on and follow this page to build it.

Please download from
( After my pull request allowed, I will edit the link on this blog to “”. )

I use Raspberry Pi as a testing machine for any server applications like web scraping. But there were no PhantomJS binaries for armhf architecture on the web. So I built it. Please use this binary, if you want. But I can not care any troubles and bugs when you use it.

< What is "PhantomJS"? >
PhantomJS is a web scraping tool with JavaScript API. It can capture web pages as PDF, PNG or some kind of picture file. If you want to know more about PhantomJS, please check

Recommendations of Webmin for Debian users

< What is “Webmin”? >
“Webmin” is a configuration tool with WEB based UI written in Perl. It can run on Linux / UNIX / Windows / OSX. When I install Debian to my computer, I install “Webmin”. Basically I use it to edit configuration files, because I don’t need to remember where are configuration files. “Webmin” can control starting and stopping of any services. “Webmin” has so many convenient functions. But it’s too heavy for me to explain everything about it. If you want to know about “Webmin” more, please check Webmin – Wikipedia and

< Installation on Debian >
Please check latest version of webmin on Please replace the red URL to the newest one when you check the official web site. Execute the commands below as root to install webmin.

root@myhost:~# cd /tmp
root@myhost:/tmp# wget
root@myhost:/tmp# dpkg -i webmin_1.690_all.deb
root@myhost:/tmp# apt-get -f install

After the command “dpkg -i webmin_1.690_all.deb“, apt show you any warnings. After that, please execute “apt-get -f install” to install required software for webmin.

< For security >
By default configuration, webmin can be accessed only from local network. I have never changed it, because of the security. I always use SSH port transfer or any kind of VPN to use webmin from the internet. You don’t need to allow webmin to be accessed directly from the internet.

< SSH port transfer >
If your user name is “abcd” and domain is ““, SSH login with port transfer for webmin is a command line below.

$ ssh -L 10000:localhost:10000

This command line is for Linux / UNIX / OSX. You can also use IP address instead of domain.

< Login to Webmin >
Use any browser to access “https://localhost:10000/“. You will see untrusted message like below.
It is an example of Firefox. Please push “Add Exception” if you use Firefox.
First time, you need to login as root. If you don’t want to use root to login to webmin, you can add any user for webmin.

< Which language do you use? >
Default language for webmin is English. If you want to change global language setting, please check the navigation and picture below.
[ Webmin ] – [ Webmin Configuration ] – [ Language ]
You can select default language and character code for webmin user interface by the function above. If you want to change personal language or theme, please check the navigation and picture below.
[ Webmin ] – [ Change Language and Theme ]

< Webmin theme >
I want to explain how to add webmin users, but before adding webmin users, I need to explain about my webmin theme.
[ Webmin ] – [ Webmin Configuration ] – [ Webmin Themes ]
You can select themes for Webmin UI. I always use “MSC.Linux Theme“. Please choose a theme you want to use. But during following my procedure on this post, it’s easy to follow using “MSC.Linux Theme“.

< Add system user >
I always add system user before adding webmin user. Because I use UNIX login for webmin. You can add users for your operation system at the navigation below. I use this function instead of “adduser” command.
[ System ] – [ Users and Groups ] – [ Create a new user ]
I basically use default settings for new user. I only change password.

< Add Webmin user >
You can add users for webmin at the navigation below. You need to select functions of webmin to allow the user can control. I always use UNIX authentication for PASSWORD.
[ Webmin ] – [ Webmin Users ] – [ Create a new Webmin user ]
After I add webmin user, I always re-login webmin on the new user.
You can find the module list like below.
If you want to control everything like an administrator, please click “Select all” to select all functions.

< Control system and service >
[ System ] – [ Bootup and Shutdown ]
This picture shows functions on the bottom of the page.

< About Webmin modules >
When I have spare time, I will update this post or write new post about some modules for webmin.

Reverse proxy on nginx on Raspberry pi

< Ready to install >
You need Debian wheezy to follow my procedure. Not only for Raspberry Pi.

< Why I use Raspberry Pi >
Reverse proxy is simple function. Basically it’s too easy task for general personal computers or any servers. Raspberry Pi is not so powerful, but it’s energy saving computer. It’s not expensive. Anyone can buy it all over the world. It’s enough for reverse proxy on nginx. That’s why I choose Raspberry Pi for reverse proxy server and wrote this post.

< Installing nginx >
Execute command below as root.

apt-get install nginx

That’s all.

< Edit config file >
Edit default config file.

nano /etc/nginx/sites-available/default

My “/etc/nginx/sites-available/default” is like below.

server {
listen 80;

location / {

This config transfer accesses “” to 8080 port of local Apache server on Raspberry Pi.

< Add proxy config file >
Add a file for proxy settings.

nano /etc/nginx/conf.d/proxy.conf

My “/etc/nginx/conf.d/proxy.conf” is like blow.

# Header
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# Timeout
proxy_connect_timeout 60;
proxy_read_timeout 90;
proxy_send_timeout 60;

# Buffer
proxy_buffering on;
proxy_buffer_size 8k;
proxy_buffers 100 8k;

# Cache
proxy_cache_path /var/cache/nginx/ levels=1:2 keys_zone=cache_$
proxy_temp_path /var/cache/nginx/temp;

proxy_cache_valid 200 2h;
proxy_cache_valid 302 2h;
proxy_cache_valid 301 4h;
proxy_cache_valid any 1m;

Also you need to make cache dir as root.

mkdir /var/cache/nginx

< Start nginx >

service nginx start

How you think about this procedure? So easy?

bochs on Raspberry Pi

< x86 on ARM >
I try to run DOS on Debian wheezy on Raspberry Pi.
( Windows95 is also possible, but it’s too slow )

< Install “bochs” >
Installing “bochs” is very easy.
Command line is as below.

root@myhost:~# apt-get install bochs bochs-x bochs-sdl bochs-svga

< Generate hard disk image >
Execute “bximage” on your Raspberry Pi.
I recommend to execute “bximage” as non-root user.
You should execute “bximage” as a user which use “bochs”.
It’s 2GB image sample.

$ bximage
                  Disk Image Creation Tool for Bochs
        $Id: bximage.c,v 1.34 2009/04/14 09:45:22 sshwarts Exp $
Do you want to create a floppy disk image or a hard disk image?
Please type hd or fd. [hd]
What kind of image should I create?
Please type flat, sparse or growing. [flat]
Enter the hard disk size in megabytes, between 1 and 129023
I will create a ‘flat’ hard disk image with
  sectors per track=63
  total sectors=4194288
  total size=2047.99 megabytes
What should I name the image?
Writing: [] Done.
I wrote 2147475456 bytes to msdoshdd.img.
The following line should appear in your bochsrc:
ata0-master: type=disk, path=”msdoshdd.img”, mode=flat, cylinders=4161, heads=16, spt=63

“bximage” said to add line “
ata0-master: type=disk, path=”msdoshdd.img”, mode=flat, cylinders=4161, heads=16, spt=63” to “.bochsrc”.

< Generate “.bochsrc” for MS-DOS >
Go to your home directory.
I use “nano” to edit text files.

$ cd /home/username
$ nano .bochsrc

My “.bochsrc” is as below.

megs: 64
romimage: file=$BXSHARE/BIOS-bochs-latest
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
display_library: sdl
ata0-master: type=disk, path=/home/username/msdoshdd.img, mode=flat, cylinders=4161, heads=16, spt=63
ata0-slave: type=cdrom, path=/home/username/MS-DOS-6.22.iso, status=inserted
boot: cdrom, disk
#keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/
log: bochsout.txt
clock: sync=realtime, time0=local

“MS-DOS-6.22.iso” is my MS-DOS bootable file. Please replace it to any iso bootable file you have. In my “.bochsrc”, mouse is unavailable. If you want to use mouse, please google about “How to edit bochsrc to use mouse”.

< Install VNC >
If you use HDMI display, you don’t need this step.
If you don’t use display, you need to install VNC server to remote X on Raspberry Pi.
Execute this command line as root.

root@myhost:~# apt-get install tightvncserver

Run this command line as a user which use “bochs”.

$ vncserver :1 -geometry 1024×768 -depth 24
You will require a password to access your desktops.
Would you like to enter a view-only password (y/n)? 
New ‘X’ desktop is myhost:1

“:1″ means port “5901″.
“-geometry 1024×768″ means resolution.
“-depth 24″ means colors in bits.

< Execute bochs >
Please connect your VNC server on Raspberry Pi. ( or use “startx” with HDMI display )
And execute terminal. ( ex. LXTerminal )
Execute bochs on terminal.

$ bochs

Sometimes bochs ask you like this syntax.

A PANIC has occurred.  Do you want to:
  cont       – continue execution
  alwayscont – continue execution, and don’t ask again.
               This affects only PANIC events from device [MEM0 ]
  die        – stop execution now
  abort      – dump core
  debug      – hand control to gdb

I always answer “alwayscont”.

< To be honest >
I tried to install Windows95.
But it needs FD images of DOS and Windows3.1. ( My Windows95 is upgrade version )
It was troublesome for me.
So I changed my goal.

Install Debian wheezy to LS-XHL

< Warning >
I can guarantee nothing about your troubles that happen to your hardware or data by following my procedure on this page. Please perform the procedure at your own risk.

< What is “LS-XHL”? >
It is a kind of NAS ( Network Attached Storage – Wikipedia ) made by Buffalo(Japanese company).
You can find similar NAS on Amazon by searching “linkstation”.
We can install Debian on it.
( Maybe “LS-XHL” is too old to buy new one, you can buy only used one. )

< I installed Debian wheezy to “LS-XHL” >
I wrote down about the procedure to install Debian wheezy to “LS-XHL”.
Basically I follow” (Japanese page) and
Buffalo NAS-Central Forums • View topic – LS-CHLv2 – LS-XHL – Debian Wheezy Rootfs – Update 2013.05.15” (English page).
If you want to understand or read more, please read these pages or google any keywords about them.

< Things you need >
1. LS-XHL ( LS-VL is similar to LS-XHL, maybe only network setting is different. )
2. Debian Wheezy Rootfs ( )
3. Debian or Ubuntu machine ( I recommend ARM CPU machine. But maybe non-ARM is possible. )
4. USB-HDD Case ( You need it to temporarily connect to Linux machine. If it’s possible, internal SATA or any kind of connections are OK. )

I wrote the procedures of ARM and non-ARM as same as possible, but some procedures are different. I checked only on ARM machine. Please be careful.

< Something like traps >
1. When I use “Gparted” for partitioning, LS-XHL didn’t boot. ( “parted” is OK. )
2. “chroot” for this rootfs is only available on ARM machine.

< STEP 1 – Disassemble LS-XHL >
I found the good video on Youtube. Please follow this.

( Maybe disassembling LS-VL is the same. )
Its plastic part is really easy to break, please be careful not to break when you open it.

Even if you break some part, maybe it can work. Don’t worry so much.
Because I break many plastic part of my LS-XHL haha…

< STEP 2 – Partitioning and formatting HDD >
Boot your Linux machine. ( I used Debian wheezy on Raspberry Pi. )
Login the Linux machine as root.
If your machine doesn’t have “parted”, please install “parted”.
If your Linux is Debian or Ubuntu, execute this command line.

apt-get install parted

Next, connect your new HDD(for LS-XHL) to this Linux machine by USB or any kind of connections.
And check information of HDD. If your HDD is on “/dev/sda”, execute this command line.

parted /dev/sda print

In my case, it showed like this.

Model: ATA Hitachi HDS72202 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/512B

Important word is “2000GB” in line “Disk /dev/sda: 2000GB”. Please remember the same part of your HDD.

Make partitions.

parted /dev/sda mklabel gpt
parted -a cylinder /dev/sda mkpart primary 0 511
parted -a cylinder /dev/sda mkpart primary 511 8191
parted -a cylinder /dev/sda mkpart primary 8191 9215
parted -a cylinder /dev/sda mkpart primary 9215 2000G
parted /dev/sda set 1 boot on

This is my sample.
I was thinking to use
“/dev/sda1″ for “/boot”,
“/dev/sda2″ for “/”,
“/dev/sda3″ for swap,
“/dev/sda4″ for “/home”.
You need to change “2000G” of the line “parted -a cylinder /dev/sda mkpart primary 9215 2000G”.
Also you can change the each partition size.

Format partitions.

mke2fs -I 128 -j /dev/sda1
mke2fs -j -t ext4 /dev/sda2
mkswap /dev/sda3
mke2fs -j -t ext4 /dev/sda4

Mount partitions to expand Rootfs.

mount /dev/sda2 /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot

< STEP 3 – Expand Rootfs >
Goto temporary folder like “/tmp”.
And get “debian_wheezy_rootfs_lschlv2-lsxhl_20130515.tar.xz” from

cd /tmp

Expand it to “/mnt”.

tar Jxvf debian_wheezy_rootfs_lschlv2-lsxhl_20130515.tar.xz -C /mnt

Download “uImage.buffalo.3.9.2-fjen-1.lsxhl” to “/mnt/boot”.

cd /mnt/boot

< STEP 4 – Update settings >
Please update these five files.

This is my “/mnt/etc/fstab”.

/dev/sda1       /boot         ext3     noauto,noatime         1 2
/dev/sda2       /             ext4     noatime                0 1
/dev/sda3       none          swap     sw                     0 0
/dev/sda4       /home         ext4     noatime                0 0
proc            /proc         proc     defaults               0 0
shm             /dev/shm      tmpfs    nodev,nosuid,noexec    0 0
devpts          /dev/pts      devpts   gid=4,mode=620         0 0
#tmpfs           /tmp          tmpfs    defaults               0 0
sysfs           /sys          sysfs    defaults               0 0

This is my “/mnt/etc/network/interfaces”.

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static

If you use “LS-VL”, it doesn’t have “eth1″.
Maybe “/mnt/etc/network/interfaces” is like this.

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static

( These are just samples. Please set correct values for your own network. )

This is my “/mnt/etc/resolv.conf”.

domain linkstation
search linkstation

Lines “domain linkstation” and “search linkstation” are not necessary.

My “/mnt/etc/hostname” is “linkstation”.
I didn’t update “/mnt/etc/hosts”.
But you can change them, if you want.

< STEP 5 – chroot >
Using chroot, but it’s only available on the same architecture. ( In this case, it’s ARM architecture. )

chroot /mnt

If you don’t have ARM machine or fail to “chroot”, goto STEP 6.
If your “chroot” is succeeded, follow this way.

cd /boot
mv uImage.buffalo uImage.buffalo.bk
ln -s uImage.buffalo.3.9.2-fjen-1.lsxhl uImage.buffalo

< STEP 6 – If you can’t “chroot” >
( I didn’t test this STEP of procedure, be careful. And I recommend to google some information about this. )

cd /mnt/boot
mv uImage.buffalo uImage.buffalo.bk
mv uImage.buffalo.3.9.2-fjen-1.lsxhl uImage.buffalo

< STEP 7 – Basic settings >
Insert HDD to LS-XHL and boot it. When you do this, I recommend not to drive a screw and not to shut the lid. Ready to re-install Debian, if you fail the install.

Connect “″(It’s my example) by SSH.
Default root password is “toor”.

ssh root@

( It’s Linux/UNIX example. )

Follow these commands after logged in.

dpkg-reconfigure locales
dpkg-reconfigure tzdata
rm /etc/ssh/ssh_host_* && dpkg-reconfigure openssh-server

These lines mean
1. Reset root password
2. Update your locale
3. Update your time zone
4. Update SSH key
You need logout SSH to update SSH key in SSH client.
If you use SSH on Linux/UNIX, follow this command to update client SSH key.

ssh-keygen -R

After that, re-login as root and execute “apt-get”.

apt-get update
apt-get upgrade

It’s now complete.
Please drive a screw and shut the lid.
Good luck!

< Thanks >
Thanks a lot to a person who compiled “Debian Wheezy Rootfs”, people on and a person who wrote
You have made my installation a lot easier! Thank you!