Saturday, December 21, 2013

3D graphics COOL slides

Let's look this nice video on 3D graphics
Here there are the very nice slide.

Sunday, May 26, 2013

Raspberry Pi NAS

I want to use my Raspberry Pi as Network Access Server in order to download file from torrent and share my hard disk with my home network. 

I have an hard disk with exfat file system. I don't use ntfs because there is an annoying bug that saturate the cpu loads (for info see this).

I download from site of Raspberry Pi the image of the Arch Linux ARM.

Install the image to the memory card

Assume that the memory card is /dev/sdc, and if mounted, umount the memory card.

In order to install the image to the SD I use the "dd" programm
$ sudo dd if=image_of_arch_linux of=/dev/sdc bs=4M

If your screen don't cover all the the TV size you can disable the overscan in the config.txt of the Raspberry
disable_overscan = 1
gpu_mem_512=128
gpu_mem_256=64
In the config.txt you can overclock the Raspberry Pi without affecting your warranty (see this)
#Turbo
arm_freq=1000
core_freq=500
sdram_freq=500
over_voltage=6
I expand with gparted the dimension of the root mount point.

Insert the SD into the Raspberry Pi, plug the ethernet cable and the HDMI cable, turn on the extern hard disk and after turn on the alimentation.

 

First installation

Login into the Rasp with the root user (user: root password: root).

One of the first things that I do is the update of the whole system and reboot
# pacman -Syyu
# reboot

For security reason change the password of the root user
# passwd root

I add new user in order to don't use the root user for my daily work
# pacman -S sudo
# EDITOR=nano visudo
Uncomment the "%wheel ALL=(ALL) ALL" line
Add a new user

# useradd -m -g users -G wheel -s /bin/bash my_user
# passwd my_user

I configure a little bit the ssh daemon
# nano /etc/ssh/ssh_config
set the protocol line to 2 (1 is considered somewhat insecure)
# nano /etc/ssh/sshd_config
change the PermitRootLogin to no
# reboot

Login with the my_user.

$ cd /etc/netctl/
$ sudo cp examples/ethernet-static ./eth0

Set the Static IP in order to redirect the port in my router to the same IP
$ sudo nano eth0
Description='A basic static ethernet connection'
Interface=eth0
Connection=ethernet
AutoWired=yes
IP=static
Address=('192.168.0.130/24')
Gateway='192.168.0.1'
DNS=('8.8.8.8')
$ sudo netctl enable eth0
$ sudo reboot

We can now unplug the HDMI cable and access to the Raspberry Pi through ssh
$ ssh my_user@192.168.0.130

In order to work with my hard disk I have to install the exfat utils.
$ sudo pacman -S exfat-utils fuse-exfat
$ sudo mkdir /media/hard_disk
$ sudo mount -t exfat-fuse -o umask=0 /dev/sda1 /media/hard_disk

$ sudo nano /etc/sysctl.conf 
vm.min_free_kbytes=16184
This last configuration is for a problem of page allocator but in my case does not work.

 

Install Transmission

$ sudo pacman -S transmission-cli
$ transmission-daemon

You can configure transmission as you wish, but if you want a light version of transmission you have to modify the cache size configuration and set to 2 Mb
$ nano .config/transmission-daemon/settings.json

$ sudo cp /usr/lib/systemd/system/transmission.service /etc/systemd/system/
$ sudo cp /usr/lib/tmpfiles.d/transmission.conf /etc/tmpfiles.d/
$ sudo gpasswd -a my_user transmission

To finish the initial configuration I modify the name of the user in this 2 files

$ sudo nano /etc/tmpfiles.d/transmission.conf d
/run/transmission - my_user transmission -
$ sudo nano /etc/systemd/system/transmission.service
User=my_user
$ sudo reboot

$ sudo systemctl start transmission

Samba

$ sudo pacman -S samba

In order to share my hard disk with the LAN
$ sudo cp /etc/samba/smb.conf.default /etc/samba/smb.conf
$ sudo nano /etc/samba/smb.conf

[hard_disk]
        path = /media/hard_disk
        public = yes
        writable = yes
$ sudo pdbedit -a -u my_user


