How to Bulk Merge MKV and ASS Subtitle Files

Posted January 25th, 2015 in Linux

Today I had a folder of files like so:

My Video - 01.ass
My Video - 01.mkv
My Video - 02.ass
My Video - 02.mkv
My Video - 03.ass
My Video - 03.mkv

I wanted to add the .ass subtitle files to my .mkv containers but I had about 100 videos and didn’t want to do each one manually.

Using mkvtoolnix you can combine the video and subtitles like so (courtesy of Super User):

mkvmerge -o output.mkv input.mkv

Because our files are all nicely named we can use a for loop to iterate this command over them all simply replacing the .mkv extension with .ass in the third argument (See How can I rename all my *.foo files to *.bar, or convert spaces to underscores, or convert upper-case file names to lower case?):

for f in *.mkv; do mkvmerge -o "./muxed/$f" "$f" "${f%.mkv}.ass"; done

and that’s it! The fixed up files will be in your muxed subdirectory.

Read More »

How to Par2 Repair More Effectively

Posted January 23rd, 2015 in Linux

One of the most annoying things about SABnzbd is it’s failure to correctly repair broken downloads – especially when you download multiple repairable files in a single combined NZB. This often stems from SABnzbd not including all relevant par2 and part files during its repair – so the par2 command assumes far more missing files than there actually are. Below I’ll explain a method for easily including all relevant files for a (hopefully) more successful repair.


The Par2 Command

First let’s look at the par2 command:

$ par2
  par2 c(reate) [options] <par2 file> [files] : Create PAR2 files
  par2 v(erify) [options] <par2 file> [files] : Verify files using PAR2 file
  par2 r(epair) [options] <par2 file> [files] : Repair files using PAR2 files

Based on the above we need to call

par2 r <list of par2 files> <list of mkv parts>

But how do we get those lists?


Your Download

Let’s say I’ve (legally) downloaded of episodes 8 and 9 of MyShow!. My failed download folder might include the following files:

MyShow! - 08 [720p].mkv.001
MyShow! - 08 [720p].mkv.002
MyShow! - 08 [720p].mkv.003
MyShow! - 08 [720p].mkv.par2
MyShow! - 08 [720p].mkv.vol000+01.par2
MyShow! - 08 [720p].mkv.vol001+02.par2
MyShow! - 09 [720p].mkv.001
MyShow! - 09 [720p].mkv.002
MyShow! - 09 [720p].mkv.003
MyShow! - 09 [720p].mkv.004
MyShow! - 09 [720p].mkv.par2
MyShow! - 09 [720p].mkv.vol000+01.par2
MyShow! - 09 [720p].mkv.vol001+02.par2
MyShow! - 09 [720p].mkv.vol003+04.par2

We want to repair one episode at a time starting with episode 8. Here’s how I’d retrieve lists of just par2 then just the part files:

# Episode 8
ls *"- 08"*.par2 # Par2 files
ls *"- 08"*.[0-9][0-9][0-9] # Part files
# Episode 9
ls *"- 09"*.par2 # Par2 files
ls *"- 09"*.[0-9][0-9][0-9] # Part files


Putting it All Together

Combining par2 with my above lists results in:

par2 r *"- 08"*.par2 *"- 08"*.[0-9][0-9][0-9] # Ep 8
par2 r *"- 09"*.par2 *"- 09"*.[0-9][0-9][0-9] # Ep 9

You may also need to include *.mkv if that file exists but more often than not I’ve found it doesn’t.

Hope your repairs go a little smoother with this quick tip!

Read More »

How to Find and Remove @eaDir Directories on Synology NAS

Posted September 26th, 2013 in Linux

If you’ve installed the MediaServer or PhotoStation packages on your Synology NAS you’ve probably noticed @eaDir directories popping up everywhere. These are “hidden” folders equivalent to thumbs.db on Windows where the package stores thumbnail files associated with iTunes support. If you’re not using iTunes you don’t need these directories. You can remove them in two steps:

Disable the Service Creating Them

SSH in as root and run the following:

cd /usr/syno/etc.defaults/rc.d/
chmod 000

Remove the existing directories

Again in SSH use the following to locate them (cd to your volume root first):

find . -type d -name "@eaDir"

and if you’re feeling adventurous you can automatically delete them like so:

find . -type d -name "@eaDir" -print0 | xargs -0 rm -rf

