Saturday, May 15, 2010

Switching from Azureus to Deluge

I've always been a fairly happy customer with Azureus, it did what I wanted, it's very fully featured, and highly extensible given the army of plugins available on their sourceforge. However lately I've been wanting some things that Azureus couldn't very easily provide me, so I undertook the task of switching from Azureus to Deluge, without a moment of downtime I might add.

First off, there was the task of actually handling the files, that was simple enough. Make copies of everything in another base folder... done. So I more-or-less copied the contents of my ~/Azureus Downloads folder to the newly created ~/Deluge (not to be confused with ~/.deluge) folder. Then I had to go around finding all the actual .torrents for those files, again fairly simple. A lot of back and forth but ultimately a simple task. Then came my favorite part, the actual configuration.

Configuring a newly installed program is particularly enjoyable to me, and as I got deeper and deeper into Deluge's options I realized that I had found exactly what I was looking for, exactly what I had been missing in Azureus.

For starters, the WebUI is nothing short of spectacular. Azureus's WebUI was only capable of fairly simple things: Starting/stopping torrents, setting speeds, a few options, et cetera. Deluge's WebUI offers damn-near the same amount of options and features that the GTK interface has; It even looks virtually identical. Pretty much anything you can do via the GTK interface can be accomplished using the WebUI. The greatest part about it though? It's live! The data updates every 2 seconds or so, versus waiting a predetermined amount of time (by default 30s) for Azureus' WebUI to refresh the entire interface.

Another great Deluge feature is that it sorts torrents by tracker: something I spent a good chunk of time and effort attempting to do in Azureus. In Azureus I wound up having to create groups for each tracker and having to manually add a torrent to a group every time. Deluge does it for you, which is great for keeping things clean and organized.

Azureus had groups, Deluge has 'labels', however Deluge's labels are capable of being configured to behave a certain way (at least to a higher extent than the settings available to groups in Azureus). That is to say, you can use labels to apply a pre-defined set of rules to any torrent that is a member of the label, things such as dl/ul speed, connection limits, upload slots, autostop, completion moving, and more.

Deluge is infinitely more organized than Azureus was, in all regards. You can sort torrents by tracker, label, or 'state'. There are several different states: all, downloading, seeding, active, et cetera. Downloading shows torrents that are downloading, seeding shows torrents that are seeding, and active only shows torrents that are transferring data in one direction or the other (i.e. no idle torrents). Now by Deluge standards, the only sorting option that Azureus offered was All, very unorganized, very convoluted. If you wanted organization you had to take matters into your own hands by creating groups or something else. Deluge comes with organizational skills by default, and I'm already quite fond of this.

But by far, my favorite thing about Deluge is that it doesn't share the same cache-size limitation that Azureus has as a result of the JVM. Bittorrent is hell on hard drives, so a large cache means less disk thrashing. With Azureus I was able to get my cache up to about 90MB while remaining (relatively) stable. With Deluge, I gave it 65,536 16KB blocks, or 1GB of RAM to play with. I know what you're thinking: 'bloat-city'. I don't see it that way. I run Linux, not Windows so I don't have an operating system that's already sucking down half of my system resources to begin with. I can afford to dedicate a GB of RAM to Deluge alone, because the rest of the system rarely exceeds 512MB of RAM usage, even while operating at higher stress levels than normal. Why let the resources sit there unused?

Deluge is also written in python, my favorite programing language, so I'm looking forward to having a new platform to experiment with.

I do feel obligated to state for the record that I never was unhappy with Azureus, I just wanted certain features and options that were not available to it. Azureus was great to me, and I learned a lot because of it. So I present the final stats from my Azureus installation, who has faithfully served me since day one.

Friday, May 7, 2010

Ubuntu 10.04

