Category Archives: How to

Install UBCD on a bootable USB stick

Ultimate Boot CD was a really good tool when I worked as a sysadmin and I thought it was a good thing to keep a USB stick around.

Download UBCD

There are several options to download a copy of UBCD iso, all listed on the dedicated page. A good way is to use torrent (here’s the magnet link).

Indetify your USB device

Please be careful here, if you are wrong, you are going to delete the wrong disk.
I’m not responsible of any data you loose.

There are few ways to detect the right USB device, I usually take a look do dmesg output

$ dmesg | grep -A8 'Direct-Access'
[  844.712601] scsi 6:0:0:0: Direct-Access     Generic  Flash Disk       8.07 PQ: 0 ANSI: 2
[  844.713050] sd 6:0:0:0: Attached scsi generic sg2 type 0
[  844.716347] sd 6:0:0:0: [sdc] 15663104 512-byte logical blocks: (8.01 GB/7.46 GiB)
[  844.716774] sd 6:0:0:0: [sdc] Write Protect is off
[  844.716780] sd 6:0:0:0: [sdc] Mode Sense: 03 00 00 00
[  844.716969] sd 6:0:0:0: [sdc] No Caching mode page found
[  844.716972] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[  844.719175]  sdc: sdc1
[  844.720364] sd 6:0:0:0: [sdc] Attached SCSI removable disk

In this case I’m sure that the device is sdc because I’ve only one disk with 8GB of storage.

I’ll use sdc in this document, you should use your device name, it’s really important.

Format the USB stick

Be sure that the OS you are running have not automatically mounted any previous partition on the stick:

$ sudo umount /dev/sdc*

Then you could use GParted or do it manually as I like.

$ sudo parted -s /dev/sdc mklabel msdos
$ sudo parted -s /dev/sdc mkpart primary fat32 0 700
$ sudo parted -s /dev/sdc set 1 boot on
$ sudo mkfs.vfat -F32 /dev/sdc1
$ sudo parted -s /dev/sdc print
Model: Generic Flash Disk (scsi)
Disk /dev/sdc: 8020MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End    Size   Type     File system  Flags
 1      512B   700MB  700MB  primary               boot, lba

Extract ISO data on a folder

$ mkdir ubcd534
$ sudo mount -o loop,ro ubcd534.iso /mnt/misc/
$ rsync -avr /mnt/misc/ ubcd534/
$ sudo umount /mnt/misc

Copy ISO data to USB

$ sudo mount /dev/sdc1 /mnt/misc/
$ sudo rsync -rtv ubcd534/ /mnt/misc/
$ sudo umount /dev/sdc1

Make the USB device bootable

$ cd ubcd534/ubcd/tools/linux/ubcd2usb
$ chmod +x syslinux
$ sudo ./syslinux -s -d /boot/syslinux -i /dev/sdc1

Statically compile redis 3.0.2 on CentOS 5 (RHEL 5)

How to statically compile redis 3.0.2 on CentOS 5 (RHEL 5)

wget http://download.redis.io/releases/redis-3.0.2.tar.gz
wget http://prdownloads.sourceforge.net/tcl/tcl8.5.18-src.tar.gz

Install tcl8.5

tar xfz tcl8.5.18-src.tar.gz
cd tcl8.5.18/unix
./configure
make
make test
make install

Compile redis

Statically linked binaries

make CFLAGS="-static" EXEEXT="-static" LDFLAGS="-I/usr/local/include/"

Dynamically linked binaries

make LDFLAGS="-I/usr/local/include/"

How to manually install redis

cd src/
cp redis-{server,cli} /usr/local/bin/
chown root: /usr/local/bin/redis-{server,cli}
chmod 755 /usr/local/bin/redis-{server,cli}
mkdir /{var,etc}/redis /var/redis/6379
chmod 775 /{var,etc}/redis
cp redis.conf /etc/redis/6379.conf
sed -i 's/daemonize no/daemonize yes/' /etc/redis/6379.conf
sed -i 's,pidfile /var/run/redis.pid,pidfile /var/run/redis_6379.pid,' /etc/redis/6379.conf
sed -i 's/^# bind 127.0.0.1/bind 127.0.0.1/' /etc/redis/6379.conf
sed -i 's,logfile "",logfile "/var/log/redis_6379.log",' /etc/redis/6379.conf
sed -i 's,dir ./,dir /var/redis/6379,' /etc/redis/6379.conf

How to enable/disable Android logcat when using a custom kernel

A good source of information could be found in this page, but none of them worked for me.

The most useful article I found was on xda and here’s the solution:

  • enable
    echo 0 > /sys/module/logger/parameters/log_mode
    
  • enable at boot, but not when suspended
    echo 1 > /sys/module/logger/parameters/log_mode
    
  • completely disabled:
    echo 2 > /sys/module/logger/parameters/log_mode
    

(you need a rooted device)

How to compile rsync for Android in Ubuntu

My situation

My machine

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04 LTS
Release:    14.04
Codename:   trusty

The latest rsync version to compile (for me it was rsync-3.1.0.tar.gz)

$ curl -s http://rsync.samba.org/ftp/rsync/ \
    | sed -r 's/^.*href="([^"]*)".*$/\1/' | grep 'rsync-[0-9].*\.tar\.gz$'

Procedure

  1. save the tarball name in a variable
    $ RSYNCTGZ="rsync-3.1.0.tar.gz"
    
  2. install needed software
    $ sudo aptitude install gcc-arm-linux-gnueabi
    
  3. download sources
    $ wget http://rsync.samba.org/ftp/rsync/$RSYNCTGZ
    $ tar xzf $RSYNCTGZ
    $ cd rsync-[0-9]*
    
  4. compile
    $ ./configure --host=arm-linux-gnueabi CFLAGS=-static
    $ make
    
  5. install on the device
    $ adb push rsync /data/local/tmp && adb shell chmod 775 /data/local/tmp/rsync
    
  6. test execution
    $ adb shell /data/local/tmp/rsync
    

References

How to display PHP errors only in public_html directories

How to display PHP errors

I always use servers where PHP errors are not shown by default and I always forget how to enable error messages in development environments.

My situation

On a server I usually prefer Debian OS, but when I develop on the go I use laptops with Ubuntu.
In this case I’m running Ubuntu 14.04 LTS with Apache2 (v2.4.7) and libapache2-mod-php5 (v5.5.9).

I want PHP errorors displayed for projects in my public_html folder.

Solution 1 (only Apache conf files)

Create the file /etc/apache2/sites-enabled/800-public-html.conf with this content:

<Directory /home/*/public_html>
  AllowOverride Options
  php_admin_flag display_errors On
</Directory>

Solution 2 (using .htaccess)

Create the file /etc/apache2/sites-enabled/800-public-html.conf with this content:

<Directory /home/*/public_html>
  AllowOverride Options
</Directory>

Create the file /home/max/public_html/project1/.htaccess with this content:

php_admin_flag display_errors On

Conclusions

It’s easy and easily forgettable. Don’t forget to add

error_reporting(E_ALL | E_NOTICE);

in your .php files.