Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
grub2 successfull but save?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Vrenn
Guru
Guru


Joined: 15 Dec 2004
Posts: 311

PostPosted: Sat Oct 26, 2013 1:41 pm    Post subject: grub2 successfull but save? Reply with quote

Today I followed the grub migration guide. But to be honest I don't get happy with grub2-mkconfig.
It doesn't find my kernel (renaming to kernel-version would break my kernel-upgrade-script, needing detection of old versions too), it needs help with windows, it just makes more work.

So I just tried to migrate syntax.
Here is the old grub.conf
Code:
default 0
timeout 10
#color red/green blue/white
splashimage=(hd0,4)/boot/grub/personal-splash.xpm.gz
foreground 00f0f2
background 000000

title=Gentoo GNU/Linux
root (hd0,4)
kernel (hd0,4)/boot/bzImage root=/dev/sda7

#Windows
title=Wintendo
root (hd0,1)
chainloader (hd0,1)+1

#grub2 test entry
title GRUB2 Chainload
root (hd0,4)
kernel /boot/grub/i386-pc/core.img
boot
and here the new grub.cfg
Code:
timeout=10

menuentry 'Gentoo GNU/Linux' {
        root=hd0,5
        linux /boot/bzImage root=/dev/sda7
}

menuentry 'Wintendo' {
        insmod part_msdos
        insmod chain
        insmod ntfs
        chainloader (hd0,2)+1
}
Are there any arguments against using a custom grub.cfg?
Arch-Linux gives out a warning manually editing grub.cfg.
_________________
With nice greetings
Vrenn
Back to top
View user's profile Send private message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 6639
Location: The soundosphere

PostPosted: Sat Oct 26, 2013 3:13 pm    Post subject: Re: grub2 successfull but save? Reply with quote

Vrenn wrote:
Today I followed the grub migration guide. But to be honest I don't get happy with grub2-mkconfig.
It doesn't find my kernel (renaming to kernel-version would break my kernel-upgrade-script


As far as I know, this isn't negotiable for grub2-mkconfig. You need your kernel file name to follow a certain format. But you could either find instructions for manually configuring grub2, or create symlinks to your kernels with the correct filename format (never tried symlinking a kernel before, though, so I don't know if this would work).
_________________
decibel Linux: https://decibellinux.org
Github: https://github.com/Gentoo-Music-and-Audio-Technology
Facebook: https://www.facebook.com/decibellinux
Discord: https://discord.gg/73XV24dNPN
Back to top
View user's profile Send private message
Vrenn
Guru
Guru


Joined: 15 Dec 2004
Posts: 311

PostPosted: Sat Oct 26, 2013 3:55 pm    Post subject: Reply with quote

Symlink or move. Anyway I would have to remove old kernel-versions manually from /boot and this would be quite annoying over time.
I would like to know which advantages grub2-mkconfig brings. I mean it's grub.cfg is huge and I don't understand it. The last one I hate most.
If it doesn't do more than just start linux, windows and perhaps memtest I'll go with my own file and add some bling.
_________________
With nice greetings
Vrenn
Back to top
View user's profile Send private message
Vrenn
Guru
Guru


Joined: 15 Dec 2004
Posts: 311

PostPosted: Sat Oct 26, 2013 6:26 pm    Post subject: Reply with quote

I gave the grub2-architekture another try using 40_custom in /etc/grub.d.

I found an old guide which helped me to understand the whole system.
but the starfield-theme is not the right one for my system.
Text to small for 1920x1080.
The menu-order is not my taste.
I need to script the theme new.
_________________
With nice greetings
Vrenn
Back to top
View user's profile Send private message
ulenrich
Veteran
Veteran


Joined: 10 Oct 2010
Posts: 1480

PostPosted: Sun Oct 27, 2013 12:10 am    Post subject: Reply with quote

I just delete the /etc/grub.d/20_osprober to get no kernel automatically. Then I create
/etc/grub.d/40_custom
Code:
menuentry "gentoo.new" {
load_video
insmod gzio
insmod part_gpt
insmod ext2
set root='(hd0,gpt7)'
linux /boot/kernel.new root=/dev/sda7
initrd /boot/initrd.new
}
Booting with grub it is possible to use symlinked new kernels by your kernel make script. Thus never need to update ...
Ps: remember genkernels initrd wants real_root!


Last edited by ulenrich on Sun Oct 27, 2013 4:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Sun Oct 27, 2013 8:29 am    Post subject: Re: grub2 successfull but save? Reply with quote

Vrenn wrote:
Are there any arguments against using a custom grub.cfg?

No. I recommend this always.
Quote:
Arch-Linux gives out a warning manually editing grub.cfg.

If you blindly run grub2-mkconfig after you edited the file, you might loose it, of course. But in Gentoo nothing runs grub2-mkconfig automatically. This might be different in Arch-Linux. It won't hurt to keep a backup anyway...
Back to top
View user's profile Send private message
Vrenn
Guru
Guru


Joined: 15 Dec 2004
Posts: 311

PostPosted: Sun Oct 27, 2013 3:33 pm    Post subject: Reply with quote

Backup is important.
I still have not decided what to so, at now I have a working mkconfig and a manual .cfg.
Lets see how I can customize grub more, with the scripts or directly.
Lets see what systemd wants.
_________________
With nice greetings
Vrenn
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Sun Oct 27, 2013 4:22 pm    Post subject: Reply with quote

The only relation of systemd with grub or grub2 is that you might want to select the init-system conveniently. This is much simpler if you edit /boot/grub/grub.cfg directly.
For those interested, here is a grub file to be sourced from grub.cfg which lets you select init-system and resolution; it is followed by an example grub.cfg which uses it.
Since variables are used, this can hardly be done with an autogenerated grub.cfg.
/boot/grub/grub-common.conf wrote:
if [ -s "${prefix}/grubenv" ]; then
load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi

function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}

set timeout=5

insmod part_msdos

function graphmode {
insmod vga
insmod vbe
loadfont unicode
# insmod all_video
# insmod efi_gop
# insmod efi_uga
# insmod ieee1275_fb
# insmod video_bochs
# insmod video_cirrus
insmod gfxterm
terminal_output gfxterm
}

function set_defaults {
set color_normal='light-green/black'
set color_highlight='yellow/brown'
set gfxmode='1024x768x32'
}

function set_systemd {
set init='/usr/lib/systemd/systemd'
}

function set_openrc {
set init='/sbin/init'
}

function set_bash {
set init='/bin/bash'
}

function set_zsh {
set init='/bin/zsh'
}

functions set_800 {
set gfxpayload='800x600x32'
set vga='0x314'
set video='VGA:800x600@75'
}

function set_1024 {
set gfxpayload='1024x768x32'
set vga='0x317'
set video='VGA:1024x768@75'
}

function set_1152 {
set gfxpayload='1024x768x32'
set vga='0x317'
set video='VGA:1152x864@75'
}

function set_1280 {
set gfxpayload='1280x1024x32'
set vga='0x31A'
set video='VGA:1280x1024@75'
}

function set_1400 {
set gfxpayload='1280x1024x32'
set vga='0x31A'
set video='VGA:1400x1050@75'
}

function set_1600 {
set gfxpayload='1600x1200x16'
set vga='0x346'
set video='VGA:1600x1200@75'
}

function echo_resolution {
echo "gfxpayload: ${gfxpayload}"
echo "vga : ${vga}"
echo "video : ${video}"
}

function echo_current {
echo_init
echo_resolution
}

function echo_init {
echo "init : ${init}"
}

function echo_boot {
echo_current
echo "root : ${root}"
}

function pause {
echo -n 'Press Esc to return. '
sleep -i -v 60
}

function show_init {
echo_init
pause
}

function show_resolution {
echo_resolution
pause
}

function show_current {
echo_current
pause
}

function show_boot {
echo_boot
pause
}

function show_vbe {
set pagersave="${pager}"
set pager=1
vbeinfo
pause
set pager="${pagersave}"
}

function select_systemd {
echo 'selecting systemd:'
set_systemd
pause
}

