3

I had to reinstall windows. Unfortunately, this means that grub isn't working. Booted from live CD, opened terminal and typed:

sudo update-grub

But got the message returned

sudo: can't stat /etc/sudoers: Input/output error
sudo: no valid sudoers sources found, quitting

Tried without sudo, it told me I had to be root to do it.

Jorge Castro
  • 71,754
Matthew
  • 31

2 Answers2

2

There must be some error with the liveCD. As suggested by @psusi, you should check the disk. If there's an error, you may want to replace it before using it for anything else. And it's a good idea to check the ISO before burning.

Originally, I had thought that sudo was not required since there's no password, but I found that this is not the case. Programs like gparted, that normally prompt for a password, will run from the menu without prompting; but commandline programs still require sudo, although they don't prompt for a password.

But you should be aware that update-grub would not be the correct method to fix this in any case; it simply generates the menu configuration file (/boot/grub/grub.cfg) in the partition that the GRUB MBR code reads (in this case, the CD, which can't even be written). In your case, the GRUB code is not in the MBR, so it is not being run; therefore, it never reads the menu configuration file.

What you need to use is grub-install to fix your problem, which is a bit more complex, and requires mounting the disk. It may be easier for you to use the boot repair disk . This disk will automatically fix this problem.

In order to actually put GRUB on the MBR, you need to run grub-install, specifying which directory to use for grub.cfg (it will default to /boot/grub/grub.cfg), and specifying the disk for the MBR code, such as sudo grub-install --root-directory = /media/sda2 /dev/sda; assuming /dev/sda2 is mounted at /media. The main point is that the partition must be mounted to have grub.cfg installed.

The syntax for grub-install is basically:

sudo grub-install < mounted location of grub.cfg > < name of disk MBR for GRUB itself >

So, in my example it assumes /dev/sda2 is mounted at /media/sda2, and will put grub.cfg in /media/sda2/boot/grub.

Marty Fried
  • 18,466
  • Just tried it without sudo, it tells me: grub-mkconfig: You must run this as root – Matthew Jun 18 '12 at 19:57
  • I don't know that I ever had to run that particular program, but others have worked fine without sudo. Don't know how can you possibly use it if you don't have a password. Maybe there's something wrong with the sudoers file, There's a Boot Repair Disk that fixes this problem automatically, if you want to burn one. That's what I usually use due to laziness. You can read about it here. – Marty Fried Jun 18 '12 at 20:05
  • 1
    sudo is always required for root access. Since there is no password on the livecd, it doesn't prompt for one. – psusi Jun 18 '12 at 22:15
  • @psusi: the only "root access" I've needed with a live CD was to run gparted, and it runs without any mention of needing root access, unlike the normal installation. This is why I thought it might not be required. But I knew, obviously, that a password could not be required. I did mention in the comment later that there may be something wrong with the disk, and I helped guide him to the easiest way to fix the problem, so I don't understand why the downvotes. – Marty Fried Jun 18 '12 at 23:42
  • 1
    @psusi It would be more accurate to say that sudo or PolicyKit is always required for root access. A lot of what people tend to think is a graphical frontend for sudo is actually PolicyKit (which is completely independent of sudo). – Eliah Kagan Jun 18 '12 at 23:47
  • @DylanMcCall, no, there is no password... user name is ubuntu, has no password. You can run passwd and set a password and see that it accepts the empty password for your current password. – psusi Jun 19 '12 at 02:12
  • @MartyFried, when you run gparted from the menu, it is launched with gksu automatically, and you don't get the password prompt since there is no password for the default user on the livecd. – psusi Jun 19 '12 at 02:13
  • @psusi, that may be, and I suspected it might be the case, but the bottom line is that it is somewhat misleading, and made me think it wasn't required, especially since there is no published password. The point is, I didn't mislead the OP, and actually said it with a caveat, so I have no idea why the anonymous downvotes, especially since I may have helped indirectly. Yours was the only comment after the downvotes, and I'm assuming it wasn't related to a minor half error, so I'm left with feeling a little let down. – Marty Fried Jun 19 '12 at 02:32
  • If you remove the bit about the sudo password and focus on the grub-install vs update-grub, I'll switch my vote. – psusi Jun 19 '12 at 02:39
  • Ah yes, indeed that is true. I must be mixing it up with something else. (Or maybe that's how it once worked and I'm living in the past?). I'll just delete that comment to clear up any confusion. Sorry about any trouble :) – Dylan McCall Jun 19 '12 at 04:40
  • @psusi, I had edited the post to say I checked and was wrong - I didn't think deleting it was good because it might make the comments confusing. But I went ahead and deleted it anyway, resisting the temptation to simply delete the entire answer, since it's now mostly extra information that I'm not sure anyone cares about. – Marty Fried Jun 19 '12 at 04:46
1

It seems that your cd is damaged. You can run the disc check at the boot menu to confirm.

Eliah Kagan
  • 117,780
psusi
  • 37,551