Your Linux Boot Disk Full?

While trying to run a YUM update on a CentOS server today, I got an error message about my /boot partition being full. I ran a df -h and sure enough, there was only 100k left. (My standard install uses 100MB for the boot partition.)

Here’s what I did to fix it.

rpm -q kernel

That returns a list of installed kernel updates. In my case I had more than 25…

kernel-2.6.9-22.EL
kernel-2.6.9-42.0.8.EL
kernel-2.6.9-42.0.8.plus.c4
kernel-2.6.9-42.0.10.plus.c4

kernel-2.6.9-67.plus.c4
kernel-2.6.9-67.0.1.EL
kernel-2.6.9-67.0.1.EL.plus.c4
kernel-2.6.9-67.0.4.plus.c4
kernel-2.6.9-67.0.7.plus.c4
kernel-2.6.9-67.0.15.plus.c4
kernel-2.6.9-67.0.20.EL

To remove some of the older ones, run:

yum remove kernel-2.6.9-42.0.10.plus.c4

or to get several at one time:

yum remove kernel-2.6.9-42.*

I recommend leaving a few of the older ones in case you need to revert one day.

Using Linux Tail to Trim Your Files

This tip is for my friend Scarb. For years I’ve used the Linux command “tail -f” for watching logs… but only recently did I discover its versatility for extracting parts of files.

Need to grab only the last 25 lines of a file?

tail -n 25 somefile.txt

How about the last 200000 bytes redirected to another file?

tail -c 200000 somefile.txt > newfile.txt

Handbrake batch conversion using CLI shell script

I contributed to a Handbrake forum a while back. Thought you might find it useful too.

This is my evolving script for transcoding DVDs from MacTheRipper.

1) Save the file in a logical place (I keep it in the Movies Folder… same place I rip movies to). It will loop through all titles longer than X.

#!/bin/sh
# usage is ./thisScript.sh minimumDuration SomeDirContainingVIDEO_TS
# duration is set in minutes ("30" equals 30 minutes)
# specify the container directory for the VIDEO_TS directory
# example ./handbrake-longer-than.sh 30 24_SEASON6_D1
#set default path to HandBrakeCLI
PathToHandBrakeCLI=/some/path/to/HandBrakeCLI
if [ "${1}x" = "x" ]; then
echo "Minutes not provided"
exit
fi
if [ "${2}x" = "x" ]; then
echo "VIDEO_TS path not provided"
exit
fi
time=$1
export time
for i in $(find $2 -type d -name VIDEO_TS) ; do
for title in $($PathToHandBrakeCLI -t 0 -i $i -L 2>&1 | grep "has length" | sed 's/sec//' | sed 's/[()]//g' | awk '$8 > (60 * ENVIRON["time"]) { print $3 "-" $5 } ') ; do
#this names the title for the output file
titlenum=$(echo $title | cut -f 2 -d '-')
# you can change the preset or any other variables here
$PathToHandBrakeCLI -i $i -o ${2}-title${titlenum}-appletv.m4v --preset="AppleTV" -2 -T -P -t ${titlenum}
#output example: 24_SEASON6_D1-title1-appletv.m4v
done
 done

2) Within the script, set the path to your HandBrakeCLI app on line 9.

3) Don’t forget to run this before trying to execute it:
chmod 777 ./handbrake-longer-than.sh

4) Execute it like this:
./handbrake-longer-than.sh 30 24_SEASON6_D1

Where “30” is the shortest title you want to export and “24_SEASON6_D1” is the name of the folder containing your VIDEO_TS directory.