function select_openrc {
echo 'selecting openrc:'
set_openrc
pause
}

function select_bash {
echo 'selecting bash:'
set_bash
pause
}

function select_zsh {
echo 'selecting zsh:'
set_zsh
pause
}

function enter_init {
echo 'Examples for init:'
echo
echo '/sbin/init'
echo '/usr/lib/systemd/systemd'
echo '/bin/bash'
echo '/bin/zsh'
echo
echo -n "init (default init): "
read readvar
if [ -n "${readvar}" ]; then
set init="${readvar}"
fi
echo
echo
echo_init
pause
}

function select_800 {
set_800
show_resolution
}

function select_1024 {
set_1024
show_resolution
}

function select_1152 {
set_1152
show_resolution
}

function select_1280 {
set_1280
show_resolution
}

function select_1400 {
set_1400
show_resolution
}

function select_1600 {
set_1600
show_resolution
}

function enter_resolution {
echo 'Examples for gfxpayload:'
echo
echo '1280x1024x32'
echo '1024x768'
echo 'keep'
echo
echo 'Examples for vga (VESA modes):'
echo
echo ' | 640x480 800x600 1024x768 1280x1024 1600x1200'
echo '----+---------------------------------------------------'
echo ' 8 | 0x301/769 0x303/771 0x305/773 0x307/775'
echo ' 16 | 0x310/784 0x313/787 0x316/790 0x319/793 0x346'
echo '*32*| 0x311/785 0x314/788 0x317/791 0x31A/794'
echo ' 64 | 0x312/786 0x315/789 0x318/792 0x31B/795'
echo
echo -n "gfxpayload (default ${gfxpayload}): "
read readvar
if [ -n "${readvar}" ]; then
set gfxpayload="${readvar}"
fi
echo
echo -n "vga (default ${vga}): "
read readvar
if [ -n "${readvar}" ]; then
set vga="${readvar}"
fi
echo
echo -n "video (default ${video}): "
read readvar
if [ -n "${readvar}" ]; then
set video="${readvar}"
fi
echo
echo
show_resolution
}

function set_vars {
set_defaults
set_systemd
set_1400
# The following restricts all except --unrestricted to require password above:
set superusers='root'
}

function menu_vars {
menuentry '0 - Resolution 1024 768 (beamer)' --hotkey 0 --unrestricted {
select_1024
}

menuentry '8 - Resolution 800 600' --hotkey 8 --unrestricted {
select_800
}

menuentry '2 - Resolution 1280 1024' --hotkey 2 --unrestricted {
select_1280
}

menuentry '1 - Resolution 1152 864 (small non-LED)' --hotkey 1 --unrestricted {
select_1152
}

menuentry '4 - Resolution 1400 1050 (wide screen)' --hotkey 4 --unrestricted {
select_1400
}

menuentry '6 - Resolution 1600 1200' --hotkey 6 --unrestricted {
select_1600
}

menuentry 'S - Select systemd' --hotkey s --unrestricted {
select_systemd
}

menuentry 'O - Select openrc' --hotkey o --unrestricted {
select_openrc
}

menuentry 'B - Select bash' --hotkey b --users '' {
select_bash
}

menuentry 'Z - Select zsh' --hotkey z --users '' {
select_zsh
}

menuentry 'R - Enter resolution' --hotkey r --unrestricted {
enter_resolution
}

menuentry 'I - Enter init' --hotkey i --users '' {
enter_init
}

menuentry 'P - Print current settings' --hotkey p --unrestricted --class gentoo --class gnu-linux --class gnu --class os {
show_current
}
# End menu_vars
}

