how to reboot in another os just once?

Hi
I’m trying to figure out how to reboot just once in a different OS (Windows 10) and after rebooting from W10 it automatically comes back to opensuse at the boot screen order as default.

I’ve tried some methods like these (no matter if the GRUB2_DEFAULT=0 or saved - 0 is the TW:

Method 1:

sudo grub2-set-default 2

which is the W10 place at the boot order and then

sudo reboot

but it fixed the boot order to always boot on W10 although I have an option to manually change it in the boot loader screen.

Method 2:
same as 1 but editing /etc/default/grub and setting

GRUB_SAVEDEFAULT="false"

follwed by

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

but the result was the same as 1

Method 3:
same as 2 but instead of

sudo grub2-set-default 2

I used

sudo grub2-reboot 2

But it did a mess in the boot! It even give me the boot options to choose from, booting directly on W10. The only solution to come back to opensuse is a recovery.

I’ll try now the method 2 again with

sudo grub2-once 2

instead of

sudo grub2-set-default 2

.

Is there a way to do what I’m trying to do?

Thank you,

Hi and welcome to the Forum :slight_smile:
So is this a UEFI boot system? If so can just use the efibootmgr command…


efibootmgr

BootCurrent: 0004
Timeout: 0 seconds
BootOrder: 0002,0001,0004,0000,2001,2002,2004
Boot0000* openSUSE
Boot0001* sled-secureboot
Boot0002* Windows Boot Manager
Boot0004* opensuse-secureboot <== Current boot

efibootmgr -n 2

BootNext: 0002 <== Next boot
BootCurrent: 0004
Timeout: 0 seconds
BootOrder: 0002,0001,0004,0000,2001,2002,2004
Boot0000* openSUSE
Boot0001* sled-secureboot
Boot0002* Windows Boot Manager
Boot0004* opensuse-secureboot

Hi, thank you for replying!

I think it is not an UEFI boot system as below response:

ap@hpsuse:~> sudo efibootmgr

EFI variables are not supported on this system.

ap@hpsuse:~> 

I tried everything I’ve searched with no success yet.

Hi
Ahh ok, well grub2-once should work…

So what does the list show?


grub2-once --list

The output is it:

     0 openSUSE Tumbleweed
     1 Advanced options for openSUSE Tumbleweed>openSUSE Tumbleweed, with Linux 5.1.7-1-default
     2 Advanced options for openSUSE Tumbleweed>openSUSE Tumbleweed, with Linux 5.1.7-1-default (recovery mode)
     3 Advanced options for openSUSE Tumbleweed>openSUSE Tumbleweed, with Linux 5.1.5-1-default
     4 Advanced options for openSUSE Tumbleweed>openSUSE Tumbleweed, with Linux 5.1.5-1-default (recovery mode)
     5 Windows 10 (on /dev/sda1)
     6 Ubuntu 18.04.2 LTS (18.04) (on /dev/sda3)
     7 Advanced options for Ubuntu 18.04.2 LTS (18.04) (on /dev/sda3)>Ubuntu (on /dev/sda3)
     8 Advanced options for Ubuntu 18.04.2 LTS (18.04) (on /dev/sda3)>Ubuntu, with Linux 4.18.0-20-generic (on /dev/sda3)
     9 Advanced options for Ubuntu 18.04.2 LTS (18.04) (on /dev/sda3)>Ubuntu, with Linux 4.18.0-20-generic (recovery mode) (on /dev/sda3)
    10 Advanced options for Ubuntu 18.04.2 LTS (18.04) (on /dev/sda3)>Ubuntu, with Linux 4.18.0-15-generic (on /dev/sda3)
    11 Advanced options for Ubuntu 18.04.2 LTS (18.04) (on /dev/sda3)>Ubuntu, with Linux 4.18.0-15-generic (recovery mode) (on /dev/sda3)
    12 Advanced options for Ubuntu 18.04.2 LTS (18.04) (on /dev/sda3)>Memory test (memtest86+, serial console 115200) (on /dev/sda3)
    13 Start bootloader from a read-only snapshot> openSUSE Tumbleweed  (5.1.7-1,2019-06-19T13:45,post,yast services-manager)

and many other snapshots.

I reverted the grup2.cfg as per original state.

If I run:

sudo grub2-once 5
sudo reboot

pc reboots in windows as expected but without passing through the boot loader screen anymore and after I reboot from W10 it is always keeping booting into W10 with no boot loader screen options to choose.

As far as I know, “grub2-once” works by storing information in “/boot/grub2/grubenv”. And grub2 is supposed to remove that information on the next boot. But grub2 is unable to write to “grubenv” if it is on a “btrfs” file system.

Or, at least, that used to be the problem. I don’t know whether it is still a problem.

Then if I want it working I’d need to reinstall opensuse with another file system type (which one?) or is there a way to change it on the go?

Hi
If it’s BIOS booting, did you create a small /boot partition?


lsblk

I think so. Almost sure it is on sda1. Suse is on sda4

NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0 298,1G  0 disk 
├─sda1            8:1    0   500M  0 part 
├─sda2            8:2    0 242,1G  0 part 
├─sda3            8:3    0  27,7G  0 part 
└─sda4            8:4    0  27,9G  0 part 
  ├─system-swap 254:0    0     2G  0 lvm  [SWAP]
  └─system-root 254:1    0  25,9G  0 lvm  /home
sr0              11:0    1  1024M  0 rom  

I’ve just used the opensuse standard when I installed

edit: looking into sda1 with Dolphin it seems to be empty

Hi
Does look like it, what about the output from;


mount | grep boot
ls /boot/grub2/
fdisk -l /dev/sda

Edit: Maybe sda is for windows…

The outputs are:


mount | grep boot
/dev/mapper/system-root on /boot/grub2/i386-pc type btrfs (rw,relatime,space_cache,subvolid=266,subvol=/@/boot/grub2/i386-pc)
/dev/mapper/system-root on /boot/grub2/x86_64-efi type btrfs (rw,relatime,space_cache,subvolid=265,subvol=/@/boot/grub2/x86_64-efi)


ls /boot/grub2/
device.map  fonts  grub.cfg  grubenv  i386-pc  locale  themes  x86_64-efi


fdisk -l /dev/sda
Disco /dev/sda: 298,1 GiB, 320072933376 bytes, 625142448 setores
Modelo de disco: WDC WD3200BEKT-6
Unidades: setor de 1 * 512 = 512 bytes
Tamanho de setor (lógico/físico): 512 bytes / 512 bytes
Tamanho E/S (mínimo/ótimo): 512 bytes / 512 bytes
Tipo de rótulo do disco: dos
Identificador do disco: 0xc9415531

Dispositivo Inicializar    Início       Fim   Setores Tamanho Id Tipo
/dev/sda1   *                2048   1026047   1024000    500M  7 HPFS/NTFS/exFAT
/dev/sda2                 1026048 508813311 507787264  242,1G  7 HPFS/NTFS/exFAT
/dev/sda3               508813312 566771711  57958400   27,7G 83 Linux
/dev/sda4               566771712 625142447  58370736   27,9G 8e Linux LVM

I guess the sda1 is the initializer/bootable one and I suspect sda is the whole disk as it seems windows is on sda2.

Hi
Yes it has the boot flag set (The *)…

What would you like to do going forward?

Maybe user nrickert has further advice…

No, I really don’t. There are limitations to dual-boot/multi-boot. I manage to live with them.

Well if you use ext4 file system rather then BTRFS (downside no snapshots) grub will be able to write. Or you could create a small ~500 meg partition and set /boot to as the mount and formatted ext4. let the main root partition be BTRFS. But the downside of this is that grub would not be able to boot to a snapshot since the BTRFS is on a different partition. So it looks like you won’t be able to do this unless you toss BTRFS and live without snapshots. I figure the problem is that grub runs before the kernel and thus does not have access to the BTRFS code and porting said code into the grub may not be possible or break other stuff. All sorts of cache 22’s :stuck_out_tongue:

I think I can live without snaps, it’ll even save me some Mib. Could you point me out to a step by step process of changing the grub2 stuff and /boot to the formatted ext4 sda1 partition, considering the need to boot in win10 and ubuntu? I’m just a beginner with very few knowledge in linux. I dont have much to lose btw but I dont wanna lose w10 :shame:

One thing that I cant understand is why bootloader change its behavior when I reboot using grub2-once 5 or grub2-reboot 5 (booting straight into w10 without asking what os to boot) but it works well when using grub2-set-default 5 asking what to boot!

It will require reinstall and going to expert mode and setting the file system ext4 and format for each partition. Be sure that the installer is pointing to the old partitions since doing a new install it will think it needs to create new partition. Note you can keep any old home partition which is probably formatted as XFS if you want just mount it as /home and Not to format

If you have any detail question ask

That’s the purpose of grub2-once as long as it is active it will go to the designated OS. It should be deactivated after that boot but grub does not know BTRFS and can’t properly deactivate it

Thank you,

Do I need to reinstall all tumbleweed or is there a way to reinstall only the /boot part itself?
If need to reinstall do I lose all settings already done in the actual installation e.g. themes, kontact, kde, etc?
If the settings are stored in home partition (I dont know), how can I mount it? before or during the reinstall?
will i lose all the packages, gpg keys etc?

No you can’t just do boot (at least not easily). All personal setting are in your home you do lose system settings back to the defaults but most of those are in /etc so backing that directory should save them.So just don’t format your home (assuming home is on a separate partition and not on root) and mount it as /home.

I see you have a LVM defined but also a regular Linux so not certain of exactly how things are setup. You do have to take care and explain when you use exotic configurations.

hmmm my home is not a separate partition, it is inside the root/home. Can I still mount it outside the root?

the other Linux is an Ubuntu partition i’m testing.

Can I move /home and /etc to Ubuntu partition, make the entire reinstall process and move them back to suse? is it just a simple copy of folders process? what about the dependencies of the packages?