Thursday, March 26, 2009

The Purpose

Our purpose here is not defined in nature's harmony and carbon traces.
The lab assistant who made us all, has gone to work on other cases.

We ask ourselves why we are here, yet none of us today can say,
if our purpose serves another purpose, like others just like us in Milky Way..

The neighboring swirls may have the answer, and we must find the ways to go,
and talk to all and figure out,
if we all really matter.

When we have understood all that exists, then we shall all decide.

If we exist with purpose, fine. Enlightenment will then soothe the soul.
If not, then our purpose will have been,
To search the meaning of it all.

Wednesday, March 25, 2009

Ubuntu - software Raid5: recovering from a failing drive

- Check integrity of array:
hdparm -i -v /dev/md0

- Unmount the raid:
root@gamma:~# umount /mnt/r5/
umount: /mnt/r5: device is busy
umount: /mnt/r5: device is busy

- Find out the process that's keeping the drive busy:
root@gamma:~# fuser -m /dev/md0
/dev/md0: 5670c

- Look up the process:
root@gamma:~# ps auxw | grep 5670
root 5670 0.4 0.0 8792 3200 ? S 19:25 0:34 /usr/sbin/smbd -D

- Ah, it's Samba, stop it:
root@gamma:~# /etc/init.d/samba stop
* Stopping Samba daemons...

- Try again to unmount:
root@gamma:~# umount /mnt/r5/
root@gamma:~#


- Take a detailed look at the raid array:
mdadm --query --detail /dev/md0


...

Number Major Minor RaidDevice State
0 0 0 - removed
1 8 16 1 active sync /dev/sdb
2 8 32 2 active sync /dev/sdc
3 0 0 - removed

4 8 0 - faulty /dev/sda
5 8 48 - spare /dev/sdd


Found a faulty drive: /dev/sda


- tell the array the drive that is faulty:
root@gamma:~# mdadm -f /dev/md0 /dev/sdd
mdadm: set /dev/sdd faulty in /dev/md0

- hot remove the faulty drive
root@gamma:~# mdadm --remove /dev/md0 /dev/sdd
mdadm: hot removed /dev/sdd

- walk over to server and pysically remove drive.
If you don't know which one is the right drive,
remove one at a time, and then run
mdadm --query --detail /dev/md0
and see which drive is no longer there

- insert a new (and good) hard drive. Add it:
root@gamma:~# mdadm -add /dev/md0 /dev/sdd
mdadm: hot added /dev/sdd

- watch the recovery
watch cat /proc/mdstat

Every 2.0s: cat /proc/mdstat Tue Mar 24 22:45:58 2009

Personalities : [raid5]
md0 : active raid5 sdd[4] sda[0] sdc[2] sdb[1]
1465159488 blocks level 5, 64k chunk, algorithm 2 [4/3] [UUU_]
[>....................] recovery = 0.0% (20224/488386496) finish=19245.9min speed=421K/sec

unused devices:

It seems that this will take 19,000 minutes, which is 13 days. Ugh.

Tuesday, March 24, 2009

Ubuntu - how to set up Samba

1. Install Samba:

root@gamma:~# aptitude install samba
Reading package lists... Done
Building dependency tree... Done
Reading extended state information
Initializing package states... Done
Building tag database... Done
The following packages have been kept back:
akregator apt apt-utils base-files bind9-host bsdutils bzip2 coreutils cpio cupsys cupsys-bsd cupsys-client dbus debconf debconf-i18n dnsutils
dpkg dselect e2fslibs e2fsprogs enscript file firefox gnupg gzip hpijs hplip hplip-data hplip-ppds imagemagick info initramfs-tools iptables
kaddressbook karm kdepim-kio-plugins kdepim-kresources kdepim-wizards klogd kmail kmailcvt knotes kontact korganizer libavahi-client3
libavahi-common-data libavahi-common3 libavahi-qt3-1 libbind9-0 libblkid1 libbz2-1.0 libcomerr2 libcupsimage2 libcupsys2 libcurl3 libcurl3-gnutls
libdbus-1-2 libdbus-glib-1-2 libdbus-qt-1-1c2 libdns21 libexif12 libfreetype6 libgadu3 libgnutls12 libisc11 libisccc0 libisccfg1 libjasper-1.701-1
libkcal2b libkdepim1a libkleopatra1 libkmime2 libkpimexchange1 libkpimidentities1 libkrb53 libksieve0 libktnef1 liblcms1 liblwres9 libmagic1
libmagick9 libmimelib1c2a libmysqlclient15off libnspr4 libnss3 libperl5.8 libpng12-0 libpq4 libruby1.8 libsasl2 libsasl2-modules libsnmp-base
libsnmp9 libss2 libssl0.9.8 libuuid1 libvorbis0a libvorbisenc2 libvorbisfile3 libxine-main1 libxml2 linux-image-2.6.15-26-server
linux-image-server linux-server locales login lvm2 mount mysql-client-5.0 mysql-common mysql-server-5.0 ntpdate openoffice.org openoffice.org-base
openoffice.org-calc openoffice.org-common openoffice.org-core openoffice.org-draw openoffice.org-impress openoffice.org-java-common
openoffice.org-kde openoffice.org-l10n-en-us openoffice.org-math openoffice.org-writer openssh-client openssh-server openssl passwd perl perl-base
perl-modules perl-suid popularity-contest python-crypto python-uno python2.4-crypto python2.4-dbus python2.4-libxml2 rsync ssh sysklogd tar
tcpdump tk8.4 ttf-opensymbol udev util-linux vim vim-common vim-runtime w3m xterm
The following NEW packages will be installed:
samba
0 packages upgraded, 1 newly installed, 0 to remove and 152 not upgraded.
Need to get 2852kB of archives. After unpacking 7262kB will be used.
Writing extended state information... Done
Get:1 http://archive.ubuntu.com dapper-updates/main samba 3.0.22-1ubuntu3.8 [2852kB]
Fetched 2852kB in 2m37s (18.1kB/s)
Preconfiguring packages ...
Selecting previously deselected package samba.
(Reading database ... 67170 files and directories currently installed.)
Unpacking samba (from .../samba_3.0.22-1ubuntu3.8_i386.deb) ...
Setting up samba (3.0.22-1ubuntu3.8) ...
Generating /etc/default/samba...
TDBSAM version too old (0), trying to convert it.
TDBSAM converted successfully.
account_policy_get: tdb_fetch_uint32 failed for field 1 (min password length), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 2 (password history), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 3 (user must logon to change password), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 4 (maximum password age), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 5 (minimum password age), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 6 (lockout duration), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 7 (reset count minutes), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 8 (bad lockout attempt), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 9 (disconnect time), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 10 (refuse machine password change), returning 0
* Starting Samba daemons... [ ok ]
root@gamma:~#


