Software, Physics, Data, Mountains

...and other random associations

Units in Dia

Ok, dia is totally screwed up with units… here’s how to make it work well.

open dia

File -> Preferences

User Interface
  length unit: Centimeter
  Font-size unit: Point
Diagram Defaults
  Portrait
  Paper type: Letter
  Connection Points:
    Visible
    Snap to object
View Defaults
  Width: 800
  Height: 600
  Magnify: 100
  Page breaks:
    uncheck "Visible"
  Antialias:
    uncheck "view antialiased"
Grid Lines
  Visible
  Snap to
  uncheck Dynamic grid resizing
  X Size: 1.0
  Y Size: 1.0
  Lines per major line: 5

on the diagram window… File->Page Setup

Paper Size: Letter
orientation again portrait
Margins
  2.54cm all around
Scale: 100.0

View->Hide Rulers

This results in a window with 100x100pixel gridlines (when exported as png w/ or w/o alpha)

results in 5cmx5cm grids when exported directly to pdf

Using Openssl

openssl req -new -newkey rsa:2048 -nodes -out star_jsas7_com.csr -keyout star_jsas7_com.key -subj "/C=JM/ST=/L=Kingston/O=Jamaica Ministry of Education/OU=IT/CN=*.jsas7.com"

Umask

Ugh

  • make sure umask is not set anywhere

    (/etc/login.defs, /etc/profile, /etc/skel/, ~/.bash ~/.profile)

  • set umask via libpam-umask. In /etc/pam.d/common-session,

    session optional pam_umask.so umask=002

Snapshot Machine Config

A script to capture config info:

#!/bin/bash

#as root

TIME_STAMP=`date +"%G-%m-%d-%H%M%S"`
RESCUE_DIR="/root/rescue/${TIME_STAMP}"

mkdir -p ${RESCUE_DIR}

dpkg --get-selections > "${RESCUE_DIR}/dpkg-selections.out"
dpkg --get-selections | grep -v deinstall > "${RESCUE_DIR}/dpkg-selections-without-deinstall.out"
fdisk -l > "${RESCUE_DIR}/fdisk.out"
df > "${RESCUE_DIR}/df.out"
mount > "${RESCUE_DIR}/mount.out"
if [ -f /sbin/iptables-save ]; then
  iptables-save > "${RESCUE_DIR}/iptables.out"
fi
if [ -f /usr/bin/gem ]; then
  gem list > "${RESCUE_DIR}/gems.out"
fi

cd /var/spool/cron
tar czvf "${RESCUE_DIR}/crontabs.tar.gz" crontabs

Setup Postfix to Relay Through Google Apps

Install / Configure a Relay-only mail host on ec2

Install postfix

apt-get install postfix mailutils

stop the service

/etc/init.d/postfix stop

Edit /etc/postfix/master.cf and change

smtp      inet  n       -       -       -       -       smtpd

to

#smtp      inet  n       -       -       -       -       smtpd

Edit /etc/postfix/main.cf and change

myhostname = ip-10-127-126-193.ec2.internal
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = mysub.mydom.com, ip-10-127-126-193.ec2.internal, localhost.ec2.internal, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

to

myhostname = mysub.mydom.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = mysub.mydom.com, localhost.mydom.com, ip-10-127-126-193.ec2.internal, localhost.ec2.internal, localhost
relayhost = mydom.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
local_transport = error:local delivery disabled

Restart postfix

/etc/init.d/postfix restart

test with mail

root@ip-10-127-126-193:/etc/postfix# mail dixon@mydom.com
Cc: 
Subject: Mims testing from root@mysub.mydom.com to dixon@mydom.com 201012120753
.
.
<Ctrl-D>

Kvm Disk Management

lots of LVM stuff here
http://www.jmcneil.net/2010/05/kvm-virtual-disk-access/

also,

<disk type='block' device='disk'>
  <source dev='/dev/sde1'/>
  <target dev='hdb' bus='ide'/>
</disk>

worked fine (showed up as /dev/sdb)

<disk type='block' device='disk'>
  <source dev='/dev/sde1'/>
  <target dev='vdb' bus='virtio'/>
</disk>

worked too (showed up as /dev/vda)

trying… /dev/sde instead of the single partition…

<disk type='block' device='disk'>
  <source dev='/dev/sde'/>
  <target dev='vda' bus='virtio'/>
</disk>

multiple direct mounts don’t work… no real surprise here

ok, what about with some other options like:

<disk type='file'>
  <driver name="tap" type="aio" cache="default"/>
  <source file='/var/lib/xen/images/fv0'/>
  <target dev='hda' bus='ide'/>
  <encryption type='...'>
    ...
  </encryption>
  <shareable/>
  <serial>
    ...
  </serial>
</disk>

like

<disk type='block' device='disk'>
  <driver name='qemu' type='raw' cache='none'/>
  <source dev='/dev/sde'/>
  <target dev='vda' bus='virtio'/>
  <shareable/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>

(driver and address came from dumpxml)

this didn’t work either

Tweak Bash History

not sure what’s best here… playing around with:

# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace

# append to the history file, don't overwrite it
shopt -s histappend

#HISTFILE=$HOME/.bash/history/$$

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

PROMPT_COMMAND="history -a; history -n"
#PROMPT_COMMAND="history -a $HISTFILE ; history -n"

