LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-02-2014, 07:24 AM   #1
StuartK24
Member
 
Registered: Jan 2010
Location: Melbourne, Australia
Distribution: MX 18.3
Posts: 32

Rep: Reputation: 2
Can't load lilo or grub onto MBR


I have attempted to load Debian 7.7 onto my laptop, which is already running Windows 7. The installation seemed to going smoothly, except for notifications of some non-free firmware I would need. I'd finished partitioning the disc and the base system was installed. It then came to the part where I needed to load the boot loader onto the MBR. I couldn't load either lilo or grub onto the MBR. I think the notice both time was that the package had failed. I didn't know what to do next and aborted the installation. I was able to recover Windows, which wouldn't boot after the failed Debian install.
I obviously can't boot my Debian and don't know what to do next. Any help would be greatly appreciated.
 
Old 11-02-2014, 08:12 AM   #2
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
You can boot into LiveCD (e.g. LinuxMint, Ubuntu or whatever else) and install grub from there.
1. mount your Debian partition somewhere ( e.g. /mnt)
2. run "grub-install --root-directory=/mnt/ /dev/sdX" where sdX is the disk that contains your Debian partition. sdX without a number at the end.
3. run "update-grub" or "grub-install -o /boot/grub/grub.cfg" (depends on what LiveCD you use)

Last edited by Teufel; 11-02-2014 at 08:17 AM.
 
1 members found this post helpful.
Old 11-04-2014, 06:56 AM   #3
StuartK24
Member
 
Registered: Jan 2010
Location: Melbourne, Australia
Distribution: MX 18.3
Posts: 32

Original Poster
Rep: Reputation: 2
Is the directory correct?

I want to load grub into the MBR. So shouldn't I be installing it into /dev/sda ? My Debian partition, the root directory, is at /dev/sda5.

Last edited by StuartK24; 11-04-2014 at 07:02 AM.
 
Old 11-04-2014, 07:02 AM   #4
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,492

Rep: Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488
Quote:
So shouldn't I be installing it into /dev/sda ?
If you have only one hard drive, then yes. You didn't indicate how many drives you had so the above post was an example with the "X".
 
Old 11-04-2014, 08:41 AM   #5
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Do not forget to create a copy of MBR. If something will go wrong, you can easily restore your current Windows boot.
dd if=/dev/sdX of=/some/safe/place/sdX.mbr bs=512 count=1
 
1 members found this post helpful.
Old 11-20-2014, 03:12 AM   #6
StuartK24
Member
 
Registered: Jan 2010
Location: Melbourne, Australia
Distribution: MX 18.3
Posts: 32

Original Poster
Rep: Reputation: 2
Can't load GRUB

Thanks to everyone for your help. I've been able to back up my mbr to a usb, but I cannot load grub.
I tried to install GRUB with the line recommended above:
#grub-install --root-directory=/mnt/ /dev/sda
I received the following message:
Path 'mnt/boot/grub' is not readable by GRUB on boot. Installation is impossible. Aborting.
I was running a live artistX CD and was logged is as superuser at the time.
 
Old 11-20-2014, 04:17 AM   #7
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Did you try it in chroot environment?

Code:
mount /dev/sda5 /mnt
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys  /mnt/sys
chroot /mnt /bin/bash
grub-install /dev/sda
update-grub
exit
reboot
if you getting an error on grub-install, you can try
grub-install --recheck /dev/sda
or
grub-install --recheck --no-floppy /dev/sda

Keep in mind, liveCD must be the same architecture as your debian installation (either both are 32bit or both are 64bit).
 
Old 11-20-2014, 07:01 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,679

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
Quote:
Originally Posted by Teufel View Post
Do not forget to create a copy of MBR. If something will go wrong, you can easily restore your current Windows boot.
dd if=/dev/sdX of=/some/safe/place/sdX.mbr bs=512 count=1
FYI the MBR contains both the boot loader and the partition table which is a total of 512 bytes. The boot code is the first 446 bytes and the partition table the rest. If you are not careful you can overwrite the partition table and you could potentially lose data.

There is a known bug for your problem assuming you have more then one disk. You can also use the rescue mode of the installer. As stated you need to chroot into your root file system.

https://www.debian.org/releases/stab...ian-installer/

Last edited by michaelk; 11-20-2014 at 07:19 AM.
 
Old 11-20-2014, 09:55 AM   #9
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Quote:
Originally Posted by michaelk View Post
FYI the MBR contains both the boot loader and the partition table which is a total of 512 bytes. The boot code is the first 446 bytes and the partition table the rest. If you are not careful you can overwrite the partition table and you could potentially lose data.
Yes, I am aware of 446 bytes of boot code as well as of following partitions table.
When you are going to manipulate mbr, its a good idea to save partitions layout as well, just to be on the safe side, isn't it?
BTW, it is absolutely safe to put saved partitions table back to hdd unless you made changes on partitions layout.
Of course, if you made re-partitioning/resizing, you have to use only first 446 bytes.
 
Old 11-20-2014, 11:04 AM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,679

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
Quote:
Of course, if you made re-partitioning/resizing, you have to use only first 446 bytes.
The point I was trying to make. You can find many threads where the OP has wanted to repair the boot loader via dd and screwed up the partition table.
 
Old 11-20-2014, 11:21 AM   #11
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Quote:
Originally Posted by michaelk View Post
You can find many threads where the OP has wanted to repair the boot loader via dd and screwed up the partition table.
I did it at least ten times in order to restore mbr after windows installation. It is absolutely safe, if you didn't re-partitioning on your hdd.
If someone screwed up partition table - it isn't dd issue, as well as not a 446 vs 512 bytes issue. You must think what are you doing and not stupidly copypaste suggested code.
 
Old 11-20-2014, 06:34 PM   #12
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
See if there is an option in bios to disable Execution Bit.
 
Old 11-24-2014, 07:51 AM   #13
StuartK24
Member
 
Registered: Jan 2010
Location: Melbourne, Australia
Distribution: MX 18.3
Posts: 32

Original Poster
Rep: Reputation: 2
Thanks everyone, especially Teufel. I've been able to load Grub. I couldn't load the .cfg, but after a bit of research on the net, I was able to boot both Windows and Debian from the Grub command line.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i load windows onto a linux box with LILO in MBR? wdave58 Linux - Software 2 01-19-2010 04:57 PM
Mbr lilo (error load operating system) hellasyoda Slackware 14 04-20-2008 04:05 PM
Lilo (mbr) won't load winXP (hdb1) jonaskoelker Linux - General 6 07-04-2004 06:13 AM
Lilo fails to load in MBR vishalwaghmare Linux - Newbie 2 12-16-2002 07:24 PM
Does lilo/grub have to be in the MBR? wincen Linux - General 9 06-20-2002 07:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration