Thursday, February 15, 2007

Restoring the GNU Grub

Have you ever found yourself locked out of a Windows installation and had to reinstall them? If so, you have probably noticed that Windows restores the NTLDR (the NT bootloader) to the MBR and Grub disappears. In order to regain access to your GNU/Linux distribution you have to re-install grub and that can be confusing since nearly 1 out of 2 guides out there WILL NOT work (at least not the way they should)…

This happened to me just yesterday and the (manual) steps I describe below worked fine. Enough with the talking, let’s start.

There are two easy ways to reinstall/restore Grub: either automatically or manually.

The automatic way: Super Grub Disk is a LiveCD-based solution for restoring grub via a user-friendly interface. After a couple of minutes you will be asked to reboot and grub will be restored, simply and easily. This solution worked for many people I know but not for me, so I used the manual way which I describe just below.

The manual way:
  1. Get yourself a small LiveCD, I personally used Slax standard edition 5.1.8.1 but any LiveCD should do just fine.

  2. Boot using the LiveCD and mount the partition containing your distribution (if it hasn’t been already mounted by the LiveCD distro)

  3. Open a terminal window, gain root access, and type: "chroot /mnt/hd??" OR "chroot /media/hd??" where the first "?" stands for the hard disk letter and the second "?" stands for the partition number. Note that some distributions use "/media" for mounting drives, so check both "/mnt" and "/media" before attempting to manually mount the partition. If you don’t know which is the distribution partition (e.g. If you have multiple distros installed) then just navigate to the directories you mounted on the previous step until you determine which is the right one.

  4. Type "grub", a message saying "Probing devices to guess BIOS drives" should appear, just wait for a couple of minutes and soon you will see the grub prompt (it looks like "grub> _")

  5. Type "find /boot/grub/stage1". The result will be like "(hd0,5)" or perhaps "(hd0)". Keep this in mind because it is a key-text for the next steps.

  6. Type "root (hd?,?)", replace the question marks with what the output of the command above was.

  7. Now we are ready to install grub, select one of the following options depending on the place you want to install grub:
    • If you want to install grub on the MBR (recommended for most installations) type "setup (hd?)" where "?" is the result BEFORE the comma that command in step 5 returned

    • If you know what you are doing and want to install it on a separate partition, type "setup (hd?,?)" where the first "?" stands for the pre-comma output of the command of step 5 and the second "?" stands for the partition number.

  8. Type "quit" to exit the grub prompt

  9. Reboot the computer and remove the LiveCD, grub should now appear

LINKS:
GNU GRUB | Wikipedia Article - GNU GRUB | Wikipedia Article - NTLDR | Wikipedia Article - Master Boot Record (MBR) | Super Grub Disk | Slax |

EDIT: The command in step 6 had accidentally been copied in step 7 too. The guide has been fixed. The right command is "setup (hd?,?)" and not "root (hd?,?)" which should be used only in step 6. Many thanks to the people who pointed that out in their comments.

Wednesday, February 7, 2007

DRM - A sneaky threat

DRM, officially known as Digital Rights Management and also known as Digital Restrictions Management is a technology that is already here, inside many pieces of hardware (yes, possibly in YOUR hardware too). This article intends to provide you with some information concerning the the problem of DRM while keeping things as simple as possible.

But what is DRM without all this "technical mambo-jumbo"? DRM was designed as an attempt to control piracy. It is an encryption system and as such, it is based on "authorization". Basically you can play media files encrypted with DRM only if you have the "key" to allow the media player to use it. Unfortunately the way DRM was designed and implemented has several flaws, flaws that often violate user freedoms.