I firmly believe that one can never have too many computers. I have my Arch/Win7 dual-boot Desktop for general use, my Mint server which does too many things to name here, my Arch netbook for school (portability is key when you have to lug something around all day), and my laptop, which has become a sandbox of sorts. I've designated it the 'laboratory-box', basically meaning I use it to toy around with things that I don't want to risk doing on one of my main boxes, or may simply not have the room for on those computers.

Now I use GRUB's legacy version on my desktop, but was curious about GRUB 2. The laptop was OS-less at the time (an fsck gone horribly, horribly, wrong) so I figured I'd install the new Ubuntu; I get to take it for a test-drive, and play around with GRUB 2... the whole two birds, one stone bit.

It's everything you would expect from a new Ubuntu release: Some minor changes here and there, as well as a few more noticeable improvements. First off, the exit/maximize/minimize buttons being on the left side of a window's title bar instead of the right drove me nuts... for about 5 minutes. You get used to it surprisingly fast, don't be put off by it, embrace it. The default theme and background is also better looking than the brown trend previous releases had. Aesthetics aren't huge to me, but in the interest of total honesty it was one of the first things I noticed. Now on to the good stuff...

Rhythmbox now features the Ubuntu One Music store, which has a surprisingly large selection, and the greatest part? It's all DRM-free. A commonly asked GNU/Linux-noob question is 'can I get iTunes running on Linux?'. Sure there's music players galore, take your pick, but up until this point there was no real viable Linux equivalent of iTunes and the iTunes store. Now you can pick up your computer, boot into your FOSS OS, load up (the also FOSS) Rhythmbox, and buy some DRM-free music. Only drawback is you need mp3 support, which is proprietary. However, if you're so inclined you can always convert it to FLAC, I wouldn't recommend using Vorbis only because converting one lossy format to another lossy format is like listening to a record that's been played a thousand times but in other situations I'm a pretty big fan of Vorbis.

As previously mentioned this Ubuntu install was also the first chance I've had to toy around with GRUB 2. I have GRUB 2 on my Mint-Server (which runs Helena, based off of Karmic) but since Mint's the only OS on it, and it's on 24/7 I haven't had much call to play with it. At first I was completely overwhelmed by how much more complex the configuration files structure was compared to GRUB legacy's relatively straightforward menu.lst, but after digging through some documentation, and toying around with it for a while I began to see its potential. I have a feeling that I'll be discovering just how versatile it is this weekend, when I plan on dual booting this Ubuntu install with FreeBSD.

Thursday, May 6, 2010

Changing GRUB's Boot Order

When you install GNU/Linux, chances are you installed GRUB (the GRand Unified Bootloader) as well, especially if you have multiple operating systems installed on the computer. GRUB is that menu that appears shortly after you boot up your computer that allows you to select which operating system you want to boot into.



By default, GRUB's first choice is the GNU/Linux distribution used to install it. For example, say you have a computer with Windows 7 on it, and decide you want to give Linux a spin. After the installation is complete booting your computer will take you to a rather simple menu that asks you which operating system you want to boot into, the Linux distribution you've installed, or Windows.


It's here a problem arises. After a certain number of seconds without user interaction, GRUB will automatically choose the first option listed, which is generally the OS used to install it. This means that if you have a dual-boot Windows/Ubuntu setup, and you want to boot into Windows, you'll have to monitor your computer while starting to prevent it from automatically launching into Ubuntu. This guide will cover how to re-arrange the order of the items that appear on the GRUB boot-menu, as well as other minor customizations.


First things first: There are two versions of GRUB out there, grub, and grub2. Newer distributions such as Ubuntu 10.04 have switched to GRUB 2, but GRUB (now referred to as the 'Legacy Edition') is still fairly common. This guide will cover the procedure for both GRUB versions. Of course you still have to tell which version of GRUB you are using. Run "grub-install -v" in the terminal and it will give you a version number. .97 is the Legacy edition, anything above that is GRUB2. Ubuntu 10.04 ships with version 1.98 which is GRUB 2.


GRUB Legacy