Read More »

How to Mount a Broken EXT4 Drive

Posted June 2nd, 2013 (Updated 19 Jul 2013) in Linux

This morning I noticed one of my drives wasn’t mounted so I attempted to mount manually and got the following error message:

$ sudo mount /dev/sdi1 /mnt/my_drive/

mount: wrong fs type, bad option, bad superblock on /dev/sdi1,
missing codepage or helper program, or other error
In some cases useful info is found in syslog – try
dmesg | tail or so

Strange. Following the messages advice I checked out dmesg:

$ dmesg | tail

[ 213.962722] EXT4-fs (sdi1): no journal found


The Solution

If this happens to you, you can ignore the error and mount in readonly mode using the following command:

sudo mount -o loop,ro,noexec,noload /dev/sdi1 /mnt/your_broken_partition/

Thanks to Computer Forensics for their useful post on this issue.


Read More »

Create and Manage a RAID Array in Ubuntu

Posted December 30th, 2012 (Updated 10 Aug 2014) in Linux

The below is a collaboration of useful information I’ve found while attempting to build and maintain a RAID5 array consisting of 4 HDDs. This tutorial is a work in progress and I’m learning everything as I go. I’ve left relevant links in each section for more information and if you spot anything that could be done better or that I’m missing let me know in the comments below!

Read More »

Installing RocketRaid 2760a drivers on Ubuntu 12.10

Posted November 8th, 2012 (Updated 30 Dec 2012) in Linux

So I don’t forget, here’s a tutorial on installing the RocketRaid 2760a drivers and management utilities on Ubuntu 12.10. I’m using 64-bit but 32-bit should be the same – just substitute where appropriate.

Installing the Driver

The installation disc comes with an out of date version of the driver and kernel module. The way the installation works, we need to download and compile the kernel module then download the driver installer, drop the module into place and run the installer. Make sure you have appropriate compiler tools installed – to be safe just run

sudo apt-get install ubuntu-dev-tools

Download and extract the ones with kernel 3.x support from the HighPoint website:

mkdir ~/driver
cd ~/driver
# driver
tar -xvzf rr276x-ubuntu-11.10-x86_64-v1.1.12.0502.tgz
# kernel module
mkdir module
cd module
tar -xvzf  RR276x-Linux-Src-v1.1-120424-1734.tar.gz

Build and compress the kernel module for our driver installer:

cd rr276x-linux-src-v1.1/product/rr276x/linux/
# Ignore the warning about not being able to find him_rr2760x.o...doesn't seem to matter
gzip rr276x.ko
mv rr276x.ko.gz ~/driver/boot/rr276x$(uname -r)$(uname -m).ko.gz

And finally install the driver

cd ~/driver
sudo bash

This step succeeded! Now you can press ALT+F1 to switch back to the installation screen!

sudo bash

Update initrd file /boot/initrd.img-3.5.0-17-generic for 3.5.0-17-generic
Please reboot the system to use the new driver module.

sudo shutdown -r now

That should be everything! You can now test with

cat /proc/scsi/rr276x/*


Installing the RAID Management Software

Annoyingly the RAID management console is difficult to install to say the least. The GUI deb packages error when trying to install and HighPoint don’t even provide a deb for the command line version and to top it off the version of the command line utility on the driver CD is newer than the version on their site! For this reason I’ve provided the newer command line RPMs here.

Let’s get this thing installed.

Web version:

mkdir ~/driver/utility
mkdir ~/driver/utility/console
mkdir ~/driver/utility/web
cd ~/driver/utility/web
echo "rr276x" | sudo tee -a /etc/hptcfg > /dev/null
tar -xzvf WebGUI-Linux-v2.1-120419.tgz
sudo apt-get -y install alien
sudo alien -d hptsvr-https-2.1-12.0419.$(uname -m).rpm
sudo dpkg -i hptsvr-https_2.1-13.0419_amd64.deb


Command Line version:

cd ~/driver/utility/console
sudo alien -d hptraidconf-3.5-1.$(uname -m).rpm
sudo alien -d hptsvr-3.13-7.$(uname -m).rpm
sudo dpkg -i hptraidconf_3.5-2_amd64.deb

Run the web server:

sudo hptsvr

You should now be able to connect to it from your browser by navigating to http://localhost:7402 with username RAID and password hpt.


Further Reading

HOWTO: Get GUI hptsvr & hptraid 3.13 working on Ubuntu
HighPoint driver download page for RocketRaid 2760a

Read More »

Partitioning and Formatting New Disks in Linux

Posted November 4th, 2012 in Linux

The below is a quick guide to creating partitions on a newly purchased, unformatted disk. For this guide I’ll be formatting a new WD 2TB Black.


Find the disk you want to partition

# lsblk

sda 8:0 0 55.9G 0 disk
├─sda1 8:1 0 53.6G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 2.3G 0 part [SWAP]
sdb 8:16 0 1.8T 0 disk
sdc 8:32 0 1.8T 0 disk

Partitions appear as subitems. Notice sdb and sdc have no partitions – those are the disks I want to format.


Create the partition

# sudo fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xd3e43840.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help):

Below I’m using the default values to create one large partition for the whole disk.


Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended

Select (default p):
Using default response p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-3907029167, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3907029167, default 3907029167):
Using default value 3907029167

Command (m for help):

All done? Write!


The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

That’s all for partitioning! Take a gander at your fancy new partitions:

# lsblk

sda 8:0 0 55.9G 0 disk
├─sda1 8:1 0 53.6G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 2.3G 0 part [SWAP]
sdb 8:16 0 1.8T 0 disk
└─sdb1 8:17 0 1.8T 0 part
sdc 8:32 0 1.8T 0 disk
└─sdc1 8:33 0 1.8T 0 part


Format to NTFS

I’m choosing a quick format. You may choose instead to remove the -f argument for a proper one instead.

# sudo mkntfs -f /dev/sdb1

Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.


Optional: Name the drives

Because I’m running NTFS I can give the drives labels. Make sure you have ntfsprogs installed then enter:

# sudo ntfslabel -f /dev/sdb1 YourLabel


More Information

For more information on partitioning check out Chris Wakefield’s post here.
For a short and sweet howto on  formatting as NTFS check here.
Information on NTFS labels here.

Read More »

Remove a PPA and roll back changes in Debian

Posted May 10th, 2012 in Linux

If you’re a Ubuntu user, you may be familiar with ppa-purge. It’s a handy little automated script to remove a PPA and roll back the version of any apps installed from that PPA. Debian doesn’t have this nicety by default but there’s a relatively simple way to get something close.

Firstly, remove your PPA from /etc/apt/sources.list or from the /etc/apt/sources.list.d/ directory.

Do an update:

sudo apt-get update

Find any packages that are now obsolete:

aptitude search '?obsolete'

For me this returned the following:

# aptitude search '?obsolete'
i A libmysqlclient18      - MySQL database client library                                                                           
i A mysql-client-5.5      - MySQL database client binaries                                                                          
i A mysql-server-5.5      - MySQL database server binaries and system database setup                                                
i A mysql-server-core-5.5 - MySQL database server binaries                                                                          
i A ruby-passenger        - Rails and Rack support for Apache2 and Nginx

Now just remove the listed packages with apt-get remove and reinstall as necessary. It’s not quite the automated tool that ppa-purge is, but it’s a pretty good start.

Read More »

A few handy Exim commands

Posted May 9th, 2012 in Linux

I’ve been getting alot of frozen messages with Exim and needed to find out what they were so figured I’d document a few handy commands for doing so:

List messages in queue:

exim -bp

Show message header/body:

exim -Mvh <id> #For header
exim -Mvb <id> #For body

Delete all messages in queue:

exim -bp | exiqgrep -i | xargs exim -Mrm

Read More »

How to add an application to the ‘Other Applications’ list in Ubuntu

Posted May 6th, 2012 (Updated 9 May 2012) in Linux

It seems Gnome 3 removed the button allowing users to add specified applications into the ‘Other Applications’ list under ‘Open With’ in file properties. Until the functionality is restored, you can add applications manually by doing the below:

cp /usr/share/applications/gedit.desktop ~/.local/share/applications/your_app.desktop

Modify the contents of your_app.deskop to look something like the below:

[Desktop Entry]
GenericName=Your App
Comment=Edit text files
Exec=your_app %U

You can copy any .desktop file from /usr/share/applications so pick the one that closest resembles the application you’re adding. Below you can see komodo added to mine:

Komodo has been added to my 'Open With' list
Komodo has been added to my ‘Open With’ list

Read More »

Page 1 of 512345