Language Selection

English French German Italian Portuguese Spanish

How-to Edit Grub

Filed under
HowTos
-s

So you've just installed your second, or third, or ninth Linux distribution and it either didn't recognize all your installs or you chose to skip that phase of the install. Of course you'd like to be able to boot all of these installs. Editing the grub.conf (or menu.lst) is an easy peasy procedure once you have an elementary understanding of the basic components.

If you are editing your Grub menu then we'll assume you already have it installed. This howto is to merely add an additional system to the existing file. This howto was inspired by this poor chap who resorted to reinstalling a whole system in order to update his Grub menu. No one should have to do that. Hopefully this will help.

Now I'm far from an expert, but having had to recently learn how to do this myself, I think I'll share what I do. The main advantage of using Grub is that editing the menu file is all that's necessary - as opposed to Lilo which requires one to rerun the Lilo program to reinstall it into the mbr.

The first thing I do is copy and paste an existing entry. No sense in retyping all of that and chances are you will probably want to use the same kernel parameters for the new install that you've used for previous. So:

  1. Copy and paste your favorite existing entry either where you think you'd like it or at the end of the list.

  2. Start the edit. The first thing one might need to consider is the title. This is easy, just change it to a meaningful name for your new install. In "Tryst's" case, he needed a new entry for PCLinuxOS 2007. So, he could have used PCLOS2007. Unlike Lilo, with Grub you can use names with spaces, so he could have used PCLOS 2007 if he chose.

  3. Now the bit more tricky part, the root. This is the component that specifies where the boot kernel is. Is it in a shared /boot partition or is it in the /boot directory of the new install?

    • First case scenario: Let's say you told the installer about your seperate /boot partition and it installed the boot kernel into it. The root component must then point to your shared /boot partition.

      The format might look scary at first, but it isn't. In the true Unix fashion, it begins its numbering with 0 (zero). The first number indicates the harddrive number. So, hda is 0, hdb is 1, hdc is 2, and so on. So, more than likely your boot partition is located on hda and in which case 0 is the number you want there. Just remember it's N - 1.

      The second number is the partition number. Again, hda1 is 0, hda2 is 1, and so on. So, say your /boot partition is located at sda5 you'd want to put a 4 there. So, your root entry might look like so:

      root (hd0,4)

    • Second scenario: You told the installer to install Grub onto the / (root) partition of the new install or you chose to skip installing Grub altogether. In this case the root component needs to point to the install partition. So, for example, say your new system is installed on hdb8, your root parameter should read:

      root (hd1,7)

  4. The next component is the kernel. This entry can contain lots of boot parameters but the most important is the correct name of the boot kernel. So, ls the /boot partition or directory to get that name.

    • If it's in a shared /boot partition you will need to just specify the name of the kernel as if in the working directory, like so:

      /vmlinuz-2.6.18.8.tex5

    • If it's on the install partition, then it will need to list the directory on that partition in which the boot kernel is found, like so:

      /boot/vmlinuz-2.6.18.8.tex5

      • Another necessary component of the kernel line is the root partition. This is in the more tradition partitioning scheme and points to the install partition. So, in our example, it should point to hdb8 like so:

        root=/dev/hdb8 (or root=/dev/sdb8)

      • Next is the resume. If you wish to use some advanced powersaving features such as suspend to disk, then you'll want a resume parameter listed. This is your swap partition where the disk image is stored. Again, the format is the more commonly used /dev/hdxX pattern. In my case, my swap is /dev/sda6, so it should look like:

        resume=/dev/sda6

      • You may also have other kernel parameters set here, such as splash=silent, vga=788, or noapic, whatever. These are system specific and usually already in place if you just copied an original working entry as in step 1.

  5. The final necessary component is the initrd. Not all boot kernels use or require an initrd, but most larger modern systems like openSUSE, Mandriva, and PCLOS do. This usually contains filesystem modules you might need to mount the system partition or the purdy boot splashes we like so much. You can tell if you need one by issuing ls -t in /boot directory of the new system or in the shared /boot partition. -t tells it to list by time, so you can see your newest files first. If one doesn't exist in the /boot directory, or you can't find one that matches the boot kernel, then you can assume you don't need one.

    If there is one listed, then you'll need to tell Grub about it. In "Tryst's" case, he does. So:

    • First case scenario: initrd /initrd-2.6.18.8.tex5.img

    • Second case: initrd /boot/initrd-2.6.18.8.tex5.img

That's it, that should get you in. If you need to, you can temporarily edit any grub entry at boot time, usually by hitting the "e" key. You will probably have to hit "e" again when the edit the entry screen appears to edit the particular component. Then you can hit "b" to boot it. You'll need to edit the grub.conf (or menu.lst) to make it permanent.

As stated this is how I do it and there is a lot more to Grub than discussed here. But hopefully this will help one edit their grub.conf or menu.lst file to boot their new Linux partitions.

PS. Windows and Unix (bsd) use entries like so:

title windows
root (hd0,0)
makeactive
chainloader +1

StumbleUpon



I use chain loader

It's good to see the subject nailed down in plain English. I found out about the chain loader method you mention from the PCLinuxOS documents for the previous version.

First, when I install a distro, I tell the installer to write the grub menu to the first sector of the root partition (i.e. the partition to which I'm installing) instead of the master boot record. The 'buntus just will not co-operate with that, so they get short shrift. I also become hypercritical of any distro which does not give me the option of using grub.

Secondly, before even beginning the installation, I add a verse like the following to menu.lst in the distro which has grub installed on the master boot record:

title KateOS_3.2
root (hd0,2)
chainloader +1

When you select that distro from the main grub menu, you then get the separate grub menu provided by the distro itself, with different options for logging in to that distro.

Advantages to using that method:
1. You can boot into the new system from the grub menu as soon as you have finished the initial installation;
2. The installer works out all the difficult technical stuff and you reduce the scope for typing errors;
3. You enable the new distro to have several options for booting, usually simple, non-fb and fail-safe.

Disadvantages:
1. There is a double choice to make and a double time lag. You can reduce the time lag on the second menu and make the distro the default choice if you wish.

This is how I eventually fixed it! (From "the poor chap")

Hey thanks for your effort, but what you wrote, for a person like me, was tooo scary. Really, I'm one of these people who find it difficult to read too much technical stuff... and so I found it difficult (and scary) to read your help. But you did inspire me to fix my GRUB immediately, and so, I did. And this is how I did it.

Firstly, taking on from your pointer, I realised that GRUB is just code. Thanks for that pointer.

Secondly, I realised that I actually needed to "cut and paste" only. Thanks for this pointer too.

However what I did, was I went to my openSUSE GRUB menu.lst and opened the file (using su) and then I copied openSUSE's boot code, which in my case was

title openSUSE 10.2
root (hd0,3)
kernel /boot/vmlinuz root=/dev/hdc4 vga=0x317 resume=/dev/hdc3 splash=silent
initrd /boot/initrd

I pasted this to the end (replacing my previous openSUSE detailed attempt). And then tested.

Viola, it worked!

Now I know that people like me are the bane of linux. Meaning, if I knew the code, I'd understand it... but instead, more and more, a generation of windows-based users are infiltrating linux and filling the space with a desire for 'easy' solutions. I try not to be one of them, but sometimes I am. However, I guess I have to go with my strengths. I don't think I will ever be friendly about understanding code (cut and paste solutions are just about all that I can do), and so I guess I want to thank you again for taking the time to address this issue... and hopefully there will be more people who will read your entry and actually UNDERSTAND what they're doing.

Cheers!

(ps. I'm going to paste this comment onto my blog along with a link to your post, because your solution actually looks and sounds really cool!)

It used to be worse

These days, BIOSes on modern motherboards work great with GRUB (and, presumably, LILO -- but, as you noted, GRUB has the advantage of not having to be reinstalled to the MBR each time its configuration file is changed). I had one computer in the mid 90s that flat would not boot using LILO, and another computer in the late 90s that would use LILO, but flat would not boot using GRUB.

There's nothing quite like a hang at boot time to induce panic, especially when you dual-boot. (Backup? What's a backup?) So afterwards, even through a succession of new computers and new motherboards, I first used loadlin, until MS-DOS went away, and then GRUB for Windows, which uses Windows' NTLDR. Finally, one day an install of openSUSE put GRUB on the MBR (even though I told it not to) and it worked just fine, so I gave in and started using "real" GRUB.

It's also really easy these days to pop in a Knoppix CD and make a backup of the MBR (with or without the partition table) and save it on a floppy.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

More in Tux Machines

OpenShift and Google

  • Red Hat launches 'OpenShift' dedicated on Google Cloud Platform
    World's leading provider of open source solutions Red Hat has announced the general availability of OpenShift Dedicated on Google Cloud Platform.
  • Red Hat and Google join forces on containers
    Red Hat and Google are set to offer enterprise customers a managed OpenShift service hosted on Google's cloud to make the build, launch and management of applications a less time-consuming process. OpenShift Dedicated on Google Cloud Platform will speed up the adoption of containers, according to Red Hat, giving developers the guidance they need to create applications and deploy them faster.
  • Red Hat’s Container Platform Lands on Google Cloud
    Red Hat’s OpenShift Dedicated container platform will now be available on Google Cloud Platform, the companies announced yesterday. OpenShift Dedicated is a managed version of Red Hat’s OpenShift container platform, targeting enterprises. Launched in December, the Dedicated version puts Red Hat in the role of a service provider, taking care of infrastructure and operations.

Security News

  • A 'mystery device' is letting thieves break into cars and drive off with them, insurance group says
    Insurance crime investigators are raising alarms over a device that not only lets thieves break into cars that use keyless entry systems but also helps start and steal them. Investigators from the National Insurance Crime Bureau, a not-for-profit organization, said in an interview they obtained what they called the “mystery device” from a third-party security expert at an overseas company. So far, the threat here may be mostly theoretical. The crime bureau said it heard of the device being used in Europe and had reports that it had entered the U.S., but said there are no law enforcement reports of a car being stolen using it in the United States.
  • Turkish hacking group offers tiered points rewards program for DoS attacks
    A TURKISH HACKING GANG is taking an unusual approach to funding denial of service attacks, and is soliciting for, and offering hackers rewards for taking down chosen pages. This is unusual, as far as we know, and it has led to the creation of comment from the security industry. Often these things do.
  • German judges explain why Adblock Plus is legal
    Last month, Adblock Plus maker Eyeo GmbH won its sixth legal victory in German courts, with a panel of district court judges deciding that ad-blocking software is legal despite German newsmagazine Der Spiegel's arguments to the contrary. Now, the reasoning of the Hamburg-based panel of judges has been made public. According to an unofficial English-translated copy (PDF) of the judgment, Spiegel Online argued it was making a "unified offer" to online consumers. Essentially, that offer is: read the news content for free and view some ads. While Internet users have the freedom "not to access this unified offer," neither they nor Adblock Plus have the right to "dismantle" it. Eyeo's behavior thus amounted to unfair competition, and it could even wipe the offer out, Spiegel claimed. "The Claimant [Spiegel] argues that the Defendant’s [Eyeo's] business model endangers the Claimant’s existence," reads the judgment, which isn't final because it can be appealed by Spiegel. Because users aren't willing to pay for editorial content on the Web, "it is not economically viable for the Claimant to switch to this business model." Spiegel asked for an accounting of all the blocked views on its website and a fine to be paid—or even for managers Wladimir Palant and Till Faida to be placed in "coercive detention" of up to two years.
  • Op-ed: I’m throwing in the towel on PGP, and I work in security [Ed: Onlya tool would drop PGP for Facebook-controlled Whatsapp. The company back-doors everything under gag orders.]
    In the coming weeks I'll import all signatures I received, make all the signatures I promised, and then publish revocations to the keyservers. I'll rotate my Keybase key. Eventually, I'll destroy the private keys.
  • 90 per cent of NHS Trusts are still running Windows XP machines
    90 PER CENT of the NHS continues to run Windows XP machines, two and a half years after Microsoft ditched support for the ageing OS. It's Citrix who is ringing the alarm bells, having learnt that 90 per cent of NHS Trusts are still running Windows XP PCs. The firm sent Freedom of Information (FoI) requests to 63 NHS Trusts, 42 of which responded. The data also revealed that 24 Trusts are still not sure when they'll migrate from Windows XP to a newer version of Microsoft's OS. 14 per cent said they would be transitioning to a new operating system by the end of this year, while 29 per cent pledged to make the move sometime next year.
  • Ransomware blamed for attack that caused Lincolnshire NHS Trust shutdown
    RANSOMWARE is to blame for an attack which saw an NHS Trust in Lincolnshire that forced to cancel operations for four days in October. In a statement, Northern Lincolnshire and Goole NHS Foundation Trust said that a ransomware variant called Globe2 was to blame for the incident.
  • Researchers Find Fresh Fodder for IoT Attack Cannons
    New research published this week could provide plenty of fresh fodder for Mirai, a malware strain that enslaves poorly-secured Internet of Things (IoT) devices for use in powerful online attacks. Researchers in Austria have unearthed a pair of backdoor accounts in more than 80 different IP camera models made by Sony Corp. Separately, Israeli security experts have discovered trivially exploitable weaknesses in nearly a half-million white-labeled IP camera models that are not currently sought out by Mirai.
  • Your data is not safe. Here's how to lock it down
    But some people worry that government surveillance will expand under a Donald Trump presidency, especially because he tapped Mike Pompeo, who supports mass surveillance, for CIA chief.
  • Tor at the Heart: Library Freedom Project
    Library Freedom Project is an initiative that aims to make real the promise of intellectual freedom in libraries by teaching librarians and their local communities about surveillance threats, privacy rights and responsibilities, and privacy-enhancing technologies to help safeguard digital freedoms.
  • PowerShell security threats greater than ever, researchers warn
    Administrators should upgrade to the latest version of Microsoft PowerShell and enable extended logging and monitoring capabilities in the light of a surge in related security threats, warn researchers [...] Now more than 95% of PowerShell scripts analysed by Symantec researchers have been found to be malicious, with 111 threat families using PowerShell.
  • Five-Year-Old Bait-and-Switch Linux Security Flaw Patched
    Maintainers of the Linux Kernel project have fixed three security flaws this week, among which there was a serious bug that lingered in the kernel for the past five years and allowed attackers to bypass some OS security systems and open a root shell.
  • The Internet of Dangerous Auction Sites
    Ok, I know this is kind of old news now, but Bruce Schneier gave testimony to the House of Representatives’ Energy & Commerce Committee about computer security after the Dyn attack. I’m including this quote because I feel it sets the scene nicely for what follows here. Last week, I was browsing the popular online auction site eBay and I noticed that there was no TLS. For a moment, I considered that maybe my traffic was being intercepted deliberately, there’s no way that eBay as a global company would be deliberately risking users in this way. I was wrong. There is not and has never been TLS for large swathes of the eBay site. In fact, the only point at which I’ve found TLS is in their help pages and when it comes to entering card details (although it’ll give you back the last 4 digits of your card over a plaintext channel).

Android Leftovers

Linux 4.8.14

Turns out I'm going to be on a very long flight early tomorrow morning, so I figured it would be good to get this kernel out now, instead of delaying it by an extra day. So, I'm announcing the release of the 4.8.14 kernel. All users of the 4.8 kernel series must upgrade. The updated 4.8.y git tree can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-4.8.y and can be browsed at the normal kernel.org git web browser: http://git.kernel.org/?p=linux/kernel/git/stable/linux-st... Read more Also: Linux 4.4.38 Linux Kernel 4.8.14 Hits the Streets with Numerous Networking Improvements, More