Users in the Windows world are very used to referencing PC’s via their NetBIOS names instead of their IP address. If your PC has a dynamic IP address (DHCP-assigned) of 192.168.0.12 and its hostname (computer name) is “gordon”, Windows users can happily jump into a command line or an Explorer window and ping the name “gordon” which will magically resolve to 192.168.0.12.
If your host is not configured with a Hosts file entry on your local PC or a DNS entry to associate a name with an IP address, Ubuntu can only use the IP address of that PC to communicate with it which means you have to remember what that IP address is with your feeble grey-matter in your head. Likewise, Ubuntu will not respond to a Windows PC pinging its NetBIOS name because Ubuntu does not use NetBIOS at all by default and so it will ignore such requests.
So how do we get Ubuntu to resolve NetBIOS names like Windows? And how can we allow Windows to ping Ubuntu like another Windows PC? Read on…
Let’s illustrate the problem first. You’ll need a Windows PC on your network to test this. For this article, the Ubuntu PC will be called “gordon” and the Windows PC will be called “alyx”.
On either PC, if you open a terminal or Command Line window and ping the opposing machine, eg:
$ ping alyx
or
C:\> ping gordon
You get an error stating that the host cannot be found. Now in the case of Windows, if you were to ping another Windows PC instead of an Ubuntu PC, you can ping its name with no problem.
Let’s sort this out, shall we?
Allowing Ubuntu to ping Windows NetBIOS names
Ubuntu is setup for Linux use, not Windows use, so we need to install a package that will allow Ubuntu to more readily mix in with Windows networks and use NetBIOS. This package is called “winbind”.
Open a terminal and type in the following at the terminal prompt:
$ sudo apt-get install winbind
Once installed, we need to tell Ubuntu to use WINS (as provided by winbind) to resolve host names. Type in:
$ sudo gedit /etc/nsswitch.conf
…which will open the file into the Gnome Editor.
Scroll down to the line that starts with “hosts:”. In Ubuntu Jaunty, it looks similar to this:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
Add the word “wins” on the end of this line such that is now looks like:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 wins
Save and exit the editor.
Now let’s ping the name of our Windows box again.
$ ping alyx
…and it now resolves!
Pat yourself on the back.
Allowing Windows to ping Ubuntu NetBIOS names
This is just one half of the equation. We now need to allow Windows to be able to ping Ubuntu PC’s using its NetBIOS name. This requires Ubuntu to recognise and respond to that request. We need to setup a server daemon to do this. In Ubuntu, this particular server daemon is called Samba.
Installing Samba is simplicity itself. Open a terminal and type in:
$ sudo apt-get install samba
Once that has finished, your Ubuntu PC will automagically respond to all NetBIOS queries for its hostname straight away, and that’s not just from Windows machines, but other Ubuntu machines (configured with the “winbind” package) as well.
This article detailed how to decrypt just about every movie under the sun except for a newer type of protection called “BD+” which I never got around to supplementing my original article with.
What is “BD+” protection? Well in short, it’s the deliberate corruption of random parts of the video track of the movie (well, OK – that is a highly simplified definition as BD+ protection can do a lot more than that, but the end result is the same – to prevent unauthorised playback which includes ripping). The idea BD+ is that when you rip the title, you can still watch the movie, but with some or all of the screen corrupt at various stages in the movie which well and truely ruins the movie-watching experience, especially since you paid good money for it and should not be forced to buy a dedicated consumer Blu-ray player when you’ve got a perfectly good PC that can do the same task.
But hang on, if the movie is deliberately corrupt, then how come it plays fine in a stand-alone consumer Blu-ray player or PlayStation3 console?
Well, let me tell you about that and how to get around it yourself.
I have to give credit to the movie studios for this one. It’s a simple, and annoying, method of protection. But as with anything, it was eventually reverse-engineered and broken, and neat little tools were developed to allow us consumer types to backup, or watch in our preferred way, our movies bought with our hard-earned cash.
So what’s this BD+ thing all about? Basically after the movie is mastered and just before being pressed to discs, an extra step is taken where by random parts of the movie data stream are deliberately exchanged with random data or removed altogether, thus corrupting the video stream. A record is kept, however, of what parts of the movie have been changed – a table listing where, when and what data needs to be put back into the movie stream in order to watch the movie back in its original uncorrupted format. This table is called a “conversion table”, and it is processed by your Blu-ray player while you watch the movie, with the correct data substituted back into the video stream before the image hits your screen, thus resulting in a proper uncorrupted picture.
So how do we get around BD+? Well, all we have to do is follow this conversion table ourselves and correct the corrupted data as the title is decrypted.
As I showed in my previous article, the DumpHD application is brilliant and it has been extended by the author KenD00 to allow the “plugging in” of another program called the “BD VM Debugger”. What this program does is simple – it executes the Java Virtual Machine that runs the conversion table in concert with the normal decrypting process which happens when the disc is played in your normal BD player, patching up the stream as it goes. The end result is a clean decryption with no corrupt video stream.
This tutorial was written using Ubuntu Jaunty but should work with Intrepid and should definitely work with Karmic and beyond as well.
DISCLAIMER: This article describes decrypting BD titles using an Intel or AMD based PC with Ubuntu Linux. At this time of writing you cannot use Ubuntu installed on a PlayStation3 console to deal with BD+ copy protection because the BD VM Debugger and AACS Keys applications are not available for the PPC processor used by the PS3.
So let’s set this up, but first – since my last article, DumpHD has been updated to 0.61 so let’s upgrade this first. Go and download yourself a copy.
Extract the archive out by either double-clicking on it or via the terminal. You should get a “dumphd-0.61″ directory.
If you are upgrading from an older version of DumpHD, copy over the “KEYDB.cfg” file, overwriting the archive copy. No point losing your collection of keys accumulated thus far.
You’re done for this bit.
The AACSKeys program (which extracts the decryption key for the Blu-ray title and can automatically update your “KEYDB.cfg” file for you when you insert a new Blu-ray title) has also been updated to 0.4.0c since my last article, so go download yourself a copy of that as well.
Extract the archive out by either double-clicking on it or via a terminal. You should get a “aacskeys-0.4.0c”.
Copy the “ProcessingDeviceKeysSimple.txt” and “HostKeyCertificate.txt” into the “dumphd-0.61″ directory.
Copy over the “libaacskeys.so” file located in the “/lib/linux32/” OR “/lib/linux64/” directories (depending on which architecture you’re using) to the “dumphd-0.61″ directory. Do NOT copy or create the “/lib/linux32″ or “/lib/linux64″ directories themselves. Copy the library file only.
You’re done for this bit.
Right, let’s get the BD VM Debugger installed. As of this writing, the current version is 0.1.5. Go and download yourself a copy.
This archive is provided as a 7zip file. Ubuntu does not have out-of-the-box support for this archive format, so install it first with:
$ sudo apt-get install p7zip-full
Once installed, extract the archive either by double-clicking on it like any normal archive, or via the terminal as follows:
$ 7z e bdvmdbg-0.1.5.7z
Copy over the everything into the “dumphd-0.61″ directory except the “changelog.txt”, “readme.txt” and “debugger.sh” files since you don’t really need them, but there’s no harm copying them anyway.
That’s it!
You should now have a total of at least of 17 files and two directories inside the “dumphd-0.61″ directory (if you are setting up these tools for the first time, you will only have 15 files instead, as two of them – conv_tab.bin & hash_db.bin – are generated by DumpHD in conjunction with the BD VM Debugger).
Now let’s try decrypting a BD+ protected Blu-ray title. In this example, I will use the Australian release of “Day Watch”, the sequel to the Russian epic “Night Watch”.
NOTE: Your ability to decrypt a given Blu-ray title, BD+ protected or not, will ultimately depend on the MKB version of the disc. As of this writing, DumpHD can only decrypt up to MKB version 10. Newer discs using version 11 or later can only be decrypted once suitable decryption keys are uncovered and added to the “ProcessingDeviceKeysSimple.txt” file in the “dumphd-0.61″ directory.
The obtaining of the decryption key of the Blu-ray title also requires the player authentication mechanism of your Blu-ray drive to be bypassed, or through use of a drive that deliberately does not have this feature such as some imported drives from China. In the case of my LG GGC-H20L drive, I used a modified firmware so that the drive always gave up the disc’s decryption key regardless of what player certificate I used – blacklisted or not.
Start the DumpHD program by double-clicking on the “dumphd.sh” icon. You will be asked if you want to run the script file. Click on the “Run” button.
When the DumpHD GUI appears, make a note of the messages in the bottom pane to ensure that AACSKeys and the BD VM Debugger was found and loaded OK. You should see the following information:
DumpHD 0.61 by KenD00 Opening Key Data File… OK Initializing AACS… OK Loading aacskeys library… OK aacskeys library 0.4.0 by arnezami, KenD00 Loading BDVM… OK BDVM 0.1.5
Insert the Blu-ray title into your Blu-ray drive.
Next to the “Source” section at the top-right of the DumpHD window is a “Browse” button. Click on it.
Navigate to the path of your Blu-ray drive (generally “/media/cdrom” will work fine). and hit the OK button.Choosing a source to rip from. Click for full size.
DumpHD will read the disc and will pass it through AACSKeys to identify the title’s descryption key. If it is successful, it will output some data about the disc in the lower pane. In the case of my Day Watch title, it shows the following:
Initializing source… Disc type found: Blu-Ray BDMV Collecting input files… Source initialized Identifying disc… OK DiscID : 73886D08811073F45AD8C75012689097E17EBD3C Searching disc in key database… Disc found in key database
This is good. We can decrypt this. If the title is not one you have ripped before, you have the option to click on the “Title” button at the top-left of the DumpHD window to give the movie a name in your Key Database.
In the “Destination” section on the right, click on the “Browse” button.
Choose a place to dump the decrypted disc to. Note that most titles will dump at least 20GB worth of data and in some cases 50GB. Ensure that you have enough hard-drive space in the location you choose to dump to.
We’re ready to rock and/or roll. Click on the “Dump” button and decryption will begin, automatically executing the BD VM and applying the Conversion Table to correct the deliberate corruption in the video stream. Here’s a small extract of what you will see in the lower pane of the DumpHD window:
AACS data processed Initializing the BDVM… OK Executing the BDVM… OK Parsing the Conversion Table… OK Processing: BDMV/BACKUP/CLIPINF/00000.clpi Processing: BDMV/BACKUP/CLIPINF/00001.clpi Processing: BDMV/BACKUP/CLIPINF/00002.clpi etc…
And after awhile it will finish with something like: Processing: BDMV/STREAM/00211.m2ts Searching CPS Unit Key… #1 0x0000000000 Decryption enabled Processing: BDMV/STREAM/00212.m2ts Searching CPS Unit Key… #1 0x0000000000 Decryption enabled Processing: BDMV/index.bdmv Disc set processed
That’s it! You’ve successfully decrypted the disc and fixed up the corrupted video track. Identify and playback the actual movie M2TS file using a player like MPlayer or VLC, and you should now find that it contains no corruption whatsoever. In the case of Day Watch, the movie file was under BDMV/STREAM/00012.m2ts identifiable simply because it was the largest file in the directory. Using MPlayer, you can play this file with:
$ mplayer -fs BDMV/STREAM/00012.mt2s
Thankfully this title does not have the movie broken up into multiple files (I’ll be writing another article soon showing you how to deal with multi-part movies).
Following up my previous article of how to pair your Bluetooth mobile phone with Ubuntu Intrepid, I present this updated article for pairing your mobile phone using the updated version of the Bluez Bluetooth stack and the newer and better Blueman applet for Jaunty which greatly simplifies the process of pairing Bluetooth devices and transferring files to your mobile phone.
First up, you need to follow the first 15 steps of my guide on how to seutp a Nokia N95 mobile phone as a Mobile Broadband Device because we need to update the version of the Bluez Bluetooth stack and pair your mobile phone. Once you get to step 15 where it asks about connecting the phone as a dial-up networking device, you can either choose to continue setting that up all the way through to Step 22 (after all, you might find DUN to be of genuine use to you if you’re a Mobile Internet kind of guy), or choose “Don’t connect” instead and just finish at Step 15 and continue on with this article.
Once you’re Bluetooth stack is updated and your mobile phone is paired, transfrerring files is simplicity itself:
Do a left-mouse click on the Bluetooth icon in your system tray. The Bluetooth Devices window will appear showing you your available or previously paired devices. Your mobile phone will be one of them.
Do a right-mouse click on your mobile phone and choose “Browse” from the menu that appears (or select the mobile phone with the left-mouse button and then click on the “Browse” button in the toolbar).
NOTE: If you get a “Could not display ‘obex://[xxxxxxx]/’.” error when trying to browse, it means that the Bluetooth connection has not re-established itself between your PC and your phone after a previous pairing (ie: “Host is down”. To fix this, click on the “Search” button in the toolbar which will “awaken” your phone’s Bluetooth awareness and then choose “Browse device” again. You should also set your PC and phone to be “trusted” or “authorised” on both sides to prevent timeouts caused by either end asking you for permission to establish the connection.
If your PC is setup as being “trusted” or “authorised” on your phone, within a second or so a Nautilus window should appear showing you the content of your mobile phone, or in the case of my Nokia N95, two Windows-like folders named “C:” and “E:” which represent the phone’s internal memory and my 8GB SD card in the phone. You can browse them like any ordinary folders including copying and pasting files. An icon for the phone will also appear on the desktop (I’m using a custom icon here).
When you have finished dealing with the files on your phone, you need to cleanly disconnect the phone and end the Bluetooth session. You can do this one of two ways. Either click on the “Eject” triangle icon next to your phone’s name in the Places list of the Nautilus window, or in the Bluetooth Devices window, do a right-mouse click and choose “Disconnect Device” from the menu.
All current “IBM-Compatible” PC’s use a Basic Input/Output System also known as a BIOS. It’s a program that tells the PC how to start up when you switch it on, raises any critical faults with the system and then passes control to an operating system on a boot medium.
As time goes on, like any program, bugs are found, improvements are made, and the manufacturer of your PC’s motherboard will provide updates to the BIOS, usually supplied as a small downloadable file. Normally it is usually intended that you reboot your PC onto a DOS-compatible boot floppy disk and run the BIOS update program to install the new BIOS firmware. These days this process has been a bit simplified what with Windows users generally being able to do this from within Windows itself and even more recently, from the BIOS itself or even though starting the system on a FAT16-formatted USB stick.
This is all well and good, but what if you have an older system that cannot be flashed from Windows? What if you don’t even have Windows? What about a system that still relies on booting from a floppy disk to flash the BIOS? I don’t know about you, but I highly doubt any of the remaining floppy disks in my garage work anymore, and besides that, there’s a good chance that the floppy drive itself on older PC’s probably doesn’t work anymore.
So what can you do?
Well, we can utilise a floppy disk image that ultimately boots from your hard-drive, but acts and operates exactly like a DOS floppy disk would.
Pre-requisites:
A boot floppy disk image. You can grab from from the FreeDOS project. FreeDOS is a compatible open source re-invention of Microsoft or IBM DOS. For our needs, we will use the 1.44MB OEM floppy which has just enough on it to boot the disk and that’s it. The filename is called FDOEM.144.gz.
Some free space under /boot. This won’t be a concern for most users, but some people, including myself, choose to partition off space for /boot rather than include it as part of the root filesystem partition. You will need about 2MB of space.
Some floppy disk image manipulation tools. We will be using MTools for the task, available in the Ubuntu repositories.
The new BIOS file for your motherboard.
The DOS-based BIOS flashing program executable.
OPTIONAL: Wine may be required if the BIOS file is provided as a self-extracting Windows executable. In most cases, the flashing program is usually included in the same archive.
These instructions were written with Ubuntu Jaunty in mind but should work on any version of Ubuntu.
Process:
First up, download the FDOEM.144.gz file from the FreeDOS website.
Extract the image file from the archive either using Ubuntu’s archive manager, or at a terminal use the command:
$ zcat FDOEM.144.gz >dosfloppy.img
Now we need to install some tools so we can manipulate the image (note that you may already have these tools installed):
$ sudo apt-get install syslinux mtools
Extract your BIOS file from the archive you downloaded from your motherboard’s manufacturer. If the file was called “bios123.zip”, unzip it with the following command:
$ unzip bios123.zip
NOTE: If your BIOS file is a self-extracting executable (eg: “bios123.exe”, then install WINE with:
$ sudo apt-get install wine
…and then execute the Windows binary via Wine with:
$ wine bios123.exe
…then let the self-extractor extract the files. Retrieve the BIOS file (and if available, the BIOS flashing program executable) from what was extracted.
Let’s copy the BIOS file and the flashing program onto the boot floppy image. In this example, the BIOS file is called “bios123.bin” and the flashing program is called “flash.exe”:
$ mcopy -i dosfloppy.img bios123.bin flash.exe ::
Now let’s list the contents of the floppy image to confirm that the files were copied:
$ mdir -i dosfloppy.img :: Volume in drive : is FREEDOS Volume Serial Number is 188F-6C25 Directory for ::/ COMMAND COM 66090 2003-12-10 7:49 sys com 9221 2005-07-18 19:58 AUTOEXEC BAT 67 2004-02-22 10:16 CONFIG SYS 52 2004-02-22 10:17 README 1486 2004-02-22 12:50 BIOS123 BIN 1048576 2009-08-11 22:34 FLASH EXE 26351 2009-08-11 22:34 7 files 1 151 843 bytes 258 048 bytes free $
The floppy disk is ready! Now to set it up so we can boot it.
Now we need to make an entry in the GRUB boot menu for it so we can choose it as a boot option when we start the PC. First open the GRUB menu.lst file in your favourite editor:
$ sudo gedit /boot/grub/menu.lst
Scroll right down to the very bottom of the file and add the following lines:
title Boot floppy for BIOS flashing kernel /boot/biosflash/memdisk initrd /boot/biosflash/dosfloppy.img boot
NOTE: If your /boot directory is on its own partition (like how I have it on my own system), you need to omit the “/boot” bit from all lines above, thus:
title Boot floppy for BIOS flashing kernel /biosflash/memdisk initrd /biosflash/dosfloppy.img boot
Save your changes and quit the editor.
You are now ready to boot! Shutdown and restart your system. When your GRUB menu appears, you will see an entry called “BIOS floppy for BIOS flashing” at the bottom of the menu. Select it and you should very quickly be presented with the familiar A:\> prompt. You can now launch your BIOS flashing program and flash your BIOS!
When you are done with the floppy environment, just press CTRL + ALT + DEL to reset your PC (or after a BIOS flash you should ideally physically switch off and then back on instead).
A PPA is a Personal Package Archive hosted by the ubuntu.com servers that contains binaries and/or source related to a project. The project can be anything from a new application to a backport of an existing one. A good example is the easy availability of OpenOffice.org 3.0.1 to Intrepid users before Jaunty came out rather than having to deal with the mess of packages from Sun’s own website.
PPA’s can be wholly personal to you or may be open to the public. In particular it is very useful for providing Ubuntu packaged versions of a given application instead of dealing with tarballs or converting RPM packages.
So how does one make use of a pre-defined PPA and are there any things to be wary about? Read on.
PPA’s are great for getting the latest versions of a given piece of software instead of waiting for the official Ubuntu repository versions to be updated, though you will of course open yourself to any potential bugs in that software. Classic examples include getting Pidgin’s 2.5.8 update with the included new authentication method for Yahoo Messenger, or getting the latest version of the Deluge BitTorrent client/daemon.
In this HowTo, we are going to grab the latest version of Deluge to install on an Ubuntu Jaunty 9.04 system using the unofficial Ubuntu PPA, but this guide should apply to just about any version of Ubuntu or other Debian-based distribution.
NOTE: Ubuntu has now further simplified the PPA process by introducing a new way of adding PPA repositories and the GPG key in one hit from Ubuntu Karmic 9.10 onwards. While you can still use the process outlined below, please see the note at the end of this article for the simplified way.
First up, we need to create a sources.list file for the PPA repository we want to add to our system. In the case of Deluge, the PPA is at https://launchpad.net/~deluge-team/+archive/ppa so go there first.
Under the “Install packages” section is a box with two lines in it:
deb http://ppa.launchpad.net/deluge-team/ppa/ubuntu jaunty main deb-src http://ppa.launchpad.net/deluge-team/ppa/ubuntu jaunty main
Highlight and copy these two lines to your clipboard.
Now open a terminal and create a new file in your favourite text editor (in this case, GEdit) by typing in:
$ sudo gedit /etc/apt/sources.list.d/deluge.list
This creates a new file under /etc/apt/sources.list.d called deluge.list. You are presented with a blank page. Paste the content of the clipboard down so you have the two lines you copied earlier.
Save and close the file.
Now, in the terminal, type in:
$ sudo apt-get update
When the update completes, you should see a warning error at the end similar to the following:
W: GPG error: http://ppa.launchpad.net jaunty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY C5E6A5ED249AD24C W: You may want to run apt-get update to correct these problems
What this means is that apt-get has processed all your package lists and found that for the newly added Deluge source list, it does not have a GPG key to authenticate any of the files from it. This doesn’t stop you from installing Deluge or other files from it, but it does prevent Ubuntu from proving whether or not these files are untampered with, so it will pester you with warnings until you can provide it that GPG public key. Providing it is simple. Make note of the hexadecimal value provided after NO_PUBKEY and then type in the following:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C5E6A5ED249AD24C Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys C5E6A5ED249AD24C gpg: requesting key 249AD24C from hkp server keyserver.ubuntu.com gpg: key 249AD24C: public key "Launchpad PPA for Deluge Team" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) $
This fetches the GPG public key from the Keyserver at ubuntu.com and adds it to your GPG keyring. Now if you run:
$ sudo apt-get update
…again, you will see no errors output this time, which means you can safely install applications from it now without Apt warning you about being unable to authenticate them.
To prove this, let’s try and install Deluge now:
$ sudo apt-get install deluge
…and it should install like any other ordinary Ubuntu applications with no fuss, no worries and no error messages.
Pat yourself on the back.
I get an “HTTP fetch” error when I try to import a GPG public key!
If at step 9, you get the following error:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C5E6A5ED249AD24C
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys C5E6A5ED249AD24C
gpg: requesting key 249AD24C from hkp server keyserver.ubuntu.com
gpgkeys: HTTP fetch error 7: couldn't connect to host
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
$
It is because your firewall is blocking access to the Keyserver. Keyservers use port 11371 to communicate, not port 80 which is the normal HTTP port, so open 11371 as an outbound port on your firewall and re-run the command and it will work fine.
The simplified way of adding PPA’s using Ubuntu Karmic 9.10 or later.
Ubuntu 9.10 introduced a new, simpler way to add PPA’s to your system. Using the above Deluge example, you now only have to type in:
$ sudo add-apt-repository ppa:deluge-team/ppa
…and that’s it. This will do the whole sources.list creation and GPG key for you in one hit. That now simply leaves you to update your package lists with:
$ sudo apt-get update
…and then you can install Deluge with:
$ sudo apt-get install deluge
As you can see, it’s a far simpler method. You can, of course, still use the original method if you prefer.
Hey these PPA things are cool – can I create one of my own?
You certainly can. Refer to the Personal Package Archives for Ubuntu Help Page for everything you need to know, however please do not use a PPA as your own personal off-site backup for personal data. It is intended to help individuals and small groups who develop new software and do not have the resources to host their software for easy distribution by providing them a place where the masses can gain access to their project. To help curb the potential for abuse, PPA’s are limited to 1GB of storage and you are bound by the Ubuntu Community Code of Conduct.
MythTV is a project that brings analogue and digital television to your Ubuntu-powered PC. It primarily functions as your television and personal video recorder (PVR), but can be made to do many other things (refer to the official MythTV site for more information), however one thing that can catch people is actually building a MythTV box from scratch. Over the years, MythTV has been one of the largest causes of baldness in users who have torn out their hair in frustration.
Nowadays, tailored distributions such as Mythbuntu make the task pretty much trivial, but not everyone likes to use the tailor-made distributions. For one, Mythbuntu has a lot of its own branding across it which I personally don’t really like, and I’d prefer not to have it install all of that plus XFCE as the default desktop and then have to undo it all just to get back to a regular Ubuntu desktop.
Since I recently built a MythTV server for my folks, and on top of that connected it to their aging CRT television rather than the latest in visual technology, this makes for a perfect tutorial on how to take a vanilla Ubuntu Jaunty 9.04 installation and turn it into a simple, functional MythTV server without all the branding. We are going to just install only the components required to get MythTV up and running. Anything else you add is purely up to you.
Note: This tutorial covers installation of MythTV 0.21 as supplied with Ubuntu Jauty 9.04. It does not apply to the forthcoming 0.22 release which will sport a vastly different interface. It is not known yet whether Ubuntu Karmic 9.10 will still have 0.21 supplied or if 0.22 will be ready for release by then.
The system I built for my folks comprised of the following hardware:
Silverstone LC17 case (just to match the lounge gear, but you can use pretty much any case)
Gigabyte 500w PSU
2GB of Kingston DDR2/800 RAM (should have bought two sticks instead of a single stick, so I could run it in dual-channel mode – ah well, it’s not really a performance killer for MythTV)
A Gigabyte S-Series EG41M-S2H motherboard (which has built-in optical out and HDMI based on an Intel gfx chipset)
An MSI NX8400GS (NVidia GeForce 8400GS) PCI-E graphics card (because it’s passively cooled for no noise and has Composite/S-Video output as well as VGA and DVI)
An Intel E5300 Pentium Dual-Core CPU
A Seagate 1TB hard-drive
LG SATA DVD-RW optical drive (for playing DVD movie discs)
Two Asus MyCinema-U3100-Mini DVB-T digital-only TV tuners
Digitech “generic” Windows Media Centre Compatible remote control and USB infra-red receiver (cheaper than the real thing and doesn’t have any Windows or Microsoft branding on it)
I won’t detail the hardware build process since it’s an ordinary PC at the end of the day, but here is how it looks in my folks’ AV cabinet (it’s on the bottom shelf):
I performed a vanilla Ubuntu Jaunty 9.04 with the following partition layout:
100MB for /boot formatted as EXT2
1GB for swap formatted as SWAP
8GB for / (root) formatted as EXT4
Remainder of drive for /home formatted as EXT4
Since I also installed a UPS, I do not foresee any issues with the EXT4 file system and power-loss-related data corruption. I used EXT2 for /boot because, frankly, it doesn’t need journalling there. You’ll only ever write to that partition when you do a kernal update and having as a separate partition will make any future system recovery easier.
My folks are still using an old standard-definition widescreen CRT television. It comes equipped with SCART inputs which can accept Composite, S-Video and Amiga-style RGB signals, but not Component ability. I elected to connect the PC using S-Video, and it looks pretty sharp for what it is – certainly far more readable than Composite.
I came across a strange issue when I started the Ubuntu installation process – it couldn’t start X. Basically put, it cannot detect the “monitor” and thus cannot setup a suitable screenmode. I decided to do the initial installation via a traditional VGA monitor and once the NVidia drivers were installed, I’d switch back to the TV only.
I configured the primary login account, password and machine name to all be “htpc” and set it to auto-login. Once installation was complete and rebooted for the first time, I quickly installed the NVidia Binary driver and updated the system with any outstanding general system updates.
Setting up the TV
Once rebooted for the second time, I physically disconnected the VGA monitor and left only the TV connected. Ubuntu appeared quite cheerfully, though annoyingly it had switched to NTSC 60Hz mode, and I wanted PAL in 50Hz.
I opened up the xorg.conf configuration file into GEdit as follows:
$ sudo gedit /etc/X11/xorg.conf
…and located the “Screen” section which describes what the X screen to be used is. It looks something like this:
This ultimately outputted a 1024×768 display on the TV, stretched horizontally (a 4:3 screenmode stretched to fit a physical 16:9 display). If your Ubuntu desktop is larger than the screen, just adjust your TV’s picture size until everything fits in. In my case, only the top and bottom panels got slightly chopped off which was fixed with a minor vertical size adjustment on the TV.
Installing MythTV
First we need to enable the system to access the Multiverse repository. Do this by going to System->Administration->Software Sources and place a check mark against all five boxes, click OK and acknowledge the prompt to reload your package lists.
We now set about installing the extra software I required to turn this box into a MythTV server (which was going to run both Backend and Frontend):
$ sudo apt-get install mythtv
That’s all you need to get the main MythTV stuff working – the “mythtv” metapackage installs the MythTV Frontend, MythTV Backend, MySQL Server, MySQL Client, MythTV database configuration, all the default MythTV themes, etc. In my case, however I also installed the following for extra video/audio codecs (such as MP3 for listening to music files or watching movie rips), Java, Flash, the Microsoft Fonts, the Compiz Configuration manager for doing desktop eye-candy, the SSH server daemon to remote control the box when my folks call for help, and finally the MythWeb add-on that allows you to look at the MythTV server’s TV guide and schedule programs to record using a web browser interface:
Note: I did not need to install lirc for the remote control because the Digitech remote is actually a USB keyboard in disguise, not a “proper” infra-red remote.
During the installation of these packages, you will be prompted for a few things, namely:
Create a password for the root MySQL account. If this MythTV installation is purely for in-house use only, then just go with something simple like “password”. Many suggest leaving it blank, but I’ve personally seen this create authentication problems later on.
Create the MySQL database. When prompted for the MythTV server address, change the default “localhost” to the IP address of the PC you are installing the Backend on. If the Backend Server has an IP address of 192.168.0.10, then type in 192.168.0.10 in place of “localhost”. If you only intend to run one machine only for everything, then you can leave “localhost” as is.
When prompted for the name of the MySQL database, leave it as the default “mythconverg”.
Make note of the password generated for the MythTV database. You will need this to configure your MythTV Frontend.
Indicate whether or not you intend to have more than one Frontend client connect to your Backend server.
If you elected to install MythWeb, then you will be asked a question as to whether or not you want your MythWeb site password protected.
Acknowledge other prompts that tell you about creating the “MythTV” groups etc.
Your PC now has a user and Home directory called /home/mythtv and we need to ensure that the “mythtv” group can write to it as well as the owner, so at a terminal, type in:
$ sudo chmod -R g+w /home/mythtv
…and hit Enter.
Finally, if you intend more than one Frontend to access your Backend machine, we need to tell MySQL to allow other PC’s on your network to access the database, or those Frontends (other than the one on the Backend server) will not be able to start. To do this, type the following at the $ prompt. Everyone else can skip to Step 12.
$ mysql mythconverg -u root -p
When prompted, enter in the root MySQL password you specified earlier.
You will then be shown a MySQL prompt. If your local network’s IP topology is 192.168.0.x, and the password that was generated for MythTV’s database was “8tSpxGiM” then type the following to grant access to all PC’s on your local network to the MythTV MySQL database, at the “mysql>” prompt:
mysql> grant all on mythconverg.* to mythtv@"192.168.0.%" identified by "8tSpxGiM"; mysql> flush privileges; mysql> quit
…this will allow all PC’s with IP addresses starting with 192.168.0.x to access the MythTV database. If you are paranoid and only want to allow specific PC’s to access the database, then simply issue the “grant all” line for all explicit IP addresses only, by replacing the “%” wildcard character with the explicit IP address you want to allow, ie: to allow just 192.168.0.67 in, replace “192.168.0.%” with “192.168.0.67”.
Repeat for all specific IP’s to allow. You only have to issue the “flush” command once at the end to make your changes take effect.
Confirm that you can access the MythTV database as the MythTV user at the $ terminal prompt. If you are only using one machine, do this on the Backend server. If you are using multiple Frontends, test this on the remote PC’s that will be running the Frontend software (obviously replace the IP address with the actual IP address your Backend machine is using):
$ mysql mythconverg -h 192.168.0.10 -u mythtv -p
…when prompted, enter the MythTV password that was generated earlier. If successful, you should be looking at a “mysql>” prompt. If not, you will get an error, probably along the lines of “access denied”. NOTE: If you configured “localhost” to be the Backend Server in Step 2, then you must use the name “localhost” to connect to MySQL. Using “127.0.0.1” instead will not work because you have not configured “127.0.0.1” to have access to the mythconverg database. If you wanted these permissions, you would modify Step 11 to be the following commands:
mysql> grant all on mythconverg.* to mythtv@"192.168.0.%" identified by "8tSpxGiM"; mysql> grant all on mythconverg.* to mythtv@"127.0.0.1" identified by "8tSpxGiM"; mysql> grant all on mythconverg.* to mythtv@"localhost" identified by "8tSpxGiM"; mysql> flush privileges; mysql> quit
…which will allow the “mythtv” user to connect from any IP on the 192.168.0.x network, from 127.0.0.1 and any host called “localhost”, all using the specified password.
Quit the MySQL client by typing “quit” at the “mysql>” prompt:
mysql> quit
Configuring MythTV – the Backend
At this point, make sure your TV tuners are connected. In my case, the Asus U3100’s are connected into two free USB ports at the rear of the PC and have automatically been detected as Ubuntu carries full support for the U3100 already.
Now we need to start MythTV Backend Setup for the first time. Go to System->Administration->MythTV Backend Setup. When you do so, it will prompt you that your user (in my case “htpc” needs to be added to the “mythtv” group. Acknowledge this and then accept being logged out for the change to take effect. Log yourself back in. Once logged back in, restart the MythTV Backend Setup again. You will be reminded that the MythTV Backend needs to be stopped before you can continue. Click OK.
You are presented with several options. Choose “General” (if you are using a remote, you should find the basic Up/Down and OK buttons work here already).
Change the “Local backend” and “Master backend” addresses to be “localhost” (in lower case and one word). Leave all the “port” numerical figures alone.
Click on “Next”. If you’re only using a keyboard, then press ALT + N to proceed. The screen content will change.
Change the “TV format” to suit your local country. In my case, this is “PAL”. If you are in America or Japan, you’ll use “NTSC”. Check your local TV standards if you are not sure.
Change the channel frequency table option to your local country. In my case, this is “australia”.
The timezone for your guide XML data will ultimately depend on how you get your guide data. In my case, I just use Auto.
Click on “Next” or ALT + N on the keyboard.
We don’t need to change anything on this screen or the five screens that follow it, so click on “Next” again until you get to the last page where the button now says “Finish”.
Click on the “Finish” button or press ALT + F on the keyboard. You will be returned back to the main menu.
Now choose the “Capture cards” option.
Choose the “New capture card” option from the list.
What you choose here will be dependent on what your tuner hardware is. In my case, I change the “Card type” until it says “DVB DTV Capture Card (v3.x)” and you will see that the “Frontend ID” will show “DiBcom 7000PC” and the “Subtype” will be “DVB-T” indicating a “Digital Video Broadcast – Terrestrial” device was found.
Click on the “Recording Options” button and ensure that the “Max recordings” option is set to “2” (most digital tuners can record two channels at once from the same network, thus two physical tuners effectively become four usable tuners within MythTV).
Go back to the previous screen by clicking on Finish and then click on Finish again. You will be returned to the Capture card list and you will now see a new line for the card you just setup.
Since I have two tuners, I repeat this whole process again – the system will pick up the second tuner and label it accordingly – you can’t setup a card more than once accidentally. In my case now I have two cards called DVB:0 and DVB:1 listed.
Press ESC to return back to the main menu.
Now choose the “Video sources” option.
Choose the “New video source” option from the list.
Give your video source a name, eg: “Digital Free-to-Air”. This can be anything you want.
For your Settings Grabber, just choose the “Transmitted guide only (EIT)” or “No grabber” option for now. If you already have a preferred grabber, then choose it here now.
Click on Finish.
We only need one source for both tuners, so we’re done here. Press ESC to return back to the main menu.
Now choose the “Input Connections” option. This is where we tie our source to the tuners.
Choose the first tuner in your list. In my case I have “DVB: 0 (DVBInput) -> (None)”.
Change the “Display Name (optional)” to be something that describes the tuner, eg: “Digital tuner 1″. This can be anything you want and will serve to highlight what tuner you are using to watch or record a particular show.
Change “Video source” to the one you created in the “Video sources” earlier. In my case, I choose the only option I have – “Digital Free-to-Air”.
Now press the “Scan for channels” button.
Ensure that “Scan Type” is set to “Full Scan” and that your Country is correct.
Make sure that your TV aerial is securely connected to your TV tuner and then click on “Next”. The tuner will begin looking for TV channels. This can take several minutes to complete. Do not interrupt the process, even if it looks like it has gotten stuck – it will finish eventually. Any channels found will be listed in the status window at the back.
Once finished, press “Finish”.
Now press “Next”. Don’t change anything here.
Press “Finish”. You will be returned to the “Input Connections” list.
Repeat steps 1 to 3 only for any additional tuners you have (in my case, I had to repeat for the second tuner). We don’t need to re-scan for channels because the tuners are using the same source and we’ve already populated it with channels in the first run. In this instance, once you have done steps 1 to 3, just click on “Next” and then “Finish”.
Press ESC to return back to the main menu.
Now choose the “Channel Editor” option and review all the channels that were picked up in the scan. Optionally, you may also have MythTV automatically download what it believes are the correct network icons for those channels from the Internet using the “Download icons” button. Delete any channels you don’t want to review. Eg: in my case, I also picked up some digital radio channels. I’m not interested in those, so I could delete those if I so choose.
Press ESC to go back to the main menu.
Now choose the “Storage Directories” option. This is where we tell MythTV where to put all our TV recordings.
Choose “Default” from the list.
Choose the “/var/lib/mythtv/recordings” path already defined and change it to “/home/mythtv” (or whatever you prefer).
Click the “OK” button.
If you want to add more directories from other devices such as secondary hard-disks or network drives, just “Add directory” and specify them accordingly.
Once done, press ESC to return back to the main menu.
We’re now done configuring the Backend, so press ESC again to close the MythTV Backend Setup application. If you get an error, review it and see if you can fix it based on the information provided. In particular, if it tells you that it couldn’t write a “.test” file to /home/mythtv, then you did not grant the “mythtv” group writer permissions to “/home/mythtv” (See Step 8 in “Installing MythTV” earlier in this article).
Upon exiting, after a couple of seconds a dialog box will appear asking if you wish to run “mythfilldatabase”. Say YES. Once this is done, the MythTV Backend should automatically restart in the background briefly and then its output window should disappear.
Configuring MythTV – the Frontend
We’re nearly there! Now to configure the Frontend! Go to Applications->Sound & Video->MythTV Frontend. After a brief delay, you will see the default MythTV menu.
Choose “Utilities/Setup” from the menu.
Now choose “Setup” in the next menu.
Now choose “General” in the next menu.
If the PC you are on now is the Backend server, then this should already show that the”Database Server Settings” hostname is “localhost”. If you are installing a laptop/desktop that is NOT the Frontend, then you need to have the IP or hostname of the Backend machine here instead so that Frontend client knows who to talk to. In the case of your installation example, I’m using 192.168.0.10.
The port number can be left empty. It will use the MythTV default automatically.
The database name should already be “mythconverg”.
The user name should already be “mythtv”.
The password should already be the one that was randomly generated during the installation process.
Press “Next”.
Nothing to change on this screen, so press “Next” again.
Change the audio settings to suit your own configuration. If you are using an ordinary stereo setup, you can leave pretty much all of this unchanged, however I’d recommend adjusting the “Master Mixer Volume” to 100 and the “PCM Mixer Volume” to 80 or 90 (don’t set PCM to 100 as some motherboards will output scratchy/distorted audio depending on the quality of your on-board sound hardware).
Press “Next” through the next four screens.
Press “Finish”. You will be returned to the Setup menu.
Special setup: Configuring your MythTV Frontend to output digital audio via SP/DIF on the PC’s motherboard.
By default, motherboards with on-board SP/DIF out generally have their output muted, and as a result you will not see any laser light from any toslink cable connected to the motherboard. Unless you’re lucky, 9 times out of 10, the SP/DIF controls will not appear in the graphical Volume Control applet. To get around this, open a terminal.
Now type in “alsamixer” and you will be presented with a terminal version of the Volume Control applet.
Now press the right-arrow key until you come across any “IEC958″ related options. There will generally be two or three entries. You will probably find they have “MM” above them which means they are Muted.
Press the M key on your keyboard to toggle the Mute status of that option so that it now shows “OO” instead. This means it is no longer muted.
If you’re looking at your toslink cable, you should now see the fibre optic line in it light up with red laser light as you unmute it. You’re done, so press ESC to close the Alsa Mixer interface.
Now choose “Appearance” from the menu.
You can now choose a different theme from here which makes the interface look more attractive than the default theme. My personal favourite is “Blootube” and “Blootube Wide”.
If you are using 3D-enabled video drivers such as the NVidia binary drivers, you can elect to change the Paint Engine to OpenGL which will do nice crossfade transitions from one menu to another (note that there are no 3D transitions).
I also change the “Menu theme” here to “classic” as I believe it provides a more intuitive menu tree within MythTV. I encourage you to explore these options and choose what works best for you.
Page the “Next” button until you get to the end and then click “Finish”.
If you’ve chosen a new theme, it will now be scaled appropriately for your display and switched over.
You are now ready to begin watching TV, but you may want to quickly duck back into Setup->Playback OSD and change the theme there to “Blootube” or whatever you prefer as well as the On-Screen-Display when watching TV has a separate theme setting to the menus.
To watch TV, simply choose “TV” and then “Watch TV” from the MythTV menu. Use the up and down arrow keys and Enter to change channels.
Examples of the Blootube-themed main menu and TV OSD (on a full high definition display):
Using MythWeb
MythWeb is completely automatically configured. Using our installation example Backend host IP of 192.168.0.10, you can access it by opening your web browser and surfing over to http://192.168.0.10/mythweb and you will be presented with the main menu of MythWeb.
Being a web site, MythWeb is obscenely easy and self-explanatory to get around, so I won’t detail any of its most common functions here. I encourage you to explore the interface.
One particularly useful feature of MythWeb is in getting the Digitech generic remote to work. Out of the box, I only found the direction and OK buttons to work right away. All the other buttons generate keyboard presses that do not coincide with MythTV’s default keys. For example, the Play/Pause key on the remote generates “CTRL + P” instead of just “P”, hence MythTV doesn’t act on the button press.
To reconfigure key binds, all you have to do is click on the “Settings” option on the main menu.
Now click on “Key Bindings” in the presented options.
You are presented with all the available keybinds for various areas of MythTV. Scroll down the list until you find the keys pertaining to “TV Frontend” (first column).
Now locate the key bind related to “PLAYBACK – Play Program” (second and third columns). You will notice that the key assigned (in the fourth column) already is “P”.
To add the CTRL + P key combination without erasing the original “P” key, simply change the text box to read “P, Ctrl+P”. This binds both the P and CTRL + P key combinations to the Playback command.
Change all the other keys you need to change or add.
When done, scroll right to the very bottom of the key binds page and click on the “Save” button.
Restart the Frontend to read in your new changes and test the remote.
This is what the Digitech generic MCE remote looks like:
OPTIONAL: Setting up the Shepherd Electronic Program Guide (EPG)
Shepherd is an amazing Perl script that enhances and keeps your EPG data up to date in Myth, always providing better information about programs than the networks themselves do. A typical example of a poor network-supplied program description might be “Late Movie: 10:30pm – Pirates of the Carribean starring Johnny Depp” and… that’s it. How boring! Shepherd will use a grading system as well as sourcing categories of data from different sites in order to provide you a comprehensive description of all your programs instead. In the case of the above example, it would go to the IMDB and get the official movie blurb to use instead.
NOTE: Shepherd is geared towards Australian MythTV users only. This is due to long-running (and petty) legal disputes over EPG supply and copyright in this country. If you are outside of Australia, you most likely already have a proper EPG provided for you and you should use that instead.
Setting up Shepherd is trivial (Shepherd was up to version 1.3.39 at the time of this writing – refer to the official installation page for any changes made to the installation process since).
Open a terminal and type in the following:
$ wget http://www.whuffy.com/shepherd/shepherd
…and press Enter. This will grab the latest version of the Shepherd Perl script.
Before we run it, we need to install some dependencies:
Once all that is installed, now run the Shepherd setup script with the command:
$ perl shepherd
…and hit Enter.
Shepherd will initially re-install itself into the “mythtv” user’s home directory, ie: /home/mythtv, and re-run itself.
Shepherd will then begin checking itself to ensure all its data grabbers are the latest versions and download any that are missing. It will then prompt you through the rest of the installation process, which is generally straight forward, but we’ll step through it here:
First you are asked for a region code and are shown a giant list. Type in the number relevant to you and hit Enter. Eg: if you lived in Melbourne, Victoria, you would type in “94” as the code associated with that region. If you were in Sydney, you’d type in “73” instead.
Next you are asked if you would like Guided Channel Selection. Say YES (or just hit Enter as the default response is yes anyway).
You will then be asked if you have High-Definition TV. If you do use HDTV channels, you should say YES to this.
You are then asked if you have PayTV. If you are only configuring MythTV for Free-to-Air TV, say NO to this.
Now MythTV will ask you to match the known channels for your region to the channels that are setup in your MythTV installation. It will prompt you for each channel one by one. Simply enter the number corresponding to the guide data source you believe belongs to the currently displayed channel, eg: in some country areas, Channel Nine is known as WIN, so any references to “Channel Nine” you would tell Shepherd to use guide data provided by WIN. Repeat this until all channels have been prompted for. You may come across some doubled-up channels. This is normal.
When finished, Shepherd will list all your selections so you can verify them. When you are happy, respond YES.
You will then be asked about transitioning from an old grabber. Since this is a fresh installation, choose the zero (“do not transition”) option.
You will be given one more review and will then be asked if you’d like Shepherd to create a configuration file and update MythTV. Say YES.
When prompted about allowing Shepherd to auto-configure MythTV, say YES.
When prompted for Shepherd to create a symbolic link, say YES.
When prompted about the cron job Shepherd sets up, say YES.
Respond YES to the review question.
Shepherd will then begin testing its components and will eventually ask if you would like to install channel icons. This is not necessary (though you can complete it if you really like), so say NO to this.
Shepherd will finish.
Now we need to populate the EPG using Shepherd for the first time. Note that the initial run can take potentially an hour or more to run depending on your connection and quantity of channels in MythTV to find data for. Once finished, however, each subsequent run (once per hour, 24 hours) should be much faster. To run it for the first time manually, simply type in:
$ mythfilldatabase
…and hit Enter.
Depending on the minute that Shepherd setup for the cron job, you may find that as you try to run it manually, Shepherd advises that “another instance is running” and will abort itself. That’s fine – the job’s already started then automatically.
When Shepherd has completed its run, you will find that your EPG within MythTV is now nicely populated with highly descriptive blurbs and will remain so for at least 7-8 days ahead as long as the PC has a connection to the Internet.
The next version of Ubuntu is here – 9.04 aka “Jaunty Jackalope”. Along with a wealth of new features comes a wealth of new minor bugs to fix. Not enough to be show-stoppers, but enough to annoy the heck out of you, and here’s a doozy.
If, like most people, you have Compiz enabled and you start the MythTV Frontend, you will notice that rather than go full-screen, Myth will start as a window, essentially, even if your settings within Myth say to go full-screen.
In a single-screen scenario, the MythTV window will start just underneath the upper Gnome panel and the lower Gnome panel will sit over the top of the Myth window, obscuring part of the display. Proof that it’s a window can be found by holding down the ALT key and then dragging the MythTV display around with your mouse.
If you’re like me and use two displays with Myth being run on the second screen, you will see a gap at the top of the screen that is the same height as the upper Gnome panel and you will see your wallpaper showing through there, as shown in the illustration below.
Here’s how to fix this problem.
EDIT June 2010: This problem still plagues Ubuntu 9.10 and 10.04, and this fix will work for those releases as well.
The simplest fix is to disable Compiz altogether and MythTV will suddenly go full-screen, but that’s not really a solution – you want to keep your eye-candy! So follow the next few steps instead:
Go to System->Preferences->CompizConfig Settings Manager. If you do not have this option in your Preferences, then you need to add it. Quickly jump into a terminal and type in at the $ prompt:$ sudo apt-get install compizconfig-settings-manager…and hit Enter. Once installed, go back into the Preferences menu and bring it up.
Scroll down until you get to the “Utility” section and then click on “Workarounds”. It should alredy be selected as enabled, but if not, also make sure the checkbox next to it is enabled too.
The window changes to show you the Workaround options. The very first option is “Legacy Fullscreen Support”. This is unchecked by default. Click on the checkbox so that it IS checked, and then click on the Back button, then close the window.
Quit the MythTV Frontend if you had it open already and then restart it. You will now find that the gap has disappeared, and that the MythTV display is now appearing full-screen properly instead of just being a window.
Pat yourself on the back.
Happy viewing!
Please note: This workaround is just that – a workaround. One minor problem that arises with it is that you may get occasional screen “flashing” or a flash of the background wallpaper appearing when a DBus message is displayed, or if you scroll a window or terminal on the same or other screen in a multi-screen setup. This does not occur often, however, and so may not bother you at all! The bug has been reported, and no doubt will be fixed in due course. When it is fixed, this workaround should be reversed.
I made a rather alarming discovery today, quite by accident.
Like most people, I use an external hard-drive to backup data to, or to shift things around if I’m low on space on my PC’s internal drive. Well, today that external drive reported that it was full. Damn.
So I fire up Ubuntu’s Disk Usage Analyser, aka Boabab, to find out what’s consuming the most space. I use a 1TB external drive and it’s formatted total is about 916GB, which is about right, however Boabab reported that the total consumption of data on the drive only added up to about 860GB – wtf? Even Nautilus’s Volume Properties window was reporting that the drive still had 50GB-odd free, so why is the system telling me it’s full?
I use Ext3 on my drives and, being a journalled filesystem, some space on the drive is reserved to record these journals among other functions which is expected, but 50GB worth? I did some research and found out that the Ext3 filesystem reserves 5% of disk space by default for itself! In this day and age of large drives, that’s a huge chunk of lost space!!
Thankfully there is a way to tell Linux not to reserve so much space. Read on…
First up, unmount your drive. You can do that by either right-clicking on the drive icon on the desktop and choosing “Unmount volume” or by clicking on the Eject icon next to it in the Places pane of any Nautilus window.
Next, open up a terminal and type the following:
$ sudo fdisk -l
This will list all your available drives. Identify which one is your external drive and take note of the device name, eg: in my case my external drive appears as /dev/sdb with one partition on it, sdb1.
Now type in the following:
$ sudo tune2fs -m 1 /dev/sdb1
This will modify the filesystem on that drive, on that one partition, to only reserve 1% instead of the default 5%.
Now re-mount your drive by clicking on its name in the Places pane in a Naultilus window.
The Nautilus Device Properties window will still show the same free space as before, because it reports the true total free space, but any Nautilus File Manager window only reports usable free space, which in the case of my external drive had now freed up a very sizable 37GB!
Lather, rinse, repeat on any other non-system drive partitions on the same or different drive you want to reclaim space back for.
Personal websites, blog pages, etc. You can spend a lot of time, effort, and sometimes money setting them up and maintaining them. The pay-off is when you see lots of people visit your site, take an interest and even provide feedback. The annoyance comes when you notice in your logs that a select handful of images are being downloaded a helluva lot more than every other image on your server, and further scruitiny shows that it wasn’t even your own website requesting them – it was someone elses.
So you go and have a look at the referring site. Worse-case scenario was that they had blatantly plagerised your site – copied everything as their own. Not so bad is that someone has found an interesting pic on your site and linked directly to it on another site to tell people about it, but not necessarily atrributed your site to it.
Hot-linking files between sites is considered bad nettiqette if you have not got permission from the site owner. Image copyright issues aside, it is preferred that if you have an interest in an image that you download a copy and host it yourself, or that you link to the hosting website itself so that people can see proper attribution.
This has already happened to me a few times with the most notable being some Korean blogger’s site blatantly copying word for word one of my articles, but he decided to leave all the images in it hot-linking to my server. I couldn’t believe it, but I knew it wouldn’t be long before someone did that. I dropped a politely worded, but firm, message on his blog where everyone could see it, and he has since deleted the plagerised entry from his blog.
So, how do we go about preventing your Apache web server from serving up images to invalid referrers? Read on…
This HowTo was written with Ubuntu Server 8.04.2 Hardy Heron in mind since most server users would be likely still be using the LTS release for public-facing servers, however these instructions should apply to any version Ubuntu Server until Apache make any radical changes to how their http daemon configuration works. I will also assume that you already have a web site up and running. We are just going to add to its configuration here.
To prevent hot-linking is a simple matter of checking what file is being requested from your server. We can do this by checking for certain file extensions such as .jpg, .png etc. We then have a rule to ensure that such requests are coming from your website, eg: www.acmecorp.com instead of someone else’s site. If the rule matches your site, the requested image is served, otherwise an alternate image is served instead.
What’s the alternate image? Simply it’s a small-sized image that provides a small message to the hot-linker to tell them that you shouldn’t be hot-linking images to your site. The small size ensures that it is transferred quickly and doesn’t chew up much bandwidth on your connection.
Here is the one I use for serenux.com:
Can be anything you want, really. Just make it polite or funny. This one was created in The GIMP and saved out with extremely high compression to make it as small as possible without compromising image quality so much that the image is unreadable with compression artifacts. From memory, I think it was 40% quality instead of the usual 80-85% you’d save most photos with.
Create your own message in a picture and save it out to somewhere on your website with some arbitrary name. I use “noop.jpe” in reference to “no operation” and the file extension is deliberately mangled for reasons you’ll see later. I also save it in the root of my website so I don’t have a long convoluted URL to refer to it with. Eg: if your website resides in /var/www on your server, then save this image to /var/www/noop.jpe accordingly.
Now we need to tell Apache to use this image in place of serving other hot-linked images.
If you use SSH to manage your server:
SSH into your web server as normal.
$ ssh acmecorp@www.acmecorp.com
Change directory to the /etc/apache2/sites-available directory.
$ cd /etc/apache2/sites-available
Bring up your website’s configuration file into your favourite text editor. In this case, the config file is called “www.acmecorp.com” and i’ll use the Nano editor to edit it.
$ sudo nano www.acmecorp.com
Add the following lines to the end of the configuration file, but before the </Virtualhost> line:
# Prevent hotlinking of images from foreign sites and redirect to a new image. RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://www\.acmecorp\.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} ^http://.*$ RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://www.acmecorp.com/noop.jpe [NC,R,L]
(Change www.acmecorp.com to what is relevant to your site, of course)
What the above does in order is turn on URL re-writing, then check to see if the referrer does NOT start with the string “www.acmecorp.com” (the NC means “not case-sensitive”, so it matches on things like WWW.ACMECORP.COM and www.AcmeCorp.com as well), the referrer is also checked to ensure that is is not blank, and that the referrer had a “http://” string at the start.
If all these rules match true, then one last rule is applied before re-writing the URL – if the URL string requested ends with .jpg, .jpeg (the e? part tests for whether the “e” exists or not so it matches on jpg or jpeg), .gif, .bmp or .png, then re-write the requested URL as “www.acmecorp.com/noop.jpe” with no case-sensitivity on the match (“NC”, the “R” parameter will tell your visitor’s browser that they were redirected (you don’t have to do this – you may want the visitor to think this is actually what they requested), and the “L” parameter will stop processing of anymore re-write rules here, ie: this is the “Last” re-write rule.
Save your work and exit the editor by pressing CTRL + X and then “Y” to save.
We’re almost there! Now that we have the rules written, we now need to enable the URL re-writing module of Apache called “mod_rewrite”. Without it, the changes we did to the configuration will cause Apache to error out on startup. Ubuntu has the re-write module pre-compiled in, so all we have to do is enable it. To do this, simply enter the command:
$ sudo a2enmod rewrite
Now we are ready to rock and/or roll. Restart your Apache server with:
$ sudo /etc/init.d/apache2 restart
Ensure that no errors were reported during startup and then test hot-linking to your site. NOTE: If you already tested hot-linking from another site and can still see your images, more than likely they have been served up from your web browser’s cache – clear your cache and try again.
Pat yourself on the back. You’re done.
If you use WEBMIN to manage your server:
This HowTo section assumes you’re using Webmin version 1.430 or later.
Open your web browser and get into your Webmin interface as normal.
Click on “Servers” in the left pane. A list of server daemons will be listed underneath.
Click on the “Apache Webserver” daemon. The right pane will then show you your available web sites.
Click on the “Global Configuration” tab at the top-left of the Virtual Server list. The pane will change to show global Apache options.
Click on the “Configure Apache Modules” icon. The pane will change to show the currently available and enabled Apache modules.
Locate “rewrite” in the list and ensure a checkbox is enabled against it. Do not change anything else.
Scroll to the bottom of the list and click on the “Enable selected modules” button. You will be returned to the Virtual Server list page.
Now click on the icon relevant to your virtual server, eg: “www.acmecorp.com”. The window changes to show the options available for that virtual server.
Click on the “Edit Directives” icon. You will be presented with a text editor showing the configuration file.
At the end of the file, paste the following in:
# Prevent hotlinking of images from foreign sites and redirect to a new image. RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://www\.acmecorp\.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} ^http://.*$ RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://www.acmecorp.com/noop.jpe [NC,R,L]
(Change www.acmecorp.com to what is relevant to your site, of course.)
See the description of what all this does in the SSH instructions.
Click on the Save button.
Click on “Apply changes” at the top-right of the Webmin window.
Test hot-linking images on a foreign site to your own. NOTE: If you already tested hot-linking from another site and can still see your images, more than likely they have been served up from your web browser’s cache – clear your cache and try again.
Pat yourself on the back. You’re done.
Notes:
Now, you’ll rember that I called the anti hot-linking image “noop.jpe” instead of “noop.jpg”. Want to know why? Well, it’s the only image on your entire server that you DON’T want to be matched on for anti hot-linking. Despite the URL being re-written to deliver that image to the visitor’s web browser, that very image is still subject to the re-write rules as well. If you were to tell your Apache server to re-write the URL for every .jpg image on your server, then the “noop.jpe” file served as “noop.jpg” instead would be re-written to “noop.jpg” again and again and again in an infinite loop, hanging your server and not actually serving it to the visitor! Thankfully Apache today is a little smarter and will detect and abort an infinite loop, but it still serves nothing to the visitor. This is why we called the file “noop.jpe” so that it does NOT match the “.jpg” or “.jpeg” rules. We could fix this by simply adding another rule that says “don’t re-write if noop.jpg is being requested” but I’m just lazy. You want the rule? OK, fine – add this before the “ReWriteRule” line:
Now what if you participate on other forums and want to allow hot-linking of images on your site from that site? What about Google and other search engines – can you omit them from being blocked? You sure can. Just add these rules in before the “ReWriteRule” line, and modify them to your requirements:
The first condition says “don’t re-write if the referrer string starts with either “www.overclockers.com.au” or “forums.overclockers.com.au” and the second condition says “don’t re-write if the referrer string starts with either “images.google.<whatever>” or “google.<whatever>” (so that means it’ll allow things like images.google.com.au, google.com, google.co.uk, images.google.co.uk etc, but will NOT allow things like banana.google.com or freddo.google.co.uk”. You can adapt this easily enough to other search engines like Yahoo etc.
Finally, what if you simply want to be a bastard and present a broken link to the hot-linker instead of a friendly message? Hot-linkers be damned! An easy way to do that is to re-write the “ReWriteRule” line as follows:
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
The dash and the “F” parameter essentially drops the request and serves nothing back. Not even an acknowledgement. As far as your hot-linker is concerned, the image file doesn’t exist.
As you are probably aware, Ubuntu has a regular six-month release cycle, and if you are someone like me, then you are probably regularly downloading all the Alpha and Beta versions as well as the final releases. The problem with such regularity is that this would use up an awful lot of blank CD’s that you will probably only use a few times before discarding just to install these upgrades.
Fortunately, you don’t have to burn Ubuntu CD ISO images to a physical disc to upgrade your installation to the next version. Here’s how to do it using just the ISO image, or wholly via the Internet with no ISO image or CD at all.
There are three ways to upgrade Ubuntu from one version to the next:
Wholly on-line via the graphical Update Manager application, or
Wholly on-line via command line Apt application, or
The quicker and more easily repeatable method of using an upgrade CD, especially if installing multiple machines (this process optionally will also retrieve additional updates from the Internet released since the CD’s initial release). I will outline all three methods here.
NOTE: You cannot upgrade one CPU architecture to another, ie: you cannot upgrade Ubuntu 8.04 x86 (32-bit Intel/AMD compatible) to Ubuntu 8.10 AMD64 (64-bit Intel/AMD compatible), etc. If you previously used the 32-bit version of Ubuntu and wish to upgrade to the 64-bit version, you will need to do a complete fresh installation from scratch.
Upgrading via the CD ISO image
First up, you will need to download the Alternate Installer CD ISO image of the new version of Ubuntu you want as opposed to the Desktop Live CD version, which cannot do upgrades. All Ubuntu Alternate discs are named in the format of ubuntu-x.xx-alternate-yyyy.iso where x.xx is the release version, eg: 8.10 or 9.04, and yyyy is the target architecture, eg: amd64 for 64-bit Intel-compatible platforms and i386 for 32-bit Intel-compatible platforms. Thus the Ubuntu Intrepid 8.10 64-bit version is called ubuntu-810-alternate-amd64.iso and when it’s eventually released, the Ubuntu Jaunty 9.04 64-bit version will be called ubuntu-9.04-alternate-amd64.iso accordingly.
Once you have the CD image downloaded, make a note of where you downloaded it to, eg: /home/jbloggs/downloads/ubuntu-8.10-alternate-amd64.iso and then jump into a terminal window.
Make sure that you do not have any actual physical CD’s inserted into your CD-ROM drive.
At the $ prompt type in:
$ sudo mount -o loop /home/jbloggs/downloads/ubuntu-8.10-alternate-amd64.iso /media/cdrom
…and hit Enter. If all is well, it should look as though nothing happened, however you will notice a CD icon appear on your desktop simply called “cdrom”.
Now start the upgrade process with the following command:
$ gksu /media/cdrom/cdromupgrade
…and then just follow the prompts. When you reboot after the upgrade, the CD image will no longer be mounted and you can use real CD’s again without any issue.
Upgrading via the Internet only – GUI installation
This method is possibly more convenient, but generally takes longer to do and is not the ideal way to upgrade multiple machines. Using this method, you don’t need the ISO image at all. Everything is handled by the Update Manager.
Open a terminal (or press ALT + F2 to bring up the Run Application dialog) and type in the following:
gksu "update-manager -d"
…and hit Enter. This will launch the familiar Update Manager. If you are not immediately advised of a newer version of Ubuntu to upgrade to, as illustrated below, then click on the “Check” button to update your system’s cache of available updates, then click on the “Upgrade” button that appears at the top.
Before Update Manager is aware of the next distribution version:
And after Update Manager is made aware of the next distribution version by clicking on the “Check” button (note that the Upgrade option will NOT appear if you did not start Update Manager with the “-d” parameter):
Follow the prompts.
Upgrading via the Internet only – Command Line installation
This method is identical to the GUI Update Manager installation, except that it is done wholly via the command line using Apt.
First of all, make sure that Apt is fully up to speed with current updates by jumping into a terminal and type in at the $ prompt:
$ sudo apt-get update && sudo apt-get upgrade
When that has finished, commence the upgrade to the next version of Ubuntu with: