VirtualBox – convert RAW image to VDI and otherwise
Let’s assume that we have raw image of the sdb device:
# dd if=/dev/sdb of=./sdb.raw
To use it with VirtualBox we need to convert it:
$ VBoxManage convertdd sdb.raw sdb.vdi --format VDI
To get back raw image ater modifications we need to perform two steps as there is no buitin direct conversion. Convert image to VMDK format first:
$ VBoxManage clonehd sdb.vdi sdb.vmdk --format VMDK
Then we need to use command from qemu package so we can finally convert VMDK to raw image:
$ qemu-img convert -f vmdk sdb.vmdk -O raw sdb.raw
Now we can write image to the device:
# dd if=./sdb.raw of=/dev/sdb
Ubiquiti AirOS 5.5 – How to set management VLAN
First step
Login to device as an administrator user.
Second step
Select Network tab.
Third step
Change Configuration mode from Simple to Advanced.
Click Change button.
Fourth step
Add desired VLAN to LAN and WLAN interfaces.
Click Change button.
Fifth step
Create new bridge and add earlier defined VLAN interfaces to it.
Click Change button.
Sixth step
Change Management Interface to earlier created bridge and adjust network settings.
Click Change button.
Seventh step
Apply or test changes on the top of the page.
Dell Inspiron 14z – Shortcut buttons
Dell Inspiron 14z (N411z) has three small shortcut buttons above the keyboard.
First button
First one with small gears on it can be used out of the box in KDE or GNOME.
xev output:
KeyPress event, serial 35, synthetic NO, window 0x6000001,
root 0xb1, subw 0x0, time 137282557, (-94,112), root:(1047,135),
state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 35, synthetic NO, window 0x6000001,
root 0xb1, subw 0x0, time 137282558, (-94,112), root:(1047,135),
state 0x40, keycode 53 (keysym 0x78, x), same_screen YES,
XLookupString gives 1 bytes: (78) "x"
XmbLookupString gives 1 bytes: (78) "x"
XFilterEvent returns: False
KeyRelease event, serial 35, synthetic NO, window 0x6000001,
root 0xb1, subw 0x0, time 137282560, (-94,112), root:(1047,135),
state 0x40, keycode 53 (keysym 0x78, x), same_screen YES,
XLookupString gives 1 bytes: (78) "x"
XFilterEvent returns: False
KeyRelease event, serial 35, synthetic NO, window 0x6000001,
root 0xb1, subw 0x0, time 137282563, (-94,112), root:(1047,135),
state 0x40, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: FalseSecond button
Second button with a small wrench on it does not work.
I tried xev, showkey, evtest and messed around with the source code but without any success.
I lost all hope here.
Third button – this is where adventure begins
Third one with a small star on it needs a little work to be usable.
dmesg output shows:
atkbd serio0: Unknown key pressed (translated set 2, code 0x60 on isa0060/serio0). atkbd serio0: Use 'setkeycodes 60 <keycode>' to make it known.
Execute as root in console (use /etc/rc.local file for persistent change):
# setkeycodes 60 222
Now showkey shows key press:
# showkey kb mode was UNICODE [ if you are trying this under X, it might not work since the X server is also reading /dev/console ] press any key (program terminates 10s after last keypress)... keycode 28 release keycode 222 press
evtest shows value 1 after pressing it first time, value 2 afterwards:
Event: time 1331065738.017054, -------------- SYN_REPORT ------------ Event: time 1331065748.872962, type 4 (EV_MSC), code 4 (MSC_SCAN), value 60 Event: time 1331065748.872988, type 1 (EV_KEY), code 222 (KEY_ALTERASE), value 1 Event: time 1331065748.872990, -------------- SYN_REPORT ------------ Event: time 1331065750.573239, type 4 (EV_MSC), code 4 (MSC_SCAN), value 60 Event: time 1331065750.573260, type 1 (EV_KEY), code 222 (KEY_ALTERASE), value 2 Event: time 1331065750.573262, -------------- SYN_REPORT ------------
To use this button you need to modify xserver-xorg-input-evdev package so create build directory and grab the source code:
$ mkdir ~/build $ cd ~/build $ apt-get source xserver-xorg-input-evdev
Directory listing:
$ ls xserver-xorg-input-evdev-2.6.0 xserver-xorg-input-evdev_2.6.0-1ubuntu13.diff.gz xserver-xorg-input-evdev_2.6.0-1ubuntu13.dsc xserver-xorg-input-evdev_2.6.0.orig.tar.gz
Directory xserver-xorg-input-evdev-2.6.0 can be safely deleted:
$ rm -rf xserver-xorg-input-evdev-2.6.0
Now save patch as evdev.patch file:
--- xserver-xorg-input-evdev-2.6.0.orig/src/evdev.c +++ xserver-xorg-input-evdev-2.6.0/src/evdev.c @@ -908,6 +908,18 @@ } + +static void +EvdevEmulateKey(InputInfoPtr pInfo, struct input_event *ev, int key, int state) +{ + ev->type = EV_KEY; + ev->code = key; + ev->value = state; + EvdevQueueKbdEvent(pInfo, ev, state); +} + + + /** * Process the events from the device; nothing is actually posted to the server * until an EV_SYN event is received. @@ -923,7 +935,14 @@ EvdevProcessAbsoluteMotionEvent(pInfo, ev); break; case EV_KEY: - EvdevProcessKeyEvent(pInfo, ev); + if (ev->code == 222) { + EvdevEmulateKey(pInfo, ev, KEY_LEFTCTRL, 1); + EvdevEmulateKey(pInfo, ev, KEY_O, 1); + EvdevEmulateKey(pInfo, ev, KEY_O, 0); + EvdevEmulateKey(pInfo, ev, KEY_LEFTCTRL, 0); + } else { + EvdevProcessKeyEvent(pInfo, ev); + } break; case EV_SYN: EvdevProcessSyncEvent(pInfo, ev);
This solution is directly taken from maxter-plus-linux (Patched evdev driver supporting Elmak Maxter Plus remote control) by dgolda.
I used CTRL+O as an emulated shortcut after pressing button so it is clear how to define own key presses and releases.
Compress it and add to other patches (as an alternative you can check
$ gzip evdev.patch $ cat evdev.patch.gz >> xserver-xorg-input-evdev_2.6.0-1ubuntu13.diff.gz
Prepare source code:
$ dpkg-source --no-check -x xserver-xorg-input-evdev_2.6.0-1ubuntu13.dsc dpkg-source: info: extracting xserver-xorg-input-evdev in xserver-xorg-input-evdev-2.6.0 dpkg-source: info: unpacking xserver-xorg-input-evdev_2.6.0.orig.tar.gz dpkg-source: info: applying xserver-xorg-input-evdev_2.6.0-1ubuntu13.diff.gz dpkg-source: info: upstream files that have been modified: xserver-xorg-input-evdev-2.6.0/autogen.sh xserver-xorg-input-evdev-2.6.0/src/evdev.c
Enter xserver-xorg-input-evdev-2.6.0 directory:
$ cd xserver-xorg-input-evdev-2.6.0
Build package:
$ dpkg-buildpackage -rfakeroot
Install package:
$ cd .. $ ls *.deb xserver-xorg-input-evdev_2.6.0-1ubuntu13_amd64.deb xserver-xorg-input-evdev-dev_2.6.0-1ubuntu13_all.deb $ sudo dpkg -i xserver-xorg-input-evdev_2.6.0-1ubuntu13_amd64.deb
Restart X server and check button. For testing purposes it is good idea to use xf86Msg function and monitor Xorg log in realtime.
How to use recent version of Wine in Ubuntu
From time to time I use Wine to play some Good Old Games but I experienced annoying problems while using touchpad when tried to play on notebook. Solution was to install recent version from Latest official WineHQ releases.
To do this add PPA repository and update package index:
$ sudo add-apt-repository ppa:ubuntu-wine/ppa $ sudo apt-get update
Check for package name:
$ aptitude search "?origin(LP-PPA-ubuntu-wine)" p wine1.3 - Microsoft Windows Compatibility Layer (Binary Emulator and Library) p wine1.3-dbg - Microsoft Windows Compatibility Layer (debugging symbols) p wine1.3-dev - Microsoft Windows Compatibility Layer (Development files) p wine1.3-gecko - Microsoft Windows Compatibility Layer (Web Browser)
Install it using command:
$ sudo apt-get install wine1.3
Collabtive – web-based project management software
Couple days ago installed Collabtive to manage my small projects in one place.
It is a PHP based solution with nice user interface that ideally fits my needs as it offers:
- Multiple projects
- Milestones
- Task lists
- File management
- Time tracker
How to quickly download or upload directory tree over FTP
The fastest way to download or upload directory tree over FTP using just plain console is to execute
lftp is a sophisticated file transfer program which supports protocols like ftp/s, http/s, hftp, fish, sftp and torrent. It is a good idea to install this tool as it can be very handy at times.
To upload local directory local_dir to remote remote_dir on hostname execute:
$ lftp -u username,password -e "mirror -R local_dir /remote_dir;quit" ftp://hostname Total: 1 directory, 3 files, 0 symlinks New: 3 files, 0 symlinks 20071573 bytes transferred in 162 seconds (121.8K/s)
To see contents of remote directory remote_dir on hostname execute:
$ lftp -u username,password -e "ls /remote_dir;quit" ftp://hostname total 19612 -rw-r--r-- 1 nobody nogroup 15568717 Feb 25 23:29 eGroupware.zip -rw-r--r-- 1 nobody nogroup 113942 Feb 25 23:29 eGroupware-egw-pear.zip -rw-r--r-- 1 nobody nogroup 4388914 Feb 25 23:30 wordpress.zip
To download remote directory remote_dir on hostname to local local_dir execute:
$ lftp -u username,password -e "mirror /remote_dir local_dir;quit" ftp://hostname Total: 1 directory, 3 files, 0 symlinks New: 3 files, 0 symlinks 20071573 bytes transferred in 20 seconds (981.0K/s)
Don’t forget to read manual as there are couple of useful options (like downloading/uploading files in parallel).
Write your own book online using Booktype
I recently read an article about Booktype, got interested and tried software myself.
Booktype is developed by Sourcefabric, a non profit organization that provides couple of other interesting solutions like Airtime (radio automation), Newscoop (content management system) and Superdesk which combines Airtime with Newscoop as a suite for independent media.
Booktype uses Django web framework. Software is easy to install but you can’t forget about
Interface is simple and readable built with collaboration in mind. Each book has its own history, custom versions and permissions. Books are written in HTML using TinyMCE editor and can be exported to PDF, ODT, EPUB and MOBI format.
How to integrate Roundcube Webmail with ISPConfig 3
To integrate Roundcube with ISPConfig 3 read requirements and follow installation instructions.
Procedure is quick and simple as it contains following steps:
- Create remote user
- Install plugins
- Configure account plugin
- Activate desired plugins in Roundcube
For full details visit bugs.web-wack.at
Ubuntu and recent problems related to PHP
Recently I run into small problems related to PHP.
Problem A – sqlite.so
First one was PHP warning:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/sqlite.so' - /usr/lib/php5/20090626/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP tried to load sqlite.so from /etc/php5/conf.d/sqlite.ini (php5-sqlite package).
$ dpkg -L php5-sqlite /. /etc /etc/php5 /etc/php5/conf.d /etc/php5/conf.d/sqlite3.ini /etc/php5/conf.d/pdo_sqlite.ini /etc/php5/conf.d/sqlite.ini /usr /usr/share /usr/share/doc /usr/lib /usr/lib/php5 /usr/lib/php5/20090626 /usr/lib/php5/20090626/pdo_sqlite.so /usr/lib/php5/20090626/sqlite3.so /usr/share/doc/php5-sqlite
As suspected there was sqlite3.so file.
$ ls /usr/lib/php5/20090626/ curl.so gd.so mysqli.so mysql.so pdo_mysql.so pdo.so pdo_sqlite.so sqlite3.so
To solve this problem just delete /etc/php5/conf.d/sqlite.ini file.
$ sudo rm /etc/php5/conf.d/sqlite.ini
Problem B – fuser process
Second problem was more serious. Thousands of fuser zombie processes and funny CPU usage.
Hopefully there is a bug report #876387 so for solution look at fourth comment. Don’t forget to identify and kill already running find processes.
In short this problem can be quickly recognized by thousands of fuser zombie processes:
$ ps ax | awk '{if ($3=="Z" && $5~/fuser/) s++}; END {print s}'
21613It was created by php cron job /etc/cron.d/php5 (php5-common package):
$ dpkg -S /etc/cron.d/php5 php5-common: /etc/cron.d/php5
Source of this problem in /etc/cron.d/php5 file:
09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -deleteTo solve it replace this line with one given below:
09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete
Don’t forget to kill running find processes:
# ps ax | grep "find /var/lib/php" | grep fuser | awk '{print $1}' | xargs kill




