2. Create group samba:
root@gamma:~# groupadd samba

3. Add user my_user_id to group samba:
root@gamma:~# usermod -a -G samba my_user_id

4. Edit the smb.conf file, uncomment what you want to be used:
root@gamma:~# nano /etc/samba/smb.conf

5. Add users who can access samba shares:
root@gamma:/etc/samba# smbpasswd -a my_user_id
New SMB password:
Retype new SMB password:
root@gamma:/etc/samba#

6. If you need to make more changes to your smb.conf, restart samba after you're done:
root@gamma:/etc/samba# /etc/init.d/samba restart

How to set up Raid5 in Ubuntu

How to set up raid5:

Setting up raid5 with 4 drives, 500gb each. Using a SIL hardware sata drive controller, and setting up software raid.

1. update and install package mdadm
apt-get update
apt-get install mdadm

2. Use the 4 devices to create md0
mdadm --create /dev/md0 --level=raid5 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

2b. If the array is already started, stop it.
mdadm --stop /dev/md0

3. Assemble the array
root@gamma:~# mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
mdadm: /dev/md0 has been started with 3 drives (out of 4) and 1 spare.

Live watch of the array building:
watch cat /proc/mdstat

Wait many hours...

I believe the wait here was about 6 hours.


4. Create the file system:

root@gamma:~# mkfs.ext3 /dev/md0
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
183156736 inodes, 366287952 blocks
18314397 blocks (5.00%) reserved for the super user
First data block=0
11179 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848

Writing inode tables: 158/11179
...

This command hangs for me, waiting at 158 forever. I even tried doing a kill -9 on the process, with no luck. Even a shutdown -now didn't work, so I had to do a hard boot. Then, I tried the following command:


4b. Try, try again, use mke2fs instead of mkfs.ext3

root@gamma:~# mke2fs /dev/md0
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
183156736 inodes, 366289872 blocks
18314493 blocks (5.00%) reserved for the super user
First data block=0
11179 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848

Writing inode tables: 427/11179
...
and that updated slowly, without hanging.
...

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
root@gamma:~#

5. use fdisk to create one partition for the whole md0
root@gamma:~# fdisk /dev/md0

Command (m for help): p

Disk /dev/md0: 1500.3 GB, 1500323315712 bytes
2 heads, 4 sectors/track, 366289872 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Device Boot Start End Blocks Id System

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-366289872, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-366289872, default 366289872):
Using default value 366289872

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
root@gamma:~#


6. Restart the system:
shutdown -r now

7. Create a directory in /mnt
mkdir /mnt/r5

8. Mount the md0 device:
mount /dev/md0 /mnt/r5/

9. Check how much space is available on the drive:

root@gamma:/mnt/r5# df -h /mnt/r5
Filesystem Size Used Avail Use% Mounted on
/dev/md0 1.4T 20K 1.3T 1% /mnt/r5
root@gamma:/mnt/r5#

... and we have 1.4 Terrabytes. All ok.

Wednesday, March 11, 2009

Standard Ubuntu Setup

----
-> After installing Ubuntu:

-> log in, change root password
sudo passwd root
----
-> as root:
apt-get install ssh
apt-get install unzip zip
apt-get install build-essential



