20141220

handy script to quickly backup a file

#!/bin/bash
# backup a file (somefile to somefile.yyyy-mm-dd.tar.gz)

FILE="$@"

#debug
echo $FILE

if [ -f $(which tar) ]
then
        tar zcPf "${FILE}".$(date +%s).tar.gz "${FILE}"
else
        echo "sorry, do you have 'tar' installed?"
fi

20141020

find files that contain string

# grep -Hirn "mystring" /path/to/dir
find . -print0 | xargs -0 -n1 -P8 grep -Hirn 

thanks to sifu enshu

20141019

error: Diskfilter writes are not supported

# cp -p /etc/grub.d/10_linux /etc/grub.d/10_linux.`date +%Y%m%d.%H%M`
# sed -i 's/quick_boot="1"/quick_boot="0"/' /etc/grub.d/10_linux
# update-grub
# reboot

share internet connection in linux via terminal


On access point side
  1. disable firewall
  2. enable packet forwarding
    # echo 1 > /proc/sys/net/ipv4/ip_forward
  3. set iptables rule for port forwarding
    # iptables -t nat -A POSTROUTING -o -j MASQUERADE
on client side:
  1. configure network interface so you can reach the access point
  2. set the access point as default gateway
    # route add default gw
  3. set dns resolution
    # echo nameserver 8.8.8.8 >> /etc/resolv.conf

20140507

Converting the numbers to decimal makes it easier to see which can be used:

# egrep "^ .*|System RAM" /proc/iomem | sed -e 's/ : / /g' -e 's/-/ /g' | awk '{;printf("%d bytes to %d bytes (%d M to %d M) - %s %s\n", strtonum("0x"$1), strtonum("0x"$2), strtonum("0x"$1)/1024/1024, strtonum("0x"$2)/1024/1024, $3, $4)}'

20140410

bind for chroot

cd /mnt/sysimage
mount -t proc proc proc/
mount --rbind /sys sys/
mount --rbind /dev dev/

20140401

mbr

446 bytes - Bootstrap
64 bytes - Partition table
2 bytes - Signature

deletes mbr only
# dd if=/dev/zero of=/dev/sdc bs=446 count=1

20140311

rename disk group

ensure file systems are not mounted
# vxvol -g currentdg stopall
# vxdg deport currentdg
# vxdg -n newdg import currentdg
# vxdg list
# vxrecover -g newdg -sb

20140116

20140115

increase vmware disk size and resize PV

increase vdisk size (vsphere client)
echo 1 > /sys/class/scsi_device/*/device/rescan

pvresize