Showing posts with label Tutorials. Show all posts
Showing posts with label Tutorials. Show all posts

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


Sunday, March 7, 2010

Azureus/Pidgin Integration

That write-up I promised in the "A whole 'nother level of Geekdom' post regarding the implementation of Pidgin as a remote-content-addition-mechanism for Azureus is now done... If you've ever wanted to be able to tell your home torrent box to start downloading something by doing something as simple as sending an Instant Message, give it a glance.

Using Pidgin To Add To Your Azureus Queue Remotely


First things first, there are countless ways to control a torrent-box remotely that will offer you a higher level of control than this procedure, but if your looking for a quick and easy way to add content on-the-fly, without much setup, then this guide is for you.



Requirements:


  • Azureus Vuze (latest version recommended)
  • Pidgin (latest version recommended)

The goal of this little project is to be able to add torrents to Azureus' queue from any computer with an AIM client. The basic setup is this: Azureus has a feature where it will autoscan a directory for new content at a predetermined time interval (i.e. 60 seconds). Pidgin has a plug-in where it will autoaccept file transfers from pre-defined 'AIM buddies', and save them to a pre-defined directory. By daisy-chaining these two features, we can IM .torrent files to an AIM account running on Pidgin on the torrent box, at which point Pidgin will automatically accept the file transfer, and Azureus will subsequently add the torrent to its queue.


Setting up Pidgin


Create a NEW AIM account that will be used on the torrent-box, say something like Steves-torrent-dedi. Next you are going to want to download and install Pidgin onto the torrent computer. Now, I use Linux almost exclusively, so I downloaded pidgin through my distribution's repositories. However if you are using Windows you can get the installer from Pidgin's Site. Now to actually set up the account settings. When you launch pidgin it will prompt you to enter account information.



0

Click the Add button and fill out the fields accordingly with the information of the AIM account you just created. Pidgin can use many protocols besides AIM, such as Yahoo, ICQ, Jabber, Google Talk, et cetera, so you may be able to use accounts operating on those networks as well, though I haven't tested it myself. It's also probably a good idea to have it remember the account password so it can login automatically.


1

If after entering all the information, and verifying that you input it correctly, the account still won't log in, you may have to fine-tune some of the advanced settings. The two biggest problems are 'Use SSL' and 'Use Client Login'. Toy around with these, SSL usually needs to be turned off for Pidgin to login to an AIM account successfully.


3

By this point, you should have the AIM account running on Pidgin, now you need to add your own personal AIM account to the newly created account's buddy list. To add your personal account as a buddy, simply click Buddies>Add Buddy and fill out the form. Once you have done this go Tools>Plugins, and check off autoaccept.


5

Next click the configure plugin to fine-tune its settings. Blocking transfers from users not on your buddy list is probably a good idea, since ideally you would want you to be the only person capable of doing this. The pop-up is a personal choice. Creating a new directory for each user will save all the transfers from Buddy-A in /folder/Buddy-A/file, this is useful for other applications, but not this one since Azureus will only scan one directory for .torrent files, and it won't do it recursivley. Configure the folder where you want the uploaded torrent files saved, the simpler the better. Despite what the screenshot says I used "/home/mint/Uploads".


6

Now just right-click the Buddy you want to autoaccept files from, and click autoaccept. Then check autoaccept once again.


7

Setting up Azureus


Congratulations, your done configuring Pidgin, now onto Azureus. I use version 4.3.1.4 with the classic interface, so you may have to adjust this based on your individual settings. Find your way into the options menu (Ctrl key and , key) and select mode, then change it to advanced.


8

Now while still in the options menu, expand the "Files" submenu, then highlight "Torrents"(don't expand click the actual menu name). Now check off "Import new .torrents automatically", and enter the directory that pidgin will autosave to. You can also modify the scan interval if you so choose.


9

And Voila! The setup is done. Try sending some .torrent files to the account set up on the torrent box, from the account you enabled auto accepts from. This isn't the most powerful solution when it comes to remote management, but it is one of the easiest to set up, and so long as you're not doing anything too intensive, it should suit you fine.