-->

Cannot delete ZFS snapshot

While Deleting to delete a snapshot, i typed:

zpool destroy zfsdiskpool@Sat

and got:

cannot open 'zfsdiskpool@Sat': invalid character '@' in pool name

This is because to delete snapshots in ZFS, you should use ‘zfs destroy’ instead of ‘zpool destroy’. DOH!

zfs destroy zfsdiskpool@Sat

Script to run handbrake recursively through a folder tree

Handbrake is a fantastic tool for (among other uses), converting videos into mobile formats. It is extremely easy to use and can usually get a video properly converted in just a few clicks. To get Videos encoded for use on my phone, I use the “iPhone & iPod Touch” preset. It will convert your video to .mp4 as well as scale it down to a consumable size. This format will work on any smartphone I’ve seen.

My issue is that when converting a folder full of videos, I don’t want to have to use the gui to add a bunch of videos to the queue one by one. It’s a very clicky process. This simple bash script will walk handbrake through all the files in a selected folder (and it’s subfolders). This uses the find command to traverse recursively through a directory structure. It will place the transcoded file in the same folder as it’s source and change it’s extension to “.mp4″.

Usage: handbrakefolder.sh [FOLDER]
Run handbrake on all the files contained in [FOLDER]. (the current directory by default)

#!/bin/bash
#
# Change this to specify a different handbrake preset. You can list them by running: "HandBrakeCLI --preset-list"
#
PRESET="iPhone & iPod Touch"
if [ -z "$1" ] ; then
	TRANSCODEDIR="."
else
TRANSCODEDIR="$1"
fi
find "$TRANSCODEDIR"/* -type f -exec bash -c 'HandBrakeCLI -i "$1" -o "${1%\.*}".mp4 --preset="$PRESET"' __ {} \;

Save that into a .sh file like “handbrakefolder.sh” and grant it the execute permission (chmod +x handbrakefolder.sh).

Thanks to Vinnie and http://mywiki.wooledge.org/UsingFind for their help in this.

Now you can simply execute this script against a folder containing your video files. like this:


For a folder structure like this:
Videos
-> show1
    vid1.avi
-> show2
    -> season 1
        ep1.avi
        ep2.avi
    -> season 2
        ep1.avi
        ep2.avi
-> show3
    vid1.avi
    vid2.avi

hostname% handbrakefolder.sh Videos
...
....
...
When done, it will look like this:
Videos
-> show1
    vid1.avi
    vid1.mp4
-> show2
    -> season 1
        ep1.avi
        ep1.mp4
        ep2.avi
        ep2.mp4
    -> season 2
        ep1.avi
        ep1.mp4
        ep2.avi
        ep2.mp4
-> show3
    vid1.avi
    vid1.mp4
    vid2.avi
    vid2.mp4

Write zero’s to disk Infinite loop

I was bored… So this is a little bash script i wrote that will write zero’s to a hard disk infinately until you press CTRL+C. It uses dcfldd instead of plain dd because i like the progress output it provides.

#!/bin/bash
echo -e "Which disk would you like to wipe out? (sda, sdb, sdc)?   \c"
read DISK
read -p "You picked "$DISK", are you sure? (y/n)" -n 1
if [[ $REPLY =~ ^[Yy]$ ]]
then
C=1
for (( ; ; ))
do
        echo -e "\nStarting zero Sweep number "$C" ..."
        dcfldd if=/dev/zero of=/dev/$DISK
        echo "Zero's written to Disk "$C" time(s)"
        echo "[ hit CTRL+C to stop ]"
        let C=C+1
done
fi

Convert High-Def MKV to play on xbox 360 using Linux

There are a million different tutorials out there on how to convert a MKV file into a format that an xbox360 will play. You may have found, like i did, that most of them use 50 different questionable pieces of software to manipulate individual tracks and separate the mkv, etc, etc… I think those are ridiculous.

Please read the FAQ regarding xbox360 file format compatibility.  It may help you pick better options for your particular files than the general ones i offer below.

The solution is simple: Use Avidemux.

  1. Install avidemux. To install it is simple. It’s in the Ubuntu repositories and I imagine you can also find it in other distros quite easily.
  2. Open avidemux and open the mkv you want to convert. If prompted some garbage about 264 and safemode, just use safe mode and dont worry about it.
  3. Select File -> Properties. This will tell you some info on the formats in use in your video file. Take this opportunity to identify what the xbox doesn’t like. When you are finished, click OK. If you want a second opinion, open up the folder with your mkv in it. Right click -> properties -> Audio/Video tab. This will also tell you the video and audio formats.
  4. We obviously know that it wont play a video in a MKV container, so first thing to do is change the “Format” dropdown to say “MP4″ (you can, of course use AVI, but the majority of files I run into are h.264 and aac audio. For this combo, you want mp4…)
  5. From the Properties menu, recall the video codec. H264 files show as “AVC1″ inside of avidemux. I’m sure theres a technical reason for this, but do you want to talk about it or watch your video?
    Most of the time, you can leave the video droptown in avidemux on “Copy” this is nice because it means that your processor wont be re-encoding the video. This saves you quality and time.
  6. From the properties menu, recall the audio codec. If you have a video with AAC stereo audio, leave the dropdown on “copy”.
    This is where most of my files need some love. Many MKV’s have 5.1 surround audio tracks. This is great, but not for an xbox360. To mix the audio down to stereo, select AAC on the audio dropdown, then click “filters”. In the mixer dropdown, select “stereo”.
  7. Click “save”. Avidemux will prompt you for a filename for the converted file. It does not default a file extension, so do yourself and your xbox a favor and add one yourself like “<videoname>.mp4″.

Once avidemux is finished with your file, it’s ready to go.

http://avidemux.sourceforge.net/

Script to run handbrake on an entire folder

UPDATED 8-10-10:
This script has been superceeded by its newer version at http://www.surlyjake.com/shell-scripting/script-to-run-handbrake-recursively-through-a-folder-tree/. The new version features all of the previous features, but can also traverse recursively through a folder structure.

#!/bin/bash
if [ -z "$1" ] ; then
	TRANSCODEDIR="."
else
TRANSCODEDIR="$1"
fi
for file in "$TRANSCODEDIR"/*
do
	HandBrakeCLI -i "${file}" -o "${file}.mp4" --preset="iPhone & iPod Touch"""
done

Save that into a .sh file like “handbrakefolder.sh”

 

Switch to our mobile site