apt-get install mysql-server-5.0
* Root password is blank. To change it use:
* /etc/init.d/mysql reset-password
----
-> setup static ip
sudo vi /etc/network/interfaces
iface eth0 inet static
address 192.168.0.102
netmask 255.255.255.0
network 192.168.0.1
broadcast 192.168.0.255
gateway 192.168.0.1
----
Set up the name servers
sudo nano /etc/resolv.conf , and add:

search yahoo.com
nameserver 216.162.128.6
nameserver 216.162.128.5
(your DNS servers are specific to your internet provider)

then,
sudo /etc/init.d/networking restart

To see if it worked,
ping google.com
and it should resolve google.com to its actual IP
----
-> as username, vi .bashrc to set up paths
export PATH=/opt/jdk1.6.0_04/bin:$PATH
export JAVA_HOME="/opt/jdk1.6.0_04"
export CLASSPATH=.:/opt/jdk1.6.0_04
----
-> grab jdk from another PC
scp username@192.168.0.202:/root/software/jdk-6u4-linux-i586.bin .
----
-> benchmark Sieve
wget http://rsb.info.nih.gov/nih-image/java/benchmarks/Sieve.java
----
How to set hard drives to go into standby mode after 10 minutes:

sudo hdparm -S 120 /dev/hda
----
How to save your hard drive from being hammered by Ubuntu power saver:

- based on http://www.breakitdownblog.com/ubuntu-power-saver-settings-could-damage-hard-drive/ :

1. Make a file named 99-hdd-spin-fix.sh The important thing is starting with 99.
2. Make sure the file contains the following 2 lines (fix it if you have PATA HDD):

#!/bin/sh
hdparm -B 255 /dev/sda

3. Copy this file to 3 locations:

/etc/acpi/suspend.d/
/etc/acpi/resume.d/
/etc/acpi/start.d/
----
The "perfect" Ubuntu setup:
http://www.howtoforge.com/perfect_setup_ubuntu_6.06
----
Install mail server:

apt-get install postfix
- run through the setup
----
Install KDE or GNOME: From: http://www.psychocats.net/ubuntu/kde

> sudo aptitude update && sudo aptitude install kubuntu-desktop

During the installation process, you should be asked whether you want to use KDM or GDM as your default display manager. The default can always be changed later by modifying the /etc/X11/default-display-manager file. For KDM, the file should read /usr/bin/kdm; for GDM, the file should read /usr/sbin/gdm . When KDE is done installing, log out. If you're using 6.06 or later, once you get to the login screen, click on Options and then Select Session. In older versions of Ubuntu (5.10 or earlier), you would have a separate Session button instead of drilling down to Session from Options. In the Sessions dialogue, select KDE and then Change Session.

Finally, before you log back in again, decide whether you want to change to KDE just for this session or if you want to make KDE your default desktop environment. Then, log back in, and you should be using KDE. To switch back to Gnome, just log out and select Gnome from the session menu.

If you later decide you don't want KDE any more, go back to the terminal and paste in
> sudo aptitude remove kubuntu-desktop
----
Install VPN:

sudo apt-get install vpnc
sudo apt-get install network-manager-vpnc
----
http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html
cat /proc/cpuinfo
top -n 1 -b | head
Useful admin commands: http://www.reallylinux.com/docs/admin.shtml
----
How to install mysql:

1. download mysql, ex: mysql-5.0.51a-linux-i686.tar.gz

2. add groups
shell> groupadd mysql
shell> useradd -g mysql mysql

3. gzip and untar into /usr/local/mysql
shell> cd /usr/local
shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf - shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data

4. How to start the daemon:
shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &

----
How to use Xterm with Xming:

username@gamma:~$ xterm Xt error: Can't open display:
xterm: DISPLAY is not set
username@gamma:~$ export DISPLAY=gamma:0.0

In putty, under Connection, Ssh, X11, check the "Enable X11 forwarding" box, and in the X-display location field type localhost:0 Save this Putty entry, load it, open connection to server.

username@server:~$ xterm &
[1] 4513
----
Installing kde:
apt-get install kubuntu-desktop
(it's over 1200MB)
----
How to disable the kde logon screen from showing at start up:

echo "false" | sudo tee /etc/X11/default-display-manager

(simply placing the word false in the file, and then restarting, should disable the kdm logon screen)

- Another option would be to change the execute rights on the /etc/init.d/kdm startup script:
chmod a-x /etc/init.d/kdm
----
How to restart apache:
/etc/init.d/apache2 restart

Virtual hosts:
nano /etc/apache2/sites-available/default

Example of setting up a virtual host (do this for both digitalagora.com and www.digitalagora.com):

ServerName www.digitalagora.com
DocumentRoot /srv/websites/digitalagora.com
LogLevel notice
CustomLog /var/log/apache2/digitalagora.com-custom.log combined
ErrorLog /var/log/apache2/digitalagora.com-error.log

----

Sunday, March 8, 2009

Memories...

This is some text
Which I have once written,
Thinking intensely
To occupy my mind.
Yet however hard
I did try to ponder,
Over hours and hours
No thoughts could I find.