View Full Version : [ubuntu] How do you edit grub.cfg?

March 13th, 2010, 05:07 PM
I need to fix a part of the file and I don't know how to edit it. I'm using the Live CD - I have the install but I need to fix grub.cfg to use it. Any help?

March 13th, 2010, 05:25 PM
First thing. First three lines of grub.cfg:


But if you need to do a quick and dirty fix to get your hard disk install booting, here's what you do:

1 - grub.cfg is read-only, even for root. So...

sudo chmod 600 /media/mountpoint/boot/grub/grub.cfgReplace /media/mountpoint with whatever mountpoint the live session has mounted your hard disc root partition to.

2 - Edit grub.cfg:

gksudo gedit /media/mountpoint/boot/grub/grub.cfgThat should get you booting up - so long as your edits are correct. Once you're in your hard disc installation, set grub.cfg to read only again with:

sudo chmod 400 /boot/grub/grub.cfg

Although that may happen automatically when you next run sudo update-grub - I don't know. Now do your edits "properly" by editing whatever you need to in /etc/grub.d and running sudo update-grub.

Useful links if you don't already have them:



March 13th, 2010, 05:34 PM
How do you know where the mountpoint is?

Yes, I know, you shouldn't edit it, but I need to.

March 13th, 2010, 05:45 PM
How do you know where the mountpoint is?

In the live session, find your hard disc root partition in the Places menu. Click on it and it will be mounted and a Nautilus window will open. Just to the left of the breadcrumb trail location is an icon that looks like a pencil and notepad (I'm going from memory here. I'm in Lucid atm and they've redesigned Nautilus). Click on the pencil icon and the breadcrumb trail will change to a text path, which will show "/media/somethingorother". /media is the system folder that partitions/drives are automounted to and somethingorother is the folder in which your root partition is mounted. That's the bit I can't predict. It could be the partition label, or something else, or something else.

Alternatively, click on "Computer" in Places, then double-click on "Filesystem" and have a look in /media to find the precise name of the mountpoint.

Yes, I know, you shouldn't edit it, but I need to.

Agreed. You can do it "properly" from the live CD by chroot-ing, but life is short and the dirty fix works, and so long as you know that the next kernel upgrade will cause update-grub to be run and all your edits to disappear then no real harm is done.

March 13th, 2010, 05:58 PM
Neither steps work, I can't find it in "Places", and "Media" is empty. I can't even find partitions on GParted.

March 13th, 2010, 06:17 PM
I can't even find partitions on GParted.

Oh dear. That sounds serious.

I presumed you wanted to edit grub.cfg because you were having problems booting up. Perhaps there's a more fundamental problem here. What prompted you to want to edit grub.cfg?

Also - from the live CD, post the output of:

sudo fdisk -l(That's a lower-case L). That will probably confirm that bad news from Gparted but it would be a good idea to see anyway.

March 13th, 2010, 06:48 PM
I wanted to edit it because apparently there's an error in the file that needs to be fixed.

I put in "sudo fdisk -l", and... It loaded, then went back to "ubuntu@ubuntu: ~". nothing else appeared.

March 13th, 2010, 06:57 PM
I put in "sudo fdisk -l", and... It loaded, then went back to "ubuntu@ubuntu: ~". nothing else appeared.

Even if the disk or partition table was corrupted, or just one partition corrupted, you'd still get an output.

That sounds as though the disk isn't physically connected to the motherboard - or the BIOS is not detecting it. Go into the BIOS and see what's there. Is this a desktop or a laptop? If a desktop, open up the case and make sure the data cable is connecting the HD to the motherboard and that the power cable is still plugged into the HD.

March 13th, 2010, 07:53 PM
Okay, I'll try that later. Thanks!

March 15th, 2010, 10:45 PM
That worked, it must have been loose, I must not have seen it. I pushed it in farther - didn't feel anything, pushed it into the MoBo farther, didn't feel anything. But it works now. Thanks!