After all this work I backup my configuration with "dd" programm
$ sudo dd if=/dev/sdc of=image_of_backup bs=4M

ddclient 

$ sudo pacman -S ddclient

$ sudo nano /etc/ddclient/ddclient.conf


protocol=dyndns2
use=web, web=checkip.dyndns.it web-skip='Current IP Address: '
server=dyndns.it
login=YOUR USERNAME
password='YOUR PASSWORD'
YOUR HOSTNAME

Tuesday, April 16, 2013

Script in bash for compiling a kernel linux

This is a script that helps me in the process of compiling the kernel linux.

I test it on Arch Linux and Ubuntu and works fine if the source of the kernel is in
~/src/linux-KERNEL_VERSION
#!/bin/bash

set -e

if (( $EUID != 0 )); then
 echo "this script must be run as root"
 exit 1
fi

if (( $# != 1 )); then
 echo "pass only the KERNEL_VERSION as parameter"
 exit 1
fi

DISTRO=$(cat /etc/issue | awk '{print $1}')
CORE=$(grep -c processor /proc/cpuinfo)
FLAGS=`expr $CORE + 1`
JFLAGS=-j$FLAGS

cd /home/$SUDO_USER/src/linux-$1

echo "copy the config file"
sleep 1

case $DISTRO in
 "Arch")
  zcat /proc/config.gz > .config
  ;;
 "Ubuntu")
  cp /boot/config* .config
  ;;
esac

KER_NAME=$(cat .config | grep CONFIG_LOCALVERSION | grep -Po '(?<=\")[^)]*(?=\")')

echo "start make"
sleep 1
make $JFLAGS
make modules_install
echo "finish make"
echo "install the kernel"
sleep 1
cp -v arch/x86/boot/bzImage /boot/vmlinuz-$1$KER_NAME
case $DISTRO in
 "Arch")
  mkinitcpio -k $1$KER_NAME -c /etc/mkinitcpio.conf -g /boot/initramfs-$1$KER_NAME.img
  ;;
 "Ubuntu")
  mkinitramfs -o /boot/initrd.img-$1$KER_NAME $1
  ;;
esac

cp System.map /boot/System.map-$1$KER_NAME
echo "updating grub"
sleep 1
cp /boot/grub/grub.cfg /boot/grub/grub.cfg.old
grub-mkconfig -o /boot/grub/grub.cfg

Wednesday, March 20, 2013

Build kernel linux in virtualbox machine Ubuntu 10.04

This post is useful only for me, for remember what command I have to launch for compiling the kernel on the MY VirtualBox machine with Ubuntu 10.04.

However it can be useful for a starting point for other people.

$ make menuconfig
This command open a graphics menu where I check the options that are written in this link http://en.gentoo-wiki.com/wiki/Virtualbox_Guest

$ make

$ make modules

$ sudo make modules_install

$ sudo make install

$ cd /boot

$ sudo mkinitramfs -o initrd.img-2.6.32.60 2.6.32.60 (depends on the kernel version)

$ sudo grub-mkconfig -o /boot/grub/grub.cfg (I'm using grub)

When reboot the machine hold shift for choose the kernel.

Thursday, March 14, 2013

Simple echo in ASM code

This is very very simple and stupid code that reads from the standard input a string and writes on the standard output the same string.

The system calls are called by ASM code

#define BUF_SIZE 1024
#define READ 3
#define WRITE 4
#define FD 0

void main(){

 int __res;

 char __str[BUF_SIZE];

 //__res = read(0,__str,BUF_SIZE)
 __asm__ volatile ("int $0x80" : \
  "=a" (__res) : \
  "a" (READ), \
  "b" (FD), \
  "c" (__str), \
  "d" (BUF_SIZE));

 //write(0,__str,__res)
 __asm__ volatile ("int $0x80" : : \
  "a" (WRITE), \
  "b" (FD), \
  "c" (__str), \
  "d" (__res));

}

Wednesday, January 9, 2013

Latin vs English

In many book we can found this two abbreviations:

  • i.e.
  • e.g.
But, what do they mean?

The i.e. is the acronym for id est that means namely (in Italian "cioè").

The e.g. is the acronym for exempli gratia that means for example.