LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 11-20-2023, 10:17 PM   #1
thethinker
Member
 
Registered: Jul 2006
Location: Peabody, MA, USA
Distribution: Xubuntu, Slackware, Pop!_OS
Posts: 297
Blog Entries: 2

Rep: Reputation: 37
Question Slackware on VirtualBox, can't upgrade GRUB


I installed Slackware-15 on VirtualBox 7.0.12 and I'm having trouble customizing the GRUB installation:

Code:
# grub-install --version
grub-install (GRUB) 2.06
When I power up the VM, the grub menu shows two huge kernel options, and then a third menu option for all the kernels - and the kernel I want to default is in that menu. I've tried things like adding this to /etc/default/grub

Code:
GRUB_DISABLE_SUBMENU=y
Also, tried to default one of the submenu items with

Code:
GRUB_DEFAULT="2>1"
And then I run grub-mkconfig, and it seems to work - here's an example:

Code:
...
   save_env next_entry
   set boot_once=true
else
   set default="2>1"
fi
...
(that's part of grub.cfg, appears like the changes have happened.)

But no matter what I do, I get the same GRUB menu at the beginning. Anyone have any idea what's going on?
 
Old 11-21-2023, 04:16 AM   #2
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,534

Rep: Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495
If you have a specific entry in the grub menu you want as the default, the simplest way to get it is to see which entry it is in the menu. If the entry you want is the third entry, you would change for testing purposes, the set default="0" line in grub.cfg and change it to the number 2 as Grub counts from zero. Do not run grub-mkconfig. If it boots the entry you want, make the change permanent by editing the /etc/default/grub file, the line entering the number you want instead of 0 and then run grub-mkconfig.

Quote:
GRUB_DEFAULT=0
You could just make the change in /etc/default/grub and then run grub-mkconfig if you want.
 
Old 11-21-2023, 09:12 PM   #3
thethinker
Member
 
Registered: Jul 2006
Location: Peabody, MA, USA
Distribution: Xubuntu, Slackware, Pop!_OS
Posts: 297

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by yancek View Post
If you have a specific entry in the grub menu you want as the default, the simplest way to get it is to see which entry it is in the menu. If the entry you want is the third entry, you would change for testing purposes, the set default="0" line in grub.cfg and change it to the number 2 as Grub counts from zero. Do not run grub-mkconfig. If it boots the entry you want, make the change permanent by editing the /etc/default/grub file, the line entering the number you want instead of 0 and then run grub-mkconfig.



You could just make the change in /etc/default/grub and then run grub-mkconfig if you want.
Yeah I know this, but listen - there are three entries in the startup menu: "huge.s", "something else that's like huge.s", and "Other kernels". What I want is in "other kernels" (it happens to be the first entry). So first, I can't just set "0" or "2" in the grub config script, but I *think* I should be able to do "2>0" to tell Grub to hit the 2 menu entry ("other kernels") and then the first entry in that submenu (which is the generic kernel I want). That's what I tried to do, and grub.cfg changed (see the text above), but there was no change to the behavior at startup - I still just see three entries, two huge, one submenu.
 
Old 11-22-2023, 05:04 AM   #4
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,534

Rep: Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495
The link below has some relevant information. If you want the generic kernel to boot and the first entry is the huge kernel, why not simply change the linux line to point to the generic kernel in the first entry and add the initrd line?

https://unix.stackexchange.com/quest...-the-second-os

I generally modify the grub.cfg file when testing things as it saves time. Make a change to grub.cfg and reboot to test. I don't run grub-mkconfig so it isn't necessary to put the change in the permanent files. If it works, put the change in the appropriate grub file (/etc/default/grub or /etc/grub.d directory) and run grub-mkconfig. Your choice.
 
1 members found this post helpful.
Old 11-22-2023, 05:36 AM   #5
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,363

Rep: Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591
Quote:
which is the generic kernel I want)
Slackware doesn't auto-run grub-mkconfig with updates, edit the fisrt menu-entry in the grub.cfg linux line to /boot/vmlinuz-generic and be done with it. No need to run grub-mkconfig with kernel updates.
 
1 members found this post helpful.
Old 11-22-2023, 08:11 AM   #6
thethinker
Member
 
Registered: Jul 2006
Location: Peabody, MA, USA
Distribution: Xubuntu, Slackware, Pop!_OS
Posts: 297

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by yancek View Post
The link below has some relevant information. If you want the generic kernel to boot and the first entry is the huge kernel, why not simply change the linux line to point to the generic kernel in the first entry and add the initrd line?

https://unix.stackexchange.com/quest...-the-second-os

I generally modify the grub.cfg file when testing things as it saves time. Make a change to grub.cfg and reboot to test. I don't run grub-mkconfig so it isn't necessary to put the change in the permanent files. If it works, put the change in the appropriate grub file (/etc/default/grub or /etc/grub.d directory) and run grub-mkconfig. Your choice.
trying to follow the instructions there (I can't copy-paste from VM....is there a trick to that?):
Click image for larger version

Name:	SS-1.jpg
Views:	10
Size:	17.1 KB
ID:	42101
/boot/grub/grubenv does exist - didn't SS that, but I can see it there.

the grub.cfg file is complicated (kinda)...it's all about automatically finding kernels, so I don't really know how to write individual entries, a la lilo.
 
Old 11-22-2023, 08:22 AM   #7
thethinker
Member
 
Registered: Jul 2006
Location: Peabody, MA, USA
Distribution: Xubuntu, Slackware, Pop!_OS
Posts: 297

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by colorpurple21859 View Post
Slackware doesn't auto-run grub-mkconfig with updates, edit the fisrt menu-entry in the grub.cfg linux line to /boot/vmlinuz-generic and be done with it. No need to run grub-mkconfig with kernel updates.
I appreciate the help, but I don't understand how to do this. the grub.cfg file is split into sections:

Code:
### BEGIN /etc/grub.d/00_header ###
...functions and stuff to automatically find kernels...
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Slackware-15.0 GNU/Linux, with Linux 5.15.117' --class slackware_15_0 --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.117-advanced-ca823be4-0c31-4367-84e9-7fa9d9aac7ff' {
....other menu entries....
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
...and so on....
But I don't see any of those menu entries (see my SS above) - whatever is going on with the "automatically finding kernels" routine is happening before any of the menu entries are being hit, so if I start replacing them, nothing is going to happen. No changes I've made to either /etc/default/grub or /boot/grub/grub.cfg changes anything about the boot process.
 
Old 11-22-2023, 09:35 AM   #8
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,363

Rep: Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591
/boot/grub/grub.cfg file is the one to edit. If you run grub-mkconfig after editing /boot/grub/grub.cfg the edits will be lost.

Quote:
No changes I've made to either /etc/default/grub or /boot/grub/grub.cfg changes anything about the boot process.
If manually editing /boot/grub/grub.cfg and you didn't run grub-mkconfig aftwards does nothing something else is going on. Is there a grub.cfg somewhere on the efi partition that needs to be edited instead of /boot/grub/grub.cfg

Last edited by colorpurple21859; 11-22-2023 at 09:48 AM.
 
1 members found this post helpful.
Old 11-22-2023, 09:59 AM   #9
thethinker
Member
 
Registered: Jul 2006
Location: Peabody, MA, USA
Distribution: Xubuntu, Slackware, Pop!_OS
Posts: 297

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by colorpurple21859 View Post
/boot/grub/grub.cfg file is the one to edit
I understand - but none of the edits I make are actually propagating down to the menu on restart. Here's the beginning of my grub.cfg file (I got copy paste enabled!).
Code:
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="1"
fi
But it's not defaulting to the second item in the menu (indicated by "1") - it still just sits with the first entry selected and waits for input.

(I even just tried to comment out everything from if [ "$(next_entry)...else and then fi, so that it would just hit the set default command, and no change in behavior.

Can I try to ask something else - is it possible the VirtualBox installation is borked in some strange way? The reason I'm switching from the Slackware huge kernel to the generic one is that when I select the Huge one, it doesn't boot, it just goes and looks for the installation media (the original .iso file), as if the drive is not flagged for booting. If this was a real machine, I would expect some kind of kernel panic if Huge was invalid. Is it possible GRUB is being loaded from some other location, or doing some kind of default script, instead of the one I'm actually editing?
 
Old 11-22-2023, 10:04 AM   #10
thethinker
Member
 
Registered: Jul 2006
Location: Peabody, MA, USA
Distribution: Xubuntu, Slackware, Pop!_OS
Posts: 297

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by colorpurple21859 View Post
/boot/grub/grub.cfg file is the one to edit. If you run grub-mkconfig after editing /boot/grub/grub.cfg the edits will be lost.

If manually editing /boot/grub/grub.cfg and you didn't run grub-mkconfig aftwards does nothing something else is going on. Is there a grub.cfg somewhere on the efi partition that needs to be edited instead of /boot/grub/grub.cfg
Ok good thought - there is no efi partition in this VM, because I didn't make one.

Code:
# fdisk -l
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Disk model: VBOX HARDDISK   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Device        Start       End  Sectors Size Type
/dev/sda1      2048  88082431 88080384  42G Linux filesystem
/dev/sda2  88082432 104857566 16775135   8G Linux swap
Code:
# ls /boot
README.initrd@               elilo-ia32.efi*    onlyblue.dat
System.map@                  elilo-x86_64.efi*  slack.bmp
System.map-generic-5.15.117  grub/              tuxlogo.bmp
System.map-huge-5.15.117     initrd-tree/       tuxlogo.dat
boot.0800                    initrd.gz          vmlinuz@
boot_message.txt             inside.bmp         vmlinuz-generic@
config@                      inside.dat         vmlinuz-generic-5.15.117
config-generic-5.15.117.x64  map                vmlinuz-huge@
config-huge-5.15.117.x64     onlyblue.bmp       vmlinuz-huge-5.15.117
(on efi machines I think it's mounted in /boot.)

But I shouldn't *need* an efi partition right? GRUB should be able to handle booting being installed to....I dunno, whatever the equivalent of an MBR is for a virtual disk?

EDIT: Don't think this helps, but anyway:

Code:
# find / -type f -name grub.cfg -print
find: ‘/run/user/1000/doc’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied
/boot/grub/grub.cfg

Last edited by thethinker; 11-22-2023 at 10:07 AM.
 
Old 11-22-2023, 11:39 AM   #11
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,534

Rep: Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495
The message in the image in post 6 indicates you are trying to write to a read only filesystem. The "canonical path of cow" part.

As has been pointed out to you twice, given your lack of knowledge on the subject, you are best off modifying the /boot/grub/grub.cfg file as root and leaving the other files alone until you have something that has been tested and works. After modifying the file, do NOT run grub-mkconfig. See line 2 in grub.cfg

Linux installs on GPT drives in Legacy/CSM mode (which you have, MBR install) generally require a 1MB unformatted partition where the core.img file used by grub is placed. You don't have that and you don't have an EFI partition are you booting the installed system or from the iso in the virtual software?


Your Slackware menuentry in grub.cfg should have the 2 lines below at the end of the entry:

Quote:
linux /boot/vmlinuz-generic-5.15.117 root=/dev/nvme0n1p6
initrd /boot/initrd.gz
The huge kernel will be the same except that huge replaces generic in the linux line and the initrd line is not needed. This seems a lot simpler than what you are trying to do.
 
1 members found this post helpful.
Old 11-22-2023, 12:06 PM   #12
thethinker
Member
 
Registered: Jul 2006
Location: Peabody, MA, USA
Distribution: Xubuntu, Slackware, Pop!_OS
Posts: 297

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by yancek View Post
The message in the image in post 6 indicates you are trying to write to a read only filesystem. The "canonical path of cow" part.
Ok, got it, thanks.

Quote:
As has been pointed out to you twice, given your lack of knowledge on the subject, you are best off modifying the /boot/grub/grub.cfg file as root and leaving the other files alone until you have something that has been tested and works. After modifying the file, do NOT run grub-mkconfig. See line 2 in grub.cfg
Agree that I do not know what I am doing with Virtualization, but I do think I'm addressing this comment (which yes, had been made several times) as best I can - modifying grub.cfg does not impact the boot process -no menu items are any different when I change grub.cfg. And no, I am not running grub-mkconfig at any point in this process.

Quote:
Linux installs on GPT drives in Legacy/CSM mode (which you have, MBR install) generally require a 1MB unformatted partition where the core.img file used by grub is placed. You don't have that and you don't have an EFI partition are you booting the installed system or from the iso in the virtual software?
Very helpful, thanks - although I don't quite understand the question. I certainly am trying to boot into the installed system, and I think I am because I am making changes, installing software, etc. I thought creating a partition table (ie in fdisk during Slackware Install) would have created the MBR and made space for the GRUB files (like core.img). I guess you're saying that didn't happen - can you give me some advice on how to check that?
 
Old 11-22-2023, 12:15 PM   #13
thethinker
Member
 
Registered: Jul 2006
Location: Peabody, MA, USA
Distribution: Xubuntu, Slackware, Pop!_OS
Posts: 297

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by yancek View Post


Your Slackware menuentry in grub.cfg should have the 2 lines below at the end of the entry:



The huge kernel will be the same except that huge replaces generic in the linux line and the initrd line is not needed. This seems a lot simpler than what you are trying to do.
My concern with that is that /dev/nvmme0n1p6 is my physical disk, not the virtual one. And there are only 4 partitions on that disk, so p6 doesn't exist.

I tried it anyway, but as I've said before, changes to grub.cfg do not have any effect on the GRUB menu, so this change (right or wrong) made no difference.
 
Old 11-22-2023, 12:20 PM   #14
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,363

Rep: Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591
To install grub to mbr of a gpt drive that doesn't have a 1mb flagged bios-grub/bios-boot partition is similar to this:
Code:
grub-install --force --target=i386-pc /dev/sda
from within the booted installed system or chroot into the installed system after bind mount of the appropriate directories.
 
1 members found this post helpful.
Old 11-22-2023, 01:42 PM   #15
thethinker
Member
 
Registered: Jul 2006
Location: Peabody, MA, USA
Distribution: Xubuntu, Slackware, Pop!_OS
Posts: 297

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Quote:
Originally Posted by colorpurple21859 View Post
To install grub to mbr of a gpt drive that doesn't have a 1mb flagged bios-grub/bios-boot partition is similar to this:
Code:
grub-install --force --target=i386-pc /dev/sda
from within the booted installed system or chroot into the installed system after bind mount of the appropriate directories.
Trying it....
Code:
# grub-install --force --target=i386-pc /dev/sda
Installing for i386-pc platform.
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
Installation finished. No error reported.
And it still had no impact on restart. Can I redo this installation and create an MBR partition on the virtual drive? I can see that is an option in fdisk. Is that the "right" thing to do here?
 
  


Reply

Tags
grub, slackware, virtual box



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] virtualbox is installed along with virtualbox-dkms and virtualbox-ext-pack and linux-headers-generic, but error for no /dev/vboxdrv Astral Axiom Linux - Software 2 03-04-2019 08:09 PM
Infinite Grub Loop: GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB... beeblequix MEPIS 2 11-02-2013 10:56 PM
Move Slackware guest from a Slackware hosted Virtualbox to Windows hosted Virtualbox? damgar Slackware 1 08-07-2012 11:28 PM
Booting my new ubuntu install = "GRUB GRUB GRUB GRUB GRUB" etc. dissolved soul Ubuntu 2 01-13-2007 12:55 PM
GRUB GRUB GRUB GRUB "Whats Going on?" Gaweph Linux - Newbie 6 03-26-2004 10:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 11:24 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