function menu_devices {
submenu 'D - >Chainload Devices<' --hotkey d --users '' --class os {
set_vars

menuentry '0 - Harddisk 0' --hotkey 0 --unrestricted --class os {
echo 'Harddisk 0'
set root='hd0'
chainloader +1
}

menuentry '1 - Harddisk 1' --hotkey 1 --unrestricted --class os {
echo 'Harddisk 1'
set root='hd1'
chainloader +1
}

menuentry 'F - Floppy' --hotkey f --unrestricted --class os {
echo 'Floppy'
set root='fd0'
chainloader +1
}

menuentry 'D - CD/DVD 0' --hotkey d --unrestricted --class os {
echo 'CD/DVD 0'
set root='cd0'
chainloader +1
}

menuentry 'W - CD/DVD 1' --hotkey w --unrestricted --class os {
echo 'CD/DVD 1'
set root='cd1'
chainloader +1
}
# End submenu 'Chainload Devices'
}
# End menu_devices
}

function menu_info {
menuentry 'I - VBE info' --hotkey i --unrestricted {
show_vbe
}

menuentry 'G - Install grub2 info' --hotkey g --unrestricted {
echo 'grub2-install /dev/sda'
pause
}
# End menu_info
}

Usage is, for instance, as follows:
/boot/grub/grub.cfg wrote:
source "${prefix}/grub-common.cfg"

function set_vars {
set_defaults
set_systemd
set_1400
# set superusers='root'
}

set_vars
# graphmode

menuentry 'G - Gentoo 64 bitt' --hotkey g --unrestricted --class gentoo --class gnu-linux --class gnu --class os {
echo '64bit'
insmod gzio
insmod ext2
set root='hd0,msdos1' # modify appropriately
search --no-floppy --fs-uuid --set=root --hint-bios=${root} [insert your 64-bit partition UUID here]
echo_boot
linux /boot/bzImage root=/dev/modify_me init=$init vga=$vga video=$video
}

menuentry '3 - 32bit' --hotkey 3 --unrestricted --class gentoo --class gnu-linux --class gnu --class os {
echo '32bit'
insmod gzio
insmod ext2
set root='hd0,msdos1' # modify appropriately
search --no-floppy --fs-uuid --set=root --hint-bios=${root} [insert you 32-bit partition UUID here]
echo_boot
linux16 /boot/bzImage root=/dev/modify_me init=$init vga=$vga video=$video
}

submenu 'A - >First Aid<' --hotkey a --unrestricted --class gentoo --class gnu-linux --class gnu --class os {
set_vars

menuentry 'P - 64bit Previous' --hotkey p --unrestricted --class gentoo --class gnu-linux --class gnu --class os {
echo '64bit Previous'
insmod gzio
insmod ext2
set root='hd0,msdos1' # modify appropriately
search --no-floppy --fs-uuid --set=root --hint-bios=${root} [insert your 64-bit partition UUID here]
echo_boot
linux /boot/bzImage.previous root=/dev/modify_me init=$init vga=$vga
}

menuentry '3 - 32bit Previous' --hotkey 3 --unrestricted --class gentoo --class gnu-linux --class gnu --class os {
echo '32bit Previous'
insmod gzio
insmod ext2
set root='hd0,msdos1' # modify appropriately
search --no-floppy --fs-uuid --set=root --hint-bios=${root} [insert your 32-bit partition UUID here]
echo_boot
linux16 /boot/bzImage.previous root=/dev/modify_me init=$init vga=$vga video=$video
}

menu_vars
# End submenu 'First Aid'
}

submenu 'T - >Toolbox<' --hotkey t --unrestricted {
set_vars

menuentry 'M - 64bit Memtest86+' --hotkey m --unrestricted --class gentoo --class os {
echo '64bit Memtest86+'
insmod ext2
set root='hd0,msdos1' # modify appropriately
search --no-floppy --fs-uuid --set=root --hint-bios=${root} [insert your 32-bit partition UUID here]
echo $root
linux16 /boot/memtest86plus/memtest
}

menuentry '3 - 32bit Memtest86+' --hotkey 3 --unrestricted --class gentoo --class os {
echo '32bit Memtest86+'
insmod ext2
set root='hd0,msdos1' # modify appropriately
search --no-floppy --fs-uuid --set=root --hint-bios=${root} [insert your 64-bit partition UUID here]
echo $root
linux16 /boot/memtest86plus/memtest
}

menu_info
# End submenu 'Toolbox'
}

menu_vars
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum