20110511: raidcheck.sh
by dervish on May.11, 2011, under Scripts
#!/bin/bash
# raidcheck.sh – Search for SAS1064 or Adaptec AAC-RAID controller and report failed/degraded drives
#
# 20091222 jah – Created by Jamey Hopkins
# 20110511 jah – Added support for more than 1 drive. Still defaults to controller 1.
# rm UcliEvt.log
# Code/error message cleanup/clarification.
process_mpt-status() {
ID=`grep Found status.0 | cut -f2 -d= | cut -f1 -d,`
/usr/sbin/mpt-status -i $ID -s >status.1
C1=`cat status.1 | grep phys_id | wc -l`
C2=`cat status.1 | grep phys_id | grep ONLINE | wc -l`
[ “$C1” = “0” ] && echo “No Drives Found”
[ “$C1” = “$C2” ] && echo “$C2 of $C1 Drives Are Online”
#echo “Controller ID=$ID”
if [ $C2 -lt $C1 ]
then
echo “ERROR: Failed SAS Drive Found”
echo “$C2 of $C1 Drives Are ONLINE”
echo
exit 2
fi
}
AACRAID=”0″;SAS1064=”0″
# search for SAS1064 controller
DATA=`/sbin/lspci | grep SAS1064 2>/dev/null`
if [ “$DATA” != “” ]
then
#echo Process SAS
SAS1064=”1″
# check if mptctl module is loaded
MPT=`/sbin/lsmod | grep mptctl 2>/dev/null`
[ ! -n “$MPT” ] && echo “mptctl module not loaded”
/usr/sbin/mpt-status -p >status.0 2>&1
grep “not found” status.0 >/dev/null
if [ “$?” = “0” -a ! -n “$MPT” ]
then
echo “mpt-status not found in /usr/sbin”
else
process_mpt-status
fi
fi
# search for Adaptec AAC-RAID controller
DATA=`/sbin/lspci | grep AAC-RAID 2>/dev/null`
if [ “$DATA” != “” ]
then
#echo Process AAC-RAID
AACRAID=”1″
STATE=`/usr/StorMan/arcconf getconfig 1 | grep “Logical devices/Failed/Degraded” | cut -f2 -d: | xargs echo`
#echo state is -${STATE}-
#STATE=”1/0/1″ # Set STATE for Testing
STATE2=`echo $STATE | cut -f2 -d’/’`
STATE3=`echo $STATE | cut -f3 -d’/’`
if [ “$STATE2” != “0” -o “$STATE3” != “0” ]
then
echo “ERROR: AAC-RAID Error – Devices/Failed/Degraded $STATE”
echo
exit 2
else
echo “AAC-RAID: No Failed or Degraded Drives Found.”
fi
fi
if [ $SAS1064 = 0 -a $AACRAID = 0 ]
then
echo “No supported controllers found.”
fi
rm status.0 status.1 >/dev/null 2>&1
rm UcliEvt.log >/dev/null 2>&1
exit 0
Move LVM Volume Group To New Larger Drive
by dervish on May.09, 2011, under Linux
Shutdown server and add new drive to system, then after power on:
fdisk /dev/sdb # set partion type to 8e
pvcreate /dev/sdb1
vgextend Volume00 /dev/sdb1
pvmove -n /dev/mapper/Volume00-external /dev/sda2 /dev/sdb1
lvextend -L +47G /dev/mapper/Volume00-external
ext2online /dev/mapper/Volume00-external
sdb=New Drive, Volume00=Volume Group, Volume00-external=Logical Volume
Support Commands: lvdisplay, vgdisplay sfdisk -s, df
Create Additional Swap Space
by dervish on May.05, 2011, under Linux
Use a File for Additional Swap Space
If you don’t have additional disk, you can create a file on your filesystem, and use the file for swap space.
Using dd, create a swap file with the name “swap_file” under /root directory with a size of 4096MB (4GB).
# dd if=/dev/zero of=/root/swap_file bs=1M count=4096
4096+0 records in
4096+0 records out
4294967296 bytes (4.3 GB) copied, 136.328 s, 31.5 MB/s
# ls -lh /root/swap_file
-rw-r–r– 1 root root 4.0G May 5 14:43 swap_file
Change the permission of the swap file so that only root can access it.
# chmod 600 /root/swap_file
Mark this file as a swap file using the mkswap command.
# mkswap /root/swap_file
Setting up swapspace version 1, size = 4194300 KiB no label, UUID=982c0db9-d522-4f08-a072-29168de28c64
Enable the newly created swapfile.
# swapon /root/swap_file
To make this swap file available as a swap area even after the reboot, add the following line to the /etc/fstab file.
# grep swap_file /etc/fstab
/root/swap_file swap swap defaults 0 0
Verify whether the newly created swap area is available for your use.
# swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 1048572 9272 -1
/root/swap_file file 4194300 0 -2
# free
total used free shared buffers cached
Mem: 508772 492700 16072 0 39384 311016
-/+ buffers/cache: 142300 366472
Swap: 5242872 9272 5233600
Note: In the output of swapon -s command, the Type column will say “file” if the swap space is created from a swap file.
If you don’t want to reboot to verify whether the system takes all the swap space mentioned in the /etc/fstab, you can do the following, which will disable and enable all the swap partition mentioned in the /etc/fstab.
# swapoff -a
# swapon -a
To increase swap by extending a Logical Volume:
# cat /proc/swaps
Filename Type Size Used Priority
/dev/mapper/Volume00-lv_swap partition 16777208 208 -1
# swapoff /dev/Volume00/lv_swap
# lvextend -L +900M /dev/Volume00/lv_swap
# mkswap /dev/Volume00/lv_swap
# swapon /dev/Volume00/lv_swap
Forward Mail to SMTP Server
by dervish on May.02, 2011, under Linux
1. Edit/create the following options in /etc/mail/sendmail.mc:
define(`SMART_HOST’, `your-smtp-server.com’)
FEATURE(authinfo)dnl
2. Edit/create /etc/mail/authinfo and add the following line:
AuthInfo:<your-smtp-server> "U:<your-smtp-user>" "P:<your-smtp-password>" "M:DIGEST-MD5"
3. Build new sendmail.cf and authinfo.db
make -C /etc/mail
4. Restart sendmail:
/etc/init.d/sendmail restart
5. Send test email message
mail user@host.com
Optional test: sendmail -bv user@host.com
Canonical Releases Ubuntu 11.04 “Venereal Vista”
by dervish on Apr.28, 2011, under Linux
THAWTELESS, Star City, Monday (NNGadget) — Canonical, Inc. has announced the release of Ubuntu 11.04, “Venereal Vista,” based on the Unity Vista desktop, which only 5 out of 11 first-time users managed to crash in final testing two weeks ago.
Unity is Canonical’s response to the GNOME 3 shell, which uses 1 gigabyte of RAM and four processor cores to exquisitely render a single button in the centre of the screen in beautifully anti-aliased text; when pressed, GNOME tells the user to switch off the computer and do something useful with their life, such as showering.
“This was just not up to the user expectations of Canonical’s vision of the desktop,” said Mark Shuttleworth, from his castle high on a crag in West London. “So we added a ‘minimise’ button too.”
Design is at the centre of Shuttleworth’s roadmap for Unity. “I woke up one day and thought, ‘Gosh, I’d really like to make using my universal general-purpose computer that I can do ANYTHING with feel like I’m using a locked-down three-year-old half-smart phone through the clunky mechanism some l33t h@xx0r used to jailbreak it, I can’t think of a better user experience.’ We’re not quite there yet, but this gets Unity a lot of the way.”
Picture: Unity is made of arse [newstechnica.com].
Shuttleworth foresees an exciting future for Linux for the general Internet user. “It’ll be a whole world of Linux devices, which millions of people will use all the time, everywhere! Of course, at the moment those are called ‘phones’ and run Android.”
David Gerard