Growing RAID 1

November 18th, 2009, 9:45 pm

The hard drive in my father’s computer finally died. It was a 74GB Raptor which was originally mine. He wanted to get his computer running as fast as possible, so I hopped on Newegg and ordered a 320GB drive for him.

For kicks, I decided to see if the drive was still under warranty. To my surprise it was! The drive was about 4 years old. I went through the RMA process and just got a replacement a few days ago.

I figured I would use the drive for my / (root),  /home, and swap partitions.

However, on my 2x 750GB HDs I had three raid arrays. One for /boot, / (root), and /home. I wanted to make the /home raid array into /data, but I no longer needed /boot or / (root).

Therefore I need to remove the two unneeded raid arrays and expand the last one, /home.

(more…)


Category: Hardware | Comment


OSS Start/Stop Script

November 4th, 2009, 5:37 pm

With Kernel 2.6.26.32-rc6 suspend-2-ram (aka sleep/standby) finally works on my machine! However OSSv4 does not support suspend/hibernate which means that OSS must be unloaded.

This scripts does the following:

In my case I have the script stop mpd. Then it kills ossxmix and attempts to unload oss. On spawn it starts mpd again and loads ossxmix.

Here it is:
oss_s.py

#!/usr/bin/env python

import subprocess
import sys
import os

#Daemons that need to be stopped
daemons=('mpd',)

#Programs that are safe to kill
kill_apps=('ossxmix','vlc','mplayer','xine','xmms','audacious',)

#Programs to load on spawn/resume
load_apps=('ossxmix -xb',)

#User to start apps as
user='pyther'

def start():
    p=subprocess.Popen(['soundon'])
    p.wait()    

    for d in daemons:
        p=subprocess.Popen(['/etc/rc.d/' + d, 'start'])
        p.wait()

    for a in load_apps:
        #Load the program as a user, not root
        os.system('sudo su -c \'' + a + ' &\' ' + user)

    return

def stop():
    for d in daemons:
        p=subprocess.Popen(['/etc/rc.d/' + d, 'stop'])
        p.wait()

    for a in kill_apps:
        p=subprocess.Popen(['killall',a])
        p.wait()

    o=subprocess.Popen(['soundoff'],stdout=subprocess.PIPE)
    output=o.stdout.readlines()

    list=[]

    for line in output:

        #If the line is empty skip it
        line = line.rstrip("\n")
        if line == '':
            pass
        #Otherwise lets split the line by spaces
        else:
            line=line.rsplit(' ')

            #Going to see if the first word is an int
            try:
                pid=int(line[0])
            except ValueError:
                #Must not be an int
                pass
            #Good it is an int... lets continue
            else:
                app=line[1] #The second word is the name of the app

                #If the list has no values, we will add the first running program
                if len(list) == 0:
                    list.append([pid,app])
                #Now lets check and see if the pid is already in the list
                else:
                    inList=0 #Set to False by default
                    #Scanning items already in the list
                    #If we find a match we set inList to True and break out of the loop
                    for x in list:
                        if int(x[0]) == int(pid):
                            inList=1
                            break
                    if not inList:
                        list.append([pid,app])

    if list:
        print("Apps that need to be killed:")
        for x in list:
            pid=x[0]
            app=x[1]

            subprocess.Popen(['notify-send', '-u', 'normal', '-i', 'audio-card', '-t', '120000', 'PID: ' + str(pid) + ' is using OSS', str(pid) + ' - ' + app + '\nPlease kill this application.' ])
            print("PID: " + str(pid) + " - " + app) 

            #Exit abnormally
            sys.exit(1)

    return

if __name__ == "__main__":
    if len(sys.argv) <= 1:
        print("Usage: start or stop")
        sys.exit(1)

    if os.geteuid() != 0:
        print "You must be root to run this script."
        sys.exit(1)

    if sys.argv[1] == "start":
        start()
    elif sys.argv[1] == "stop":
        stop()
    else:
        print "Usage: start or stop"

Usage is simple enough:
./oss_s.py start
./oss_s.py stop

Then to get the script to run on suspend/wake:
Save this as /etc/pm/sleep.d/48oss

#!/bin/bash

case $1 in
    hibernate)
        /home/pyther/bin/oss_s.py stop
    ;;
    suspend)
       /home/pyther/bin/oss_s.py stop
    ;;
    thaw)
        /home/pyther/bin/oss_s.py start
    ;;
    resume)
        /home/pyther/bin/oss_s.py start
    ;;
esac

Then make it executable
chmod +x /etc/pm/sleep.d/48oss

Of course you will have to modify the code as necessary.


Category: Code, Linux | Comment