LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Grub2 does not detect (btrfs) partition after reinstall (https://www.linuxquestions.org/questions/linux-general-1/grub2-does-not-detect-btrfs-partition-after-reinstall-4175616085/)

Grabby 10-21-2017 05:53 AM

Grub2 does not detect (btrfs) partition after reinstall
 
I just installed Xubuntu alongside a (btrfs) Manjaro installation which used to be booted by Grub2.

Now for some reason Grub2 does not detect the Manjaro partition, so I can't boot from it.

Any solutions? (including using a different boot loader)

syg00 10-21-2017 06:18 AM

You know grub can handle btrfs - check the grub.cfg on Manjaro for what you need to add to the cfg on Xubuntu.

Grabby 10-21-2017 05:00 PM

Quote:

Originally Posted by syg00 (Post 5772285)
You know grub can handle btrfs - check the grub.cfg on Manjaro for what you need to add to the cfg on Xubuntu.

I have found the grub.cfg file on the Manjaro partition, but extracting from it the relevant information and manually inserting it into the current grub.cfg is something I am unable to do, as my technical skills are limited. I have tried anyway, with the help of the Grub-Customizer, but it did not work (the entry is created, but it does not boot).
BTW, I also tried overwriting the current grub.cfg with the one taken from the Manjaro partition (replacing it as a whole), but strangely enough when I run update-grub2 what actually gets written on disk is not from the Manjaro grub.cfg (which I had copied into Xubuntu's /boot/grub directory) but from Xubuntu's own grub.cfg file -- despite the fact that it was just overwritten by the Manjaro one. That's odd! Moreover, the old Xubuntu grub.cfg gets restored (in place of the Manjaro one), seemingly out of nowhere...

Now I am in a hurry to restore the boot from the Manjaro partition and I don't mind giving up the newly installed Xubuntu partition altogether.

So, is there a way to get update-grub2 to read from the particular grub.cfg file which I want (i.e. the one I copied from the Manjaro partition) and ignore the currently installed grub config (which causes the interference)?

Could you please provide some easy-to-follow instructions on how to do it?

colorpurple21859 10-21-2017 05:58 PM

Whenever you run update-grub it will overwrite any changes you made to /boot/grub.cfg. In manjaro /boot/grub/grub.cfg copy the section that is similar to this
Code:

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Manjaro Linux' --class manjaro --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-996cfe51-bdf3-47c0-91cb-2be3f0fb4606' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos5'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos5 --hint-efi=hd0,msdos5 --hint-baremetal=ahci0,msdos5 996cfe51-bdf3-47c0-91cb-2be3f0fb4606
else
search --no-floppy --fs-uuid --set=root 996cfe51-bdf3-47c0-91cb-2be3f0fb4606
fi
echo 'Loading Linux 4.4.5-1-MANJARO x64 ...'
linux /boot/vmlinuz-4.4-x86_64 root=UUID=996cfe51-bdf3-47c0-91cb-2be3f0fb4606 rw
echo 'Loading initial ramdisk ...'
initrd /boot/intel-ucode.img /boot/initramfs-4.4-x86_64.img
}

To /etc/grub.d/40_custom then run uppdate grub.

Grabby 10-22-2017 03:03 AM

It worked! Problem solved. THANK YOU.

colorpurple21859 10-22-2017 07:55 AM

One thing to note is when the kernel version changes for manjaro during a manjaro update you will need to edit the /etc/grub.d/40 and change the numbers and rerun update-grub. to keep from doing this and IMHO easier way is to make an entry in the 40_custom similar to this:
Code:

menuentry 'Manjaro Linux'{
insmod part_msdos
insmod ext2
set root='hd0,msdos5'
configfile /boot/grub/grub.cfg
}

just change the set root numbers to reflect the partition your manjaro is on.

Grabby 10-24-2017 06:08 PM

Quote:

Originally Posted by colorpurple21859 (Post 5772609)
One thing to note is when the kernel version changes for manjaro during a manjaro update you will need to edit the /etc/grub.d/40 and change the numbers and rerun update-grub. to keep from doing this and IMHO easier way is to make an entry in the 40_custom similar to this:
Code:

menuentry 'Manjaro Linux'{
insmod part_msdos
insmod ext2
set root='hd0,msdos5'
configfile /boot/grub/grub.cfg
}

just change the set root numbers to reflect the partition your manjaro is on.

I have just tried to do as you suggested, but I get an error message when running update-grub:
/etc/grub.d/40_custom: line 1: #!: command not found

The content of my /etc/grub.d/40_custom file is:

#! /bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.

menuentry 'Manjaro Linux'{
insmod gzio
insmod part_gpt
insmod btrfs
set root='hd0,gpt6'
configfile /boot/grub/grub.cfg
}

Am I missing something?
Could you please tell me what to do?

colorpurple21859 10-24-2017 06:33 PM

what is on line one of 40_custom?

Grabby 10-24-2017 06:58 PM

Quote:

Originally Posted by colorpurple21859 (Post 5773508)
what is on line one of 40_custom?

It's simply

#!/bin/sh

which was present by default in the file.

colorpurple21859 10-24-2017 07:38 PM

Quote:

#! /bin/sh
if this isn't a mistype then should be #!/bin/sh without no spaces

Grabby 10-24-2017 07:48 PM

Quote:

Originally Posted by colorpurple21859 (Post 5773522)
if this isn't a mistype then should be #!/bin/sh without no spaces

It was originally without the space after #!, and it produced the error message

/etc/grub.d/40_custom: line 1: #!/bin/sh: No such file or directory

(I added the space while trying to solve the problem)

So I tried both with and without the space, and I get an error message in each case.

colorpurple21859 10-24-2017 08:34 PM

There is something wrong with the first line. Did you use the same editor that you initially used to edit 40_custom?

Grabby 10-24-2017 08:55 PM

Quote:

Originally Posted by colorpurple21859 (Post 5773534)
There is something wrong with the first line. Did you use the same editor that you initially used to edit 40_custom?

You just beat me to the punch. I was going to post the solution of the riddle. It was indeed a case of wrong encoding by the text editor. I saved the same text with a different text editor, and this time update-grub produced no error messages.
I still have to reboot, but I am confident that the problem is solved.
Thanks a lot indeed!

colorpurple21859 10-24-2017 09:13 PM

Your welcome

Grabby 10-27-2017 07:14 PM

By the way, I can now confirm that the problem was about the wrong encoding of the text file. After rebooting, the grub menu shows the entry which I wanted. Problem solved.


All times are GMT -5. The time now is 06:46 PM.