Pages

Monday, 10 December 2012

PIL jpeg support on 64 bit Precise

If you have problems with installing PIL, look at this site
In short:
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/

Sunday, 9 December 2012

My First Android App

Yesterday, I decided to keep up with the rest of the world in some ways, so I bought a Samsung Galaxy ACE smartphone. I know, it is not a really high-end stuff, according to the current state of the smartphone market. Anyhow, I think it is a great value for 85 pounds, with a pay as you go contract. I am really impressed by this phone, and I decided, to develop a hello world application. So, I first downloaded the Android SDK. As I extracted the tar.gz, the Readme file told me how to carry on with the installation. So I followed the instructions, first with the UI:
tools/android update sdk
With the UI, I selected to install:
  • Android SDK Tools
  • Android SDK Platform-tools
  • For Android 2.3.3
    • SDK Platform
    • Samples for SDK
After the process finished, the log window had a warning:
Stopping ADB server failed (code -1).
I will ignore it for now. The whole stuff is consuming around 307 megs at the moment.
cd tools
./android list targets
And I created a project:
./android create project --target "android-10" --name HelloWorldApp \
--path ~/Documents/android/workspace/HelloWorldApp \
--activity MainActivity --package eu.lakat.example.helloworldapp
Let's go back to the "root":
cd ..
I created a small script, to include all the paths in one shot:
export PATH=$PATH:"$(pwd)/android-sdk-linux/tools/":"$(pwd)/android-sdk-linux/platform-tools/"
Changed the directory to the applications:
cd workspace/HelloWorldApp/
Compiled it to debug:
ant debug
And installed it on my device:
adb install bin/HelloWorldApp-debug.apk
Everything worked perfectly fine, I found the app in my device, and was able to run that easily. Cool!

Virtual device

android avd
Use th UI to create a new device, and simply execute:
adb install bin/HelloWorldApp-debug.apk

Monday, 3 December 2012

NFS installation

