Wednesday, December 8, 2010

playing with linear raid and ext4

The goal is to create linear raid with ext4 array from 4 disks. Than add 5. disk and verify data.

Create linear raid from 4 disks
$ sudo mdadm -v --create /dev/md0 -l linear -n 4 /dev/sdb /dev/sdc /dev/sdd /dev/sde

Make ext4fs
$ sudo mkfs.ext4 /dev/md0

Mount array
$ sudo mkdir array
$ sudo mount /dev/md0 /media/array


Information about array
$ sudo mdadm --detail /dev/md0
$ cat /proc/mdstat


Set the system recognize the raid after the reboot
$ sudo echo 'DEVICES /dev/sdb /dev/sdc /dev/sdd /dev/sde' >> /etc/mdadm/mdadm.conf
$ sudo mdadm --detail --scan >> /etc/mdadm.conf


Upload test data, make md5 checksum
$ cd /media/array/
$ wget http://cdimage.debian.org/debian-cd/5.0.7/amd64/iso-cd/debian-507-amd64-netinst.iso
$ md5sum debian-507-amd64-netinst.iso
971ddace926fc3f7765f595da5cce223 debian-507-amd64-netinst.iso


Add 5. disk and resize filesystem
$ mdadm --grow --add /dev/md0 /dev/sdf
$ sudo resize2fs /dev/md0


Add device at /etc/mdadm/mdadm.conf and rescan (change list line)

Compare checksum
$ md5sum debian-507-amd64-netinst.iso
971ddace926fc3f7765f595da5cce223 debian-507-amd64-netinst.iso


Checksums are the same.

Add line to /etc/fstab and test reboot.

Sometimes there are problems with assemble, look in

cat /proc/mdstat


if there are not some dummy traits from one disk, that you can stop by

mdadm --stop /dev/md_d0


See also wiki

Monday, December 6, 2010

esxi managing from console

See also: Robert Chase page

It is easy to use console of ESXi server and do some managing from it.


Get all virtual machines
vim-cmd vmsvc/getallvms

Power off/on/reboot virtual machine with id 368
vim-cmd vmsvc/power.off 368
vim-cmd vmsvc/power.on 368
vim-cmd vmsvc/power.reboot 368


Get information about virtual machine with id 368
vim-cmd vmsvc/get.summary 368

Delete all snapshots
vim-cmd vmsvc/snapshot.removeall 368

Refresh datastore
esxcfg-nas -r

Delete and add nfs datastore back
esxcfg-nas -d back
esxcfg-nas -a back --host IPADDRESS --share DIRECTORY


Running processes
esxtop

Console screen
dcui

Wednesday, September 15, 2010

apache2 modules

List of loaded modules:
apache2ctl -t -D DUMP_MODULES

List of compiled modules:
apache2 -l

Apache2 version:
apache2 -v

Disable module:
a2dismod module_name

Enable module:
a2enmod module_name

Tuesday, June 15, 2010

second postfix instance with auth smtp

See advosys.ca help.ubuntu.com adomas.org postfix.org

Copy config dir
cp -rp /etc/postfix /etc/postfix-out

Create file /etc/postfix-out/sasl/smtpd.conf with
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN

Note, that previous plaintext mechanism send credentials unencrypted. Therefore TLS-encrypted SMTP session is used.

Add following lines to /etc/postfix-out/main.cf
queue_directory = /var/spool/postfix-out
data_directory = /var/lib/postfix-out


Create and copy queue and data directories
mkdir /var/spool/postfix-out
postfix -c /etc/postfix-out check
cp -rp /var/lib/postfix /var/lib/postfix-out
cp -rp /var/spool/postfix/etc /var/spool/postfix-out
cp -rp /var/spool/postfix/usr /var/spool/postfix-out
cp -rp /var/spool/postfix/lib /var/spool/postfix-out


Add following line to /etc/postfix/main.cf
alternate_config_directories = /etc/postfix-out

Modify port no. for smtp at /etc/postfix-out/master.cf

1025 inet n - - - - smtpd


Test start
postfix -c /etc/postfix-out start

Install sasl and mkdir var folder
apt-get install libsasl2-2 sasl2-bin


Modify /etc/init.d/saslauthd
PIDFILE=/var/spool/postfix-out/var/run/saslauthd/saslauthd.pid

Modify /etc/default/saslauthd
START=yes
PWDIR="/var/spool/postfix-out/var/run/saslauthd"
PARAMS="-m ${PWDIR}"
PIDFILE="${PWDIR}/saslauthd.pid"
OPTIONS="-c -m /var/spool/postfix-out/var/run/saslauthd"


Create dirs for sasl in chroot postfix
dpkg-statoverride --force --update --add root sasl 755 /var/spool/postfix-out/var/run/saslauthd

Add following lines to /etc/postfix-out/main.cf
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_path = smtpd


Restart all services
/etc/init.d/saslauthd restart
/etc/init.d/postfix restart
postfix -c /etc/postfix-out stop
postfix -c /etc/postfix-out start


Test by sasl
testsaslauthd -u USERNAME -p PASSWORD -f /var/spool/postfix-out/var/run/saslauthd/mux

Test by telnet
telnet SERVER_ADDRESS 1025
Trying IPADDRESS...
Connected to SERVER_NAME.
Escape character is '^]'.
220 SERVERNAME ESMTP Postfix (Ubuntu)
ehlo localhost
250-SERVERNAME
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN


Create startup script
cp /etc/init.d/postfix /etc/init.d/postfix-out

And replace pairs in new file
/etc/postfix by /etc/postfix-out
postfix by postfix -c /etc/postfix-out
/var/spool/postfix by /var/spool/postfix-out
postconf by postconf -c /etc/postfix-out

Now make symlinks in rc.d to /etc/init.d/postfix-out, e.g.
ln -s /etc/init.d/postfix-out /etc/rc6.d/K01postfix-out

Saturday, June 5, 2010

Font Arial in R

See stat.ethz.ch

Install fonts

sudo apt-get install ubuntu-restricted-extras


In console

ttf2afm /usr/share/fonts/msttcorefonts/arial.ttf > ~/afont/arial.afm
ttf2afm /usr/share/fonts/msttcorefonts/ariali.ttf > ~/afont/ariali.afm
ttf2afm /usr/share/fonts/msttcorefonts/arialbd.ttf > ~/afont/arialbd.afm
ttf2afm /usr/share/fonts/msttcorefonts/arialbi.ttf > ~/afont/arialbi.afm


In R

postscript("fa1x.eps",
family=c("/home/pvl/afont/arial.afm","/home/pvl/afont/arialbd.afm","/home/pvl/afont/ariali.afm","/home/pvl/afont/arialbi.afm"),
horizontal=FALSE, height=4.5, width=7.5, paper = "special", pointsize=4)

Friday, April 9, 2010

eduroam throught ppp

See general link

Choose NAME of connection, VPNSERVER of your institution and your LOGIN
$ cat /etc/ppp/peers/NAME
pty "pptp VPNSERVER --nolaunchpppd"
name LOGIN
remotename PPP
require-mppe-128
file /etc/ppp/options.pptp
ipparam NAME


Choose LOGIN and PASSWORD
$ cat /etc/ppp/chap-secrets
# client server secret IP addresses
LOGIN PPP PASSWORD *


Now you simply run
pppd call NAME
route add -net ADDRESS_OF_NETWORK netmask 255.255.0.0 dev ppp0

Wednesday, March 31, 2010

ssl certificates

Generate request (aliases could be added later)
keytool -genkey -keyalg RSA -keysize 2048 -keystore serverkey.pem -validity 1100 -dname "CN=SERVERNAME, O=Jihoceska univerzita v Ceskych Budejovicich, C=CZ" -keypass PASSWORD -alias SERVERALIAS

keytool -certreq -keyalg RSA -file request.csr -keystore serverkey.pem -alias SERVERALIAS


Submit request at http://tcs.cesnet.cz/req and download keys.

Generate no password key
openssl rsa -in serverkey.pem -out serverkey_nopass.pem


Copy keys
cp serverkey_nopass.pem /etc/ssl/private/
cp servercert.pem /etc/ssl/private/


Edit apache2 conf /etc/apache2/sites-enabled/000-default-ssl
SSLEngine on
SSLCertificateFile /etc/ssl/certs/servercert.pem
SSLCertificateKeyFile /etc/ssl/private/serverkey_nopass.pem