DRM is actually not a new concept, in the past some unsuccessful forms of DRM have been implemented. An early example of DRM is the CSS (Content Scrambling System) algorithm which when it first came out, allowed the "DVD Forum" to be in control of all consumer hardware capable of decoding DVD movies, restricting the use of DVD media even to the users who had the legal right to make backup copies of their movies.
  • DRM limits your options: If you want to play a file locked with DRM you have to use media players, mp3 players or CD Players that support DRM. iPod owners for example can only listen to the music they have purchased through the iTunes music store through their iPod, they cannot play it on non-apple devices. The famous Sony rootkit software which was installed by some music CD's in Windows PC's was a way of enforcing a kind of DRM to the end-users. Songs bought through the Napster service can only be played on players carrying the Microsoft PlaysForSure logo.
  • DRM restricts your rights: In most countries you have the right to make backup copies of music/movies/software for personal use, with DRM this option can be limited by the provider of the keys. Some services such as Napster only allow you to listen to the music you have downloaded if you have an active subscription but as described in the Wikipedia article: "But as soon as the user misses a payment the service renders all music downloaded unusable.". This is the reason DRM is also known as Digital Restrictions Management.
  • DRM can violate your privacy: The use of keys that must be retrieved from the Internet allows people who control this information (such as online music stores) to create a "profile" of your options. Should it be misused by someone, such information may be a potential threat to your privacy.
  • With DRM you no longer buy music, you rent music: It is possible to use DRM to limit specific actions of the end-user. Napster for example charges users who wish to use the music on their portable device an additional 5$ per month and pay an additional $.99 per each track to burn a track to CD or to listen to the track after the subscription expires.
  • DRM may pose a security threat to your system: Imagine the following scenario, which may become a very important security issue in the future: Your motherboard, like most new motherboards, may possibly have hardware DRM chips. What if a worm exploits a security hole and configures that chip to lock you out of your computer? Thanks to the way DRM is designed, it would be impossible to recover your data since no LiveCD would boot on a DRM-protected system... Matters can become even worse: What if it's not a worm that does that kind of damage but a cracker? He can blackmail you for money to give you back access to your data (this HAS actually happened in the past but it was with "plain" encryption, not DRM), or if he sells your data to other people who might be interested (other businesses etc.)? If Windows Genuine Advantage which is a software lock can actually lock you out of your computer, imagine what a hardware-level lock could do...
Some people have expressed the opinion that "crackers will probably workaround DRM soon". Indeed they will possibly workaround DRM protection of some systems but the nature of DRM is related to the Internet and any workaround will be patched soon. Furthermore, in some countries, such as the United States , it is illegal to circumvent measures taken to protect copyright such as encryption and this means that it is illegal to try to workaround DRM (see the DMCA - Digital Millennium Copyright Act). You may say "I just won't install any DRM stuff" but, as I have mentioned above, you may actually already have DRM in your hardware!

This is only a small part of the problems caused by DRM. There are many more problems that exceed the purpose of this article. The links below contain much more detailed information about DRM and I strongly recommend visiting them.

LINKS:
DefectiveByDesign.org | Wikipedia Article - Digital Rights Management | DRM.Info | DigitalFreedom.org | GNU | StopDRM | FreeCulture | EFF - Electronic Frontier Foundation | StopDRMNow.org | DMCA - Digital Millennium Copyright Act

Note: All of the opinions stated above are personal and do not in any way target specific businesses or services. Every example provided above is taken from wikipedia.org and does not reflect my personal opinion on the services.

Ubuntu and Upstart - a BAD combination

This computer and Ubuntu made a BAD start. Ever since version 4.10, Ubuntu would install, boot and it would just freeze either at the login screen (GDM) of just a few minutes after logging in.

Then one day the smart people of Ubuntu decided that it would be good to unify the LiveCD and the install CD [an evil mind would think they did it to decrease the cost of ShipIt... ;-p ] and so made users use the GUI to install Ubuntu. Hell, I DON'T like GUI installers and I like them even less ever since they used this stupid installer from version 6.06 untill now.

Up to version 6.06 Ubuntu would install and work for a while before it froze, since version 6.06 the normal CD wouldn't even boot, it would just flash colours on my monitor and that's all... Fortunately the alternate CD with the good old text-based installer works fine when I set a custom resolution before starting the installation. So, I finally managed to install Ubuntu (Edgy 6.10) on this computer...

When the installation had finished, I had to deal with the annoying freezing. This time it was far worse since it would always freeze before logging me in. After several hours of Googling and searching in various files in Ubuntu I discovered that the problem was caused by the default runlevel which Ubuntu uses. Ubuntu by default boots on runlevel 2 which is also the default at Debian (though I've never had such problems with Debian...).

So, all I had to do was to modify /etc/inittab, right? Nooooo... it was way too easy just to make it work like that. There had to be something that would make fixing the problem even more time-consuming and complex than it already was and the good guys at Ubuntu made sure this would happen.

I booted on failsafe, logged in and ls ini* on /etc/ to find the inittab... well, guess what, someone had the greeeeat idea of replacing the traditional init system with the new (and poorly documented) Upstart and so THERE WAS NO inittab under /etc/!

Having already spent hours trying to solve the freezing problem, I wasn't going to quit until I had made it work the way it should, so I got back to googling. The Upstart website had very little things and a poor wiki which wasn't helpful at all, fortunately after reading several threads at Ubuntuforums.org I managed to understand the way Upstart works and finally, after days of searching and reading I found the script that handled the default runlevel and modified it.

Blogs

So, after having criticized blogs numerous times over the years I am now writing my own blog... it's embarrassing but still, it's kewl ;-)