So I decided to put an NFS server to my DreamPlug. First, an easy step:
apt-get --no-install-recommends install nfs-kernel-server
Let's see what do I have:
root@plugged:~# lsmod | grep nfs
nfsd                  243695  11 
exportfs                3108  1 nfsd
So, next step is to export a directory. I would like to create a read-only export.
cat /etc/exports
/mnt/md2        192.168.0.2(ro,no_subtree_check)
TODO: Some security Okay, so let's restart the nfs server:
/etc/init.d/nfs-kernel-server stop
/etc/init.d/nfs-kernel-server start
Install the client on the other machine:
sudo apt-get --no-install-recommends install nfs-common
And mount the export:
sudo mount 192.168.0.4:/mnt/md2 /mnt/md2
It does not seem to perform very well. For example, from the client, through wifi:
time ls -la /mnt/md2/1/ > /dev/null
Gives
real 1m18.605s
user 0m0.560s
sys 0m2.632s
Whereas running the same stuff on the DreamPlug:
real 0m2.572s
user 0m1.650s
sys 0m0.920s
And that's fast. Let's try to dd some files.
dd if=/mnt/md2/1/ffc4f5bc7f6b78ac371f3ecebdd9701e4cb8c68f of=/dev/null
Gives:
577409024 bytes (577 MB) copied, 103.255 s, 5.6 MB/s
And what is the raw speed? On the server:
nc -l -p 4545 -q 1 < /mnt/md2/1/ffc4f5bc7f6b78ac371f3ecebdd9701e4cb8c68f
On the client:
nc 192.168.0.4 4545 | dd of=/dev/null
And the results:
577409024 bytes (577 MB) copied, 103.84 s, 5.6 MB/s
So nfs gives almost no overhead. (Please note, that the 1 sec was the waiting time added by the netcat server. That's negligable.) Let's see the same thing locally on the server:
dd if=/mnt/md2/1/ffc4f5bc7f6b78ac371f3ecebdd9701e4cb8c68f of=/dev/null
Result:
577409024 bytes (577 MB) copied, 19.4105 s, 29.7 MB/s
NFS over a gigabit connection (after umount-mount, to clear the cache):
577409024 bytes (577 MB) copied, 24.6491 s, 23.4 MB/s
Without NFS (nc way):
577409024 bytes (577 MB) copied, 20.9865 s, 27.5 MB/s
So yes, NFS has some overhead at these rates.

Friday, 30 November 2012

MDADM: start raid1 array with one device

When I was home, I copied a lot of pictures to a raid array. As I moved back, I brought only one disk with me. Now, I would like to access the data on that drive, in a read-only fashion.
sudo mdadm --assemble /dev/md0 /dev/sdb1
This printed out the following:
mdadm: /dev/md0 assembled from 1 drive - need all 2 to start it (use --run to insist).
Let's see the status:
cat /proc/mdstat
Gives me:
md0 : inactive sdb1[1](S)
      625129216 blocks
Okay, so this array definitely needs activation. I decided to run this array:
sudo mdadm --run /dev/md0
And now, let's see the status:
cat /proc/mdstat
It seems, that the device is now active.
md0 : active raid1 sdb1[1]
      625129216 blocks [2/1] [_U]
I expected to see a read only mode, and it is a bit annoying, that it seems that it is not r/o. Now, I try to set it to read-only:
sudo mdadm --readonly /dev/md0
And now, it seems better:
cat /proc/mdstat
shows:
md0 : active (read-only) raid1 sdb1[1]
      625129216 blocks [2/1] [_U]
And now, it is time to mount it!
sudo mount --read-only /dev/md0 /mnt/p1
The good stuff, is that I managed to mount it, and hopefully, as I put it back to its original place, it will still be fine.
sudo mdadm --detail /dev/md0
See the "Update Time" (which is exactly the date, when I last accessed the array)
/dev/md0:
        Version : 0.90
  Creation Time : Wed Nov 21 22:52:49 2012
     Raid Level : raid1
     Array Size : 625129216 (596.17 GiB 640.13 GB)
  Used Dev Size : 625129216 (596.17 GiB 640.13 GB)
   Raid Devices : 2
  Total Devices : 1
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Thu Nov 22 07:10:02 2012
          State : clean, degraded 
 Active Devices : 1
Working Devices : 1
 Failed Devices : 0
  Spare Devices : 0

           UUID : 9d82c2e5:33bd53b5:e4d1075c:94619d7b
         Events : 0.40

    Number   Major   Minor   RaidDevice State
       0       0        0        0      removed
       1       8       17        1      active sync   /dev/sdb1

Monday, 19 November 2012

syrep

I always forgot the name of the tool, that I used to sync directory structures. So here is the name and the URL:

SYREP

Sunday, 11 November 2012

Dreamplug - overwrite the internal SD card

ssh 192.168.0.4 mkfs.ext3 /dev/sda2
ssh 192.168.0.4 mount /dev/sda1 /mnt/sda1
ssh 192.168.0.4 mount /dev/sda2 /mnt/sda2
sudo kpartx -av debian.phase2.img
sudo mount /dev/mapper/loop0p2 p2
cd p2
sudo tar -czf - . | ssh 192.168.0.4 "cd /mnt/sda2 && tar -xzf -"
cd ..
sudo umount p2
sudo mount /dev/mapper/loop0p1 p1
scp p1/uImage 192.168.0.4:/mnt/sda1/uImage2
sudo umount p1
ssh 192.168.0.4 sync
Reboot the plug, and go to uBoot. Remove all USB drives.
setenv x_bootcmd_kernel fatload usb 0 0x6400000 uImage2
setenv x_bootargs_root root=/dev/sda2 rootdelay=10 panic=10
saveenv
Extract the libs:
mkdir libs
cd libs/
sudo tar -xzf ../sda2.tgz
cd lib/modules
sudo tar -czf - . | ssh 192.168.0.4 "cd /lib/modules && tar -xzf -"

Dreamplug - post setup

Some notes on what I did to the installed debian: - /etc/default/locale
LANG="C"
- /etc/hostname - /etc/apt/sources.list
deb http://mirrors.kernel.org/debian squeeze main contrib non-free
deb http://security.debian.org squeeze/updates main contrib non-free
- /etc/network/interfaces
auto lo eth1

iface lo inet loopback
iface eth1 inet dhcp
- start network
dhclient eth1
- update
apt-get update
apt-get upgrade
- install openssh
apt-get --no-install-recommends install openssh-server