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

today's leftovers

  • How to dual-boot Linux and Windows
    Even though Linux is a great operating system with widespread hardware and software support, the reality is that sometimes you have to use Windows, perhaps due to key apps that won't run under Linux. Thankfully, dual-booting Windows and Linux is very straightforward—and I'll show you how to set it up, with Windows 10 and Ubuntu 18.04, in this article. Before you get started, make sure you've backed up your computer. Although the dual-boot setup process is not very involved, accidents can still happen. So take the time to back up your important files in case chaos theory comes into play. In addition to backing up your files, consider taking an image backup of the disk as well, though that's not required and can be a more advanced process.
  • Weather Forecasting Gets A Big Lift In Japan
    This is a lot more compute capacity than JMA has had available to do generic weather forecasting as well as do predictions for typhoons, tsunamis, earthquakes, and volcanic eruptions – the weather forecasting alone is predicted to run 10X faster, according to Cray.
  • Bitwarden Password Manager Adds Command Line Vault
    Bitwarden, the secure, open source password manager we talked about recently, added a command line tool to its list of apps you can use to access your passwords. Bitwarden CLI is currently in public beta testing, and according to its documentation, it includes all the features available in other Bitwarden client applications, like the desktop or browser extension.
  • GSoC’18 Week 1
    The first week of the coding period was great and I got to learn a lot of new things. My mentors help me on every stage and the work is going on as planne [...] Improvement in the overall UI is still in progress. Other than this, I have been working on refactoring the current code for this activity and breaking the whole code into various elements. For the next week, my main task is to complete the overall UI of this activity and add more geometries for drawing.
  • Time to Test Plasma 5.13 Beta
    The forthcoming new release of Plasma 5.13 will have some lovely new features such as rewritten System Settings pages and Plasma Browser Integration. But we need testers. Incase you missed it the Plasma 5.13 release announce has a rundown of the main features. If you are an auditory learner you can listen to the Late Night Linux Extra podcast where Jonathan “great communicator” Riddell talks about the recent sprint and the release.
  • GSoC students are already hacking!
    We always enjoy that new people join openSUSE community and help them in their first steps. Because of that, openSUSE participates again in GSoC, an international program in which stipends are awarded to students who hack on open source projects during the summer. We are really excited to announce that this year four students will learn about open source development while hacking on openSUSE projects. The coding period started last week, so our students are already busy hacking and they have written some nice articles about their projects. ;)
  • CryptoFest a openSUSE Conference již tento víkend v Praze
  • openSUSE Conference a CryptoFest 2018
  • Aaeon reveals two rugged, Linux-ready embedded PCs
    Aaeon unveiled two Linux-friendly embedded systems: an “AIOT-IP6801” gateway equipped with an Apollo Lake-based UP Squared SBC with WiFi and LoRa, and a “Boxer-8120AI” mini-PC with an Nvidia Jetson TX2 module and 4x GbE ports. Aaeon announced that three of its Linux-ready embedded systems have won Computex d&j awards, including two previously unannounced models: an Intel Apollo Lake based AIOT-IP6801 gateway based on Aaeon’s community-backed UP Squared board, as well as a Boxer-8120AI embedded computer built around an Arm-based Jetson TX2 module.
  • Last Call for Purism's Librem 5 Dev Kits, Git Protocol Version 2 Released, LXQt Version 0.13.0 Now Available and More
    Purism announces last call for its Librem 5 dev kits. If you're interested in the hardware that will be the platform for the Librem 5 privacy-focused phones, place your order by June 1, 2018. The dev kit is $399, and it includes "screen, touchscreen, development mainboard, cabling, power supply and various sensors (free worldwide shipping)".

Programming: GNU Parallel, Rust, Go

OSS Leftovers

  • Openlab: what it is and why it matters
    Six months on from its announcement at Openstack Summit Sydney in late 2017, community testing project OpenLab is in full swing. OpenLab was initially formed by Intel, Huawei and the OpenStack foundation as a community-led project for improving SDK support and also introducing other platforms like Kubernetes and Cloud Foundry to the Openstack environment. Ultimately the idea is to improve usability in hybrid and multi-cloud environments. Melvin Hillsman sits on the governance board along with Dr Yih Leong Sun of Intel and Chris Hoge from the Foundation. Hillsman moved from Rackspace to Huawei to work specifically on the project. "The reason we think Openlab is important is, basically, Openstack for some time has been very specific about testing and integration for Openstack services, focusing only on the projects started at Openstack," Hillsman tellsComputerworld UK at the Openstack Vancouver Summit. "It's been working very well, it's a robust system. But for me as a person in the user community - my getting involved in Openstack was more on the operator-user side.
  • Open source innovation tips for the customer-driven economy
    New technologies, ranging from big data and blockchain to 3D printing, are giving rise to new opportunities and challenges for companies today. To stay competitive, organizations need to become more intelligent, customer-centric, and increasingly agile to cope with changing business demands. The worry for many companies which are trying to innovate is that while the speed and scope of applications are expanding rapidly, the variety and complexity of technology is increasing simultaneously, putting pressure on their IT infrastructure. Speaking at the SUSE Expert Days 2018 held in Singapore recently, Dr Gerald Pfeifer, VP of Products and Technology Program, SUSE, told attendees that these prevailing trends have come together to make Open Source the primary engine for business innovation.
  • Qualcomm is able to release the Snapdragon 845 source code in 6 weeks
    Qualcomm‘s latest high-end system-on-chip, the Qualcomm Snapdragon 845, was announced at the Snapdragon Tech Summit back in December. The chipset offers 4 Kryo 385 (A75 “performance”) and 4 Kryo 385 (A55 “efficiency”) CPU cores, the latest Adreno 630 GPU, the Spectra 280 ISP, the Hexagon 685 DSP, the Snapdragon X20 LTE modem, and a new Secure Processing Unit (SPU). The Snapdragon 845 SoC is a powerhouse in benchmarks and it is already available in devices like the Samsung Galaxy S9/S9+, Xiaomi Mi Mix 2S, and the OnePlus 6. Developers on our forums have been itching to get their hands on a device with Qualcomm’s latest and greatest, but there’s just one thing that has made some developers worry about the future of development on the platform: The lack of publicly available source code for the kernel, HALs, framework branches, and more on the CodeAurora Forums.
  • Kata Containers 1.0 Released, Formerly Intel Clear Containers
    Back in December was the announcement of Intel's Clear Containers being spun into a new project called Kata Containers in collaboration with other organizations. Kata Containers has now reached their version 1.0 milestone. Kata Containers 1.0 is now available for this container technology designed for offering a secure and scalable container experience built atop Intel VT technology.
  • What's new in OpenStack?
    As OpenStack Foundation Chief Operating Officer Mark Collier referenced in his opening keynote, the uses which OpenStack is seeing today expand far beyond what most who were involved in the early days of the project could have ever imagined. While OpenStack started out primarily in the traditional data center and found many large-scale users, particularly in the telecommunications industry, who were using it to manage huge installations of traditional x86 server hardware, the flexibility of OpenStack has today allowed it to thrive in many other environments and use cases. Today, we see OpenStack powering everything from academic and research projects to media and gaming services, from online retail and e-commerce to manufacturing and industrial applications, and from finance to healthcare. OpenStack is found in all of these different places not just because it is cheaper than using the public cloud, not just because it makes compliance with various regulations easier, but because its open source code makes it flexible to all sort of different situations.
  • Should Red Hat Buy or Build a Database?
    For a decade, at least, observers of the company have speculated about whether Red Hat would or should enter the database market. The primary argument, one made in this space eight years ago, has historically been that Red Hat is de facto leaving potential dollars on the table by limiting itself to operating platform and immediately adjacent markets. In a more recent piece, analyst Krishnan Subramanian adds that Red Hat is at risk because databases represent a control point, one that the company is effectively ceding to competitors such as AWS or Microsoft.
  • Tidelift Raises $15M Series A From General Catalyst, Foundry, & Others
    This morning Tidelift, a startup focused on helping developers work with open source technology, announced that it has closed a $15 million Series A round of funding co-led by General Catalyst, Foundry, and Matthew Szulik, the former CEO of Red Hat, a public open source-centered technology company. The subscription-powered startup has an interesting business model which we’ll dive into shortly, but it’s worth noting that the open source space as a whole is quite active. It’s something that Crunchbase News covered last year, describing how startups working with open source software have enjoyed a dramatic rise in investor interest. That puts Tidelift in the midst of a trend.
  • Tidelift lands $15M to deliver professional open-source support
    Tidelift Inc. is raising $15 million as it looks to boost its unique open-source software model that sees companies pay for professional support of their favorite projects, allowing those that maintain them to get compensated too. The Series A round was led by the investment firms General Catalyst and Foundry Group, as well as former Red Hat Inc. Chairman and Chief Executive Matthew Szulik. The company was able to attract the investment after coming up with a novel idea for maintaining the most popular open-source software projects in a way that benefits both the users and those who help to create them. It works like this: Companies pay a subscription fee that entitles them to professional-grade support, similar to the kind of commercial subscriptions offered by firms such as Red Hat, Cloudera Inc. and Docker Inc. A part of these fees are then used to pay the developers who maintain the software. The net result, at least in theory, is that everyone is happy, as companies enjoy the benefits of professional support at lower rates than they might expect from an established firm, and the developers of the software are finally rewarded for their efforts.

today's howtos