Repair grub

Post your tutorials and howtos here.
User avatar
Arjen Balfoort
Site Admin
Posts: 9395
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Repair grub

Postby Arjen Balfoort » 15 Mar 2013 14:55

Today I needed to prepare my system for testing (for the upcoming UP): create 16 extra partitions to install SolydX and SolydK, pointing to different repositories. While I was doing that, I was not only reminded of the fact that you can only add 4 primary partitions, but you're also limited to a total of 15 partitions on a SCSI or SATA drive.

Needless to say, I totally ruined my drive and decided to remove all partitions and deal with it in the live-installer. In the live-installer I started gparted and added a root, home, swap and extended partition with 12 logical partitions. All went well, and I was offered to reboot. So, I did...to end in a black screen with a nervously blinking cursor: no grub! :shock:

I booted up the SolydXK live USB again, and created and executed this bash:

Code: Select all

#!/bin/bash
mount -t ext4 /dev/sda1 /target
mount --bind /dev/ /target/dev/
mount --bind /dev/shm /target/dev/shm
mount --bind /dev/pts /target/dev/pts
mount --bind /sys/ /target/sys/
mount --bind /proc/ /target/proc/

chroot /target/ /bin/sh -c "grub-install --force /dev/sda"
chroot /target/ /bin/sh -c "grub-mkconfig -o /boot/grub/grub.cfg"

umount --force /target/dev/shm
umount --force /target/dev/pts
umount --force /target/dev/
umount --force /target/sys/
umount --force /target/proc/
umount --force /target
/dev/sda1 was the partition where I installed root.
/dev/sda is where I wanted grub to be installed.

I rebooted, and hey presto!
All works as expected. I don't know why it didn't function the first time, but I think that although the chances are slim that you get in this particular predicament, it's nice to have this fix available.


SolydXK needs you!
Development | Testing | Translations

wayne
Posts: 178
Joined: 25 Feb 2013 14:58

Re: Repair grub

Postby wayne » 16 Mar 2013 02:49

Schoelje wrote: I was not only reminded of the fact that you can only add 4 primary partitions, but you're also limited to a total of 15 partitions on a SCSI or SATA drive.
Hi Schoelje,

I do not think the limit is 15. I had that long time ago when using lilo.

But we are using grub2, and it can go very large in partition number, at least 63....I have not reached that yet.
Used to be using 30+ partitions on 640G SATA drive without problem using grub2 or grub legacy.

Here, I just test by putting the SolydX32 on partition 24 /dev/sda24 and have no trouble booting it.

/boot/grub/grub.cfg had this on
### BEGIN /etc/grub.d/10_linux ###
menuentry 'SolydXK GNU/Linux, with Linux 3.2.0-4-686-pae' --class solydxk --class gnu-linux --class gnu --class os {
load_video
set gfxpayload=800x600
insmod gzio
insmod part_msdos
insmod ext2
set root='(/dev/sda,msdos24)'
search --no-floppy --fs-uuid --set=root ae6215bf-3d35-4381-8f9e-64ca72c7d89d
echo 'Loading Linux 3.2.0-4-686-pae ...'
linux /boot/vmlinuz-3.2.0-4-686-pae root=UUID=ae6215bf-3d35-4381-8f9e-64ca72c7d89d ro quiet splash
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.2.0-4-686-pae
}
currently running SolydX32 on partition 24

Code: Select all

solydx32 wayne # blkid -o list |grep /dev/sda2
/dev/sda2  swap             (not mounted)  5e5af78e-7269-4053-9f84-a3c7625e35b1
/dev/sda20 ext2             (not mounted)  8f196a54-da77-4d89-a45b-9a15a3d8c0e3
/dev/sda21 ext2             (not mounted)  f5256afd-94c7-41be-89c6-ce04c3285edf
/dev/sda22 ext2             (not mounted)  3f636148-e2cb-4811-b990-e55f598251ac
/dev/sda23 ext2             (not mounted)  cf239ab1-facd-4bbf-898d-60f85ff1f242
/dev/sda24 ext4             /              ae6215bf-3d35-4381-8f9e-64ca72c7d89d

User avatar
Arjen Balfoort
Site Admin
Posts: 9395
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: Repair grub

Postby Arjen Balfoort » 16 Mar 2013 07:22

Unfortunately, on my SATA drive, both fdisk and gparted refused to make more than 15 partitions, resulting in an error.
The size of partitions did not matter.
I never got to the grub part until I limited the drive to 15 partitions, that's when I had to repair grub.
I think the limitation of partitions on my drive and not being able to boot into grub were totally coincidental.


SolydXK needs you!
Development | Testing | Translations

wayne
Posts: 178
Joined: 25 Feb 2013 14:58

Re: Repair grub

Postby wayne » 16 Mar 2013 09:04

HI Schoelje,
So I did a check on another hard disk, and realise the 'current Debian wheezy' version of gparted gave me error when I attempt to create partition number 16, 17 , etc..
Not sure why, perhaps similar to your experience..

When I had some issue with gparted, especially if it is repeatable, I would usually fall back to using gparted from partedmagic.iso, partedmagic is Slackware based.

Just compare their versions:

1. SolydXK, Debian wheezy etc
gparted 0.12.1
libparted 2.3


2. partedmagic, 'second latest' edition,
gparted 0.14.1
libparted 3.1


Then I booted to partedmagic iso, run live, then run gparted and it has no issue to create any partition number 16 to 30....enough for me.

Perhaps, if you must have more partitions due to your work requirement, you could try latest version gparted running from partedmagic.iso

User avatar
Arjen Balfoort
Site Admin
Posts: 9395
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: Repair grub

Postby Arjen Balfoort » 16 Mar 2013 09:14

That's a great tip. Thanks!


SolydXK needs you!
Development | Testing | Translations

cwwgateway
Posts: 1215
Joined: 23 Feb 2013 19:14

Re: Repair grub

Postby cwwgateway » 16 Mar 2013 15:57

Thanks both of you for the how-tos. I've never had any problems with having too many partitions (I think the most I've had is 13). wayne, you must have a lot of installs with 24+ partitions... I have trouble managing just the installs I have now.
Dell XPS 15:
SolydX Debian Testing
SolydK Testing
SolydX Testing
Debian Sid Xfce
Debian Wheezy KDE
Arch Gnome Shell

Gateway:
SolydX Sid
Debian Sid OpenBox
Arch Linux OpenBox
CrunchBang Testing

User avatar
jsalpha2
Posts: 296
Joined: 28 May 2013 12:28

Re: Repair grub

Postby jsalpha2 » 19 Apr 2014 13:46

Wow, that's a lot of Linuxes. I need to add a few more.
1. SolydX
2. Mint Xfce
3. Jessie Alpha
4. Sabayon Xfce
5. Korora Xfce
6. Manjaro Xfce
7. Xubuntu 14.04

I also have Win 7

but I also have
MX-14 and Porteus on pendrives (Those two have persistence enabled. :D
You may notice that I am a big Xfce fanboy.

My only problem is that the more distros I install, the longer it takes for grub-customizer to save the new configuration.

kinesis
Posts: 9
Joined: 01 Feb 2016 19:17

Re: Repair grub

Postby kinesis » 13 Feb 2016 22:49

Hi,
I have installed solydk 2015.12 32 bit along side with windows XP in an old pc. Due to the faillure of the XP. I formated the partition in which it was installed (sda1). Now I can't boot solydk.
I noticed after many readings, that the codes used to recover grub are some how different, and I am not sure which one will work for me. Here are some links showing codes different from the one pubkushed above:
http://howtoubuntu.org/how-to-repair-re ... tu-live-cd
http://www.howtogeek.com/114884/how-to- ... wont-boot/
http://askubuntu.com/questions/88384/ho ... ng-windows

User avatar
jsalpha2
Posts: 296
Joined: 28 May 2013 12:28

Re: Repair grub

Postby jsalpha2 » 13 Feb 2016 23:22


User avatar
xendistar
Posts: 510
Joined: 08 Jun 2014 08:17
Location: Bournemouth, UK

Re: Repair grub

Postby xendistar » 14 Feb 2016 09:33

I used this

http://www.supergrubdisk.org/super-grub2-disk/

When I had a grub issue and the PC would not load the OS, I can't remember if it was a old style bios or the newer UEFI bios but I just followed the on screen instruction and was back up and running without an issue


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 1 guest