Modifying GRUB is fairly straight-forward, you can make changes by editing the GRUB Menu's configuration file: '/boot/grub/menu.lst'. After altering the file, you will need to save it, and in order to save it, you need superuser privileges. If you try to open it in gedit or kate you won't be able to save it. You'll need to launch your preferred text editor as a superuser in order to save the file after revision. Try using these in terminal to accomplish that.



GNOME:
gksu gedit /boot/grub/menu.lst
KDE:
kdesu kate /boot/grub/menu.lst

Now for the actual configuration file itself, here's mine:





# Config file for GRUB - The GNU GRand Unified Bootloader
# /boot/grub/menu.lst


# DEVICE NAME CONVERSIONS
#
# Linux Grub
# -------------------------
# /dev/fd0 (fd0)

# /dev/sda (hd0)
# /dev/sdb2 (hd1,1)
# /dev/sda3 (hd0,2)
#

# FRAMEBUFFER RESOLUTION SETTINGS

# +-------------------------------------------------+
# | 640x480 800x600 1024x768 1280x1024
# ----+--------------------------------------------
# 256 | 0x301=769 0x303=771 0x305=773 0x307=775
# 32K | 0x310=784 0x313=787 0x316=790 0x319=793
# 64K | 0x311=785 0x314=788 0x317=791 0x31A=794

# 16M | 0x312=786 0x315=789 0x318=792 0x31B=795
# +-------------------------------------------------+
# for more details and different resolutions see
# http://wiki.archlinux.org/index.php/GRUB#Framebuffer_Resolution

# general configuration:

timeout 30
default 0
color light-blue/black light-cyan/blue

# boot sections follow
# each is implicitly numbered from 0 in the order of appearance below

#
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
#
#-*

# (0) Arch Linux

title Arch Linux
root (hd0,2)
kernel /vmlinuz26 root=/dev/disk/by-uuid/a8a2e826-2f66-47df-b522-9f842964897f ro
initrd /kernel26.img

# (1) Arch Linux

title Arch Linux Fallback
root (hd0,2)
kernel /vmlinuz26 root=/dev/disk/by-uuid/a8a2e826-2f66-47df-b522-9f842964897f ro
initrd /kernel26-fallback.img

# (2) Windows

title Windows 7 x64
rootnoverify (hd0,0)
makeactive
chainloader +1



Now at the bottom you see the actual menu items. Arch Linux, Arch Linux Fallback, and Windows 7 x64. Each of the items has a few lines of information, and separate menu items are separated from each other by a blank line. Let's take a look at the first menu entry.




# (0) Arch Linux

title Arch Linux

root (hd0,2)

kernel /vmlinuz26 root=/dev/disk/by-uuid/a8a2e826-2f66-47df-b522-9f842964897f ro

initrd /kernel26.img



The first line, the one that starts with '#' is for your information. It is not read by GRUB, but serves as more of a comment for the user reading the configuration file to make it a little more organized.


The line under it, the 'title' line, holds the text that will be in the GRUB Menu's entry for that selection. I.e. My GRUB Menu will give me the choices Arch Linux, Arch Linux Fallback, and Windows 7 x64. If I changed the line that reads 'title Arch Linux' to 'title Foobar', my Grub Menu would present me with the choices Foobar, Arch Linux Fallback, and Windows 7 x64. This is useful if the default title GRUB chooses is not to your liking. For example, GRUB frequently identifies Windows Vista as 'Windows Vista/Longhorn'.


You can also change the boot sequence fairly easily. For example, changing:



# (0) Arch Linux
title Arch Linux

root (hd0,2)
kernel /vmlinuz26 root=/dev/disk/by-uuid/a8a2e826-2f66-47df-b522-9f842964897f ro
initrd /kernel26.img

# (1) Arch Linux
title Arch Linux Fallback

root (hd0,2)
kernel /vmlinuz26 root=/dev/disk/by-uuid/a8a2e826-2f66-47df-b522-9f842964897f ro
initrd /kernel26-fallback.img

# (2) Windows
title Windows 7 x64

rootnoverify (hd0,0)
makeactive
chainloader +1

to



# (0) Windows

title Windows 7 x64
rootnoverify (hd0,0)
makeactive
chainloader +1

# (1) Arch Linux

title Arch Linux
root (hd0,2)
kernel /vmlinuz26 root=/dev/disk/by-uuid/a8a2e826-2f66-47df-b522-9f842964897f ro
initrd /kernel26.img

# (2) Arch Linux

title Arch Linux Fallback
root (hd0,2)
kernel /vmlinuz26 root=/dev/disk/by-uuid/a8a2e826-2f66-47df-b522-9f842964897f ro
initrd /kernel26-fallback.img

will change the order of the menu entries in GRUB's Menu. Since Windows 7 is first on the list, after 30 seconds without user intervention, GRUB will default to booting into Windows. You can change the amount of time before this happens if you desire by altering the 'timeout 30' line to read the amount of seconds you wish (i.e. 'timeout 15').



GRUB 2


GRUB 2's configuration files are a bit more complex, and offer much more versatility. Start by taking a look at your /boot/grub/grub.cfg file. Note: Do not edit this file. You'll notice right away that this is not a pretty document. Look for the lines that start with 'menuentry', Ctrl-F is your friend here. You should find something that resembles this:



menuentry 'Ubuntu, with Linux 2.6.32-21-generic' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail

    insmod ext2
    set root='(hd0,1)'
    search --no-floppy --fs-uuid --set e6948097-4d7c-4bc5-a4fe-8e760a11f5c5
    linux /boot/vmlinuz-2.6.32-21-generic root=UUID=e6948097-4d7c-4bc5-a4fe-8e760a11f5c5 ro quiet splash
    initrd /boot/initrd.img-2.6.32-21-generic
}

menuentry 'Ubuntu, with Linux 2.6.32-21-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod ext2
    set root='(hd0,1)'
    search --no-floppy --fs-uuid --set e6948097-4d7c-4bc5-a4fe-8e760a11f5c5
    echo 'Loading Linux 2.6.32-21-generic ...'

    linux /boot/vmlinuz-2.6.32-21-generic root=UUID=e6948097-4d7c-4bc5-a4fe-8e760a11f5c5 ro single
    echo 'Loading initial ramdisk ...'
    initrd /boot/initrd.img-2.6.32-21-generic
}

Each line that begins with 'menuentry' is precisely that. Above we see two of them, Ubuntu, and it's recovery mode. Now, the first one we'll refer to as menu entry 0, and the second one will be menu entry 1. This may seem counter-intuitive as most human beings start counting with 1, but with computers starting with 0 isn't as uncommon as one might think. Now say you wanted to configure the GRUB 2 Menu so that the recovery mode is the default option. For this we'll need to edit the /etc/default/grub file.



Like with GRUB legacy, you'll also need superuser privileges to save the configuration file after editing it, so you'll need to launch your text editor with elevated privileges. Run the following in the terminal depending on your DE of choice:



GNOME:
gksu gedit /etc/default/grub

KDE:
kdesu gedit /etc/default/grub

This configuration file is more human-readable. Look for "GRUB_DEFAULT=0", which should be relatively close to the top. By changing this to "GRUB_DEFAULT=1", The second, or menu entry #1 will be selected by default in the GRUB menu, becoming the default choice. Say Windows was installed as well, and occupied a third (or #2) menu entry. By setting "GRUB_DEFAULT=2" Windows will be automatically highlighted on GRUB's Menu, and will be launched after the timer runs out. After editing this file to your liking, save it, and run 'sudo update-grub'.


That's it, you're done! Restart your computer and see the changes for yourself.

Recommended Reading:
GRUB 2 Documentation
GRUB 2 Guide
GRUB 2 Title Tweaks