or

unset INPUTRC
export EDITOR=vi
export HISTSIZE=10000000
export HISTFILESIZE=10000000
export HISTTIMEFORAMT="%c"
export PROMPT_COMMAND='history -a && history -c && history -r'
set -o vi

Lvm Cheats and Notes

from http://www.redhatlinux.info/2010/11/lvm-logical-volume-manager.html

LVM (LOGICAL VOLUME MANAGER) 1. TO CREATE LVM

1.fdisk /dev/sda   ->create 3 partitions + label to 8e
2.partprobe
3.fdisk -l
4.pvcreate /dev/sda8 /dev/sda9
5.pvdisplay /dev/sda8
6.pvdisplay /dev/sda9
7.vgcreate vg0 /dev/sda8 /dev/sda9
8.vgdisplay 
9.lvcreate -L +200M -n /dev/vg0/home1
10.lvdisplay /dev/vg0/home1
11.lvcreate -L +300M -n /dev/vg0/var1
12.lvdisplay /dev/vg0/var1 
13.mkfs.ext3 /dev/vg0/var1
14 mkfs.ext3 /dev/vg0/home1 
15.mkdir /home1
16.mkdir /var1
17.mount /dev/vg0/home1 /home1
18.mount /dev/vg0/var1 /var1
19.cp /etc/a* /home1
20.cp /etc/b* /var1
21.vim /etc/fstab 
22.mount -a

TO EXTEND LVM

1.lvdisplay /dev/vg0/home1
2.lvextend -L +200M /dev/vg0/home1
3.ls /home1
4.resize2fs /dev/vg0/home1
5.ls /home1

TO REDUCE LVM

1. lvdisplay 
2. umount /var1
3. e2fsck -f /dev/vg0/var1
4. resize2fs /dev/vg0/var1 100M
5. lvreduce -L -100M -n /dev/vg0/var1
6. mount /dev/vg0/var1 /var1
7. df -h 

LVM SNAPSHOT

1.  lvcreate  -L 200M -s -n lv2 /dev/llc/lv1

TO EXTEND PV 1.pvcreate /dev/sda10 2.pvdisplay

TO EXTEND VG 1.vgextend vg0 /dev/sda10 2.vgdisplay vg0

TO REDUCE VG 1.vgreduce vg0 /dev/sda10 2.vgdisplay

TO REDUCE PV 1.pvremove /dev/sda10 2.pvdisplay

REMOVE LVM 1.lvdisplay 2.umount /dev/vg0/home1 3.umount /dev/vg0/var1 4.vim /etc/fstab 5.lvremove /dev/vg0/home1 6.lvremove /dev/vg0/var1 7.lvdisplay

REMOVE VG 1.vgdisplay 2.vgremove /dev/vg0 3.vgdisplay

REMOVE PV 1.pvdisplay 2.pvremove /dev/sda9 3.pvremove /dev/sda8


from http://www.linux-mag.com/cache/7454/1.html

# fdisk -l /dev/sdb

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       30400   244187968+  8e  Linux LVM
/dev/sdb2           30401       60801   244196032+  8e  Linux LVM
   

# pvcreate /dev/sdb1 /dev/sdb2 /dev/sdc1 /dev/sdc2
Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdb2" successfully created
Physical volume "/dev/sdc1" successfully created
Physical volume "/dev/sdc2" successfully created


# pvdisplay


# vgcreate primary_vg /dev/sdb1 /dev/sdb2 /dev/sdc1 /dev/sdc2
  Volume group "primary_vg" successfully created


# vgdisplay

# vgscan
Reading all physical volumes.  This may take a while...
Found volume group "primary_vg" using metadata type lvm2
  
# lvcreate --name /dev/primary_vg/home_lv --size 450G
  Logical volume "home_lv" created

# lvdisplay

# lvscan

# mkfs.ext3 /dev/primary_vg/home_lv


# lvcreate -L500M -s -n home_backup_080309 /dev/primary_vg/home_lv
  Logical volume "home_backup_080309" created


# lvscan
  ACTIVE   Original '/dev/primary_vg/home_lv' [450.00 GB] inherit
    ACTIVE   Snapshot '/dev/primary_vg/home_backup_080309' [500.00 MB] inherit


# mkdir /mnt/backup/home_backup_080309
# mount /dev/primary_vg/home_lv/home_backup_080309 /mnt/backup/home_backup_080309
# mount
/dev/hda3 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/hda1 on /boot type ext2 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/mapper/primary_vg-home_lv on /home type ext3 (rw,data=ordered)
/dev/mapper/primary_vg-home_backup_080309 on /mnt/backup/home_backup_080309 type ext3 (rw)

# ls -s /mnt/backup/home_backup_080309/
total 20
16 lost+found   4 user5
# ls -s /mnt/backup/home_backup_080309/user5
total 74080
    4 linux-2.6.30  74076 linux-2.6.30.tar.gz

Ipmi Stuff

OMG…. finally!

http://wiki.adamsweet.org/doku.php?id=ipmi_on_linux

http://www.cyberciti.biz/tips/tag/ipmiclix86-command
http://www.cyberciti.biz/tips/linux-freebsd-ipmi-login-session.html
http://www.intel.com/design/servers/ipmi/ipmi.htm
http://wikitech-static.wikimedia.org/articles/i/p/m/IPMI_8730.html