LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Yet another grub hiccough. (https://www.linuxquestions.org/questions/slackware-14/yet-another-grub-hiccough-4175706220/)

business_kid 01-11-2022 02:02 PM

Yet another grub hiccough.
 
"It would be good to have a bootable backup disk," I thought. So as I was organizing one, I backed up my current install to be bootable. It's mainly the /home I need anyhow I added partuuids to the fstab, and mkade this grub config for the backup disk (to be booted via usb atm)
Code:

# Begin /boot/grub/grub.cfg
set default=0
set timeout=5
set root=(hd1,1)
insmod msdos

menuentry "Slackware64-5.10.15 - Generic Kernel" {
        linux  /vmlinuz-generic-5.10.15 root=/dev/sdb2 ro
        initrd /initrd-5.10.15.gz

Attempting to install it got me this error
Code:

root@RoseViolet:/boot/grub# grub-install /dev/sdb
Installing for i386-pc platform.
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install: error: embedding is not possible, but this is required for cross-disk install.

That was normally a question of toggling a bootable flag, but that option is missing or moved in fdisk & gdisk. There's been a serious revamp there and all sorts of weird and wonderful partition types have been invented. Why?

Now this is all my fault, of course. But what should have known that I didn't?

colorpurple21859 01-11-2022 02:18 PM

You are attempting to install grub to a gpt drive in legacy mode.
try
Code:

grub-install --force /dev/sdb
If this doesn't work use lilo, or create a 2mb empty partition flagged BIOS Boot on the gpt drive to install grub in legacy mode or install grub in uefi mode.

Didier Spaier 01-11-2022 02:39 PM

https://wiki.archlinux.org/title/GRU...c_instructions

business_kid 01-12-2022 11:56 AM

Thanks Didier Spaier, & colorpurple21859.

To cut to the chase, grub thinks it's installed, but it doesn't see the disk as bootable when I press F10 on bootup.

There's no gpt here, I got this box in early 2013,which was a very patchy time for UEFI support. I eventually hacked into an extremely hostile BIOS enough to get Legacy mode going, and never looked back. Just thinking, even formatting with gdisk is enough to reawaken UEFI. I did format the new disk with gdisk. But I haven't woken the enemy Bios thus far …
Code:

bash-5.1$ sudo gdisk -l /dev/sdb
Password:
GPT fdisk (gdisk) version 1.0.6

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sdb: 1953525168 sectors, 931.5 GiB
Model: USB 3.0       
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): 210C4ABB-7483-4DC0-B678-9EF1F58DCA21
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1953525134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size      Code  Name
  1            2048            6143  2.0 MiB    EF02  BIOS boot partition
  2            6144          518143  250.0 MiB  8300  Linux filesystem
  3          518144        84404223  40.0 GiB    8300  Linux filesystem
  4        84404224      189261823  50.0 GiB    8300  Linux filesystem
  5      189261824      1953525134  841.3 GiB  8300  Linux filesystem

That gdisk does go into long-winded detail, as does the Arch Wiki!

I find it's always the last thing you think of trying with grub that works. In my case, it was making the Bios Boot partition. Grub installed error free, but the System Can't See It when I hit F10 and looks for an alternative boot source. SCSI indeed. Do I need to put a file system on that Bios Boot partition, and if so, which one?

colorpurple21859 01-12-2022 12:25 PM

Quote:

Do I need to put a file system on that Bios Boot partition, and if so, which one?
NO, the bios-boot partition is the replacement for the 1mb space between the mbr and first partition that exists on a legacy drive, that doesn't exist on a gpt drive.

Quote:

To cut to the chase, grub thinks it's installed, but it doesn't see the disk as bootable when I press F10 on bootup.
Something to do with your bios/firmware, maybe this will help:
Code:

parted /dev/sdb disk_set pmbr_boot on
If doesn't help or make things worst set to off.

business_kid 01-13-2022 08:02 AM

Ok the parted command did nothing, not making things worse or better.

A little thought unciurled itself in my head here. I have a duplicate (backup) system here on /dev/sdb. So I can run the grub command installed on /dev/sda; Or I can do a chroot and run the grub command installed on /dev/sdb; Or, I can also install from a live usb key which leads to endless combinations. But what is the kosher grub to run?

Does using the grub on sda mean that sda has to be referenced in the bootup process? The usual time you want an alternative is when you box won't boot. What I have been doing is the same as the live usb. I press F10 during bootup, to select an alternative boot device, and I don't see sdb there. I do see my rather blind sr0, but not my usb drive.

enorbet 01-13-2022 08:16 AM

You might enjoy rEFInd. It is human readable text with a LOT of syntax and usage comments in the config file and it doesn't care whether a disk is partitioned Legacy MBR or GPT or some are UEFI booted. The existing slackbuild at slackbuilds.org works whether you're on 14.2 or 15.0-RC2. It will find and try to boot any existing kernel it sees (unless you choose hide one or many) any elilo config, maybe more if you want to check. The documentation is very good.

business_kid 01-13-2022 09:19 AM

Quote:

Originally Posted by enorbet (Post 6317804)
You might enjoy rEFInd. It is human readable text with a LOT of syntax and usage comments in the config file and it doesn't care whether a disk is partitioned Legacy MBR or GPT or some are UEFI booted. The existing slackbuild at slackbuilds.org works whether you're on 14.2 or 15.0-RC2. It will find and try to boot any existing kernel it sees (unless you choose hide one or many) any elilo config, maybe more if you want to check. The documentation is very good.

Thanks for the reply. What does rEFInd do? My fallback is that if I want to bother with a 550G copy (again), I can make a live usb out of the usb backup disk. But this struck me as a handy way of doing stuff without having to reset default settings for the Excited States every time I boot up, which I do find to be a pain in the derrière with the liveslak installs. BTW, liveslak is otherwise excellent.

wpeckham 01-13-2022 09:51 AM

http://www.rodsbooks.com/refind/
It is an EFI boot manager. If you are not on an EFI/UEFI machine you do not need it.
Nice project though.

business_kid 01-13-2022 10:13 AM

Well, I narrowed the options slightly.

I mounted sdb with all partitions correctly positioned, copied over the /dev/disk stuff, and did a chroot onto /dev/sdb. I mounted proc, checked /boot/grub/grub.cfg, and ran
Code:

grub-install /dev/sdb
That took about 30 seconds, threw up about 15 'node not found' errors, and told me it had completed, like everything was fine. It's still not a boot disk. Barring someone spotting my mistake, my next move is to use the 'iso2usb.sh' script on it, make a live system on sdb, and go forward from there. It may well mean copying 550G of data over again, but hell, what are disks for? It's a background copy anyhow.

Here's the bit of the 'iso2usb.sh' script, which looks an awful lot different from what I did. I already feel another 550G copy coming on :mad:
Code:

  # Use sgdisk to wipe and then setup the USB device:
  # - 1 MB BIOS boot partition
  # - 100 MB EFI system partition
  # - Let Slackware have the rest
  # - Make the Linux partition "legacy BIOS bootable"
  # Make sure that there is no MBR nor a partition table anymore:
  dd if=/dev/zero of=$TARGET bs=512 count=1 conv=notrunc

  # We have to use wipefs before sgdisk or else traces of an old 'cp' or 'dd'
  # of a Live ISO image to the device will not be erased.
  # The sgdisk wipe command is allowed to have non-zero exit code:
  wipefs -af $TARGET
  sgdisk -og $TARGET || true

  # After the wipe, get the value of the last usable sector:
  ENDSECT=$(sgdisk -E $TARGET)

The script gets fairly long-winded after that as he has user input to figure out. Here's his bit on setting up the disk
Code:

# Setup the disk partitions:
  sgdisk \
    -n 1:${LP1_START}:${LP1_END} -c 1:"BIOS Boot Partition" -t 1:ef02 \
    -n 2:${LP2_START}:${LP2_END} -c 2:"EFI System Partition" -t 2:ef00 \
    -n 3:${LP3_START}:${LP3_END} -c 3:"Slackware Linux" -t 3:8300 \
    $TARGET
  sgdisk -A 3:set:2 $TARGET
  # Show what we did to the USB stick:
  sgdisk -p -A 3:show $TARGET

As for what it does with grub - well, it doesn't. It uses the syslinux/etxlinux stuff.

I'd welcome ideas on this, but I'm backing off the priority a tad, as I have a cd/dvd rom --> 2.5" hd converter on it's way from our helpful friends at Ali Express, to make a slightly less chaotic setup here, and better use the unspectacular throughput this box posesses.

business_kid 01-13-2022 10:27 AM

Quote:

Originally Posted by wpeckham (Post 6317827)
http://www.rodsbooks.com/refind/
It is an EFI boot manager. If you are not on an EFI/UEFI machine you do not need it.
Nice project though.

I'm on a UEFI machine but using the Legacy option which requires partitioning sda with fdisk. If I use gdisk, the BIOS ignores set values and looks for EFI. where I will stand with an internal sdb formatted by gdisk is an unknown. My experience with UEFI on this box has been
Quote:

Abandon hope all ye who enter here.
Luckily, this laptop is not mission critical to anyone, and I do have the SaveMyA** liveslack usb disk to smooth things over if/when all else fails.

colorpurple21859 01-13-2022 11:36 AM

Do you have grub installed in the mbr of sda and/or does sda boot with grub?

business_kid 01-13-2022 12:11 PM

sda is mbr formatted, and sda1=/boot=ext4. I presume grub is in sda's mbr.

I feel another rejig of that new disk coming on, but who cares? I'm thinking all the /dev/disk/by-* symlinks probably broke when I copied them over. I might give that another go if I get energy.

colorpurple21859 01-13-2022 01:13 PM

at sda grub boot menu press c for grub command line
Code:

grub>ls
See if grub sees the sdb drive. It should be listed as (hd1)

if it is make a /boot/grub/custom.cfg file on sda1 with this in
Code:

menuentry 'sdb chainload' {
set root=(hd1)
chainloader +1
}

reboot and see if grub will chainload sdb mbr/

enorbet 01-13-2022 04:08 PM

My apologies if rEFInd doesn't help your case, business_kid. I may be projecting my own confusion with Grub on multi disk, multi partitioned systems. I had a terrible time just trying to use Grub CLI to try to discover exactly what it could "see" and then how to correctly handle the arcane syntax to properly boot them/it. rEFInd made it vastly simpler for me as I have 4 drives, 2 SSDs and 2 HDDs, with some partitioned GPT and others MBR. rEFInd made that relatively simple for me, simple enough I can see just EFI bootables if I disable CSM Legacy. or all of them if I enable CSM. It might not be what you need but it's a thought possibly worth looking into.


All times are GMT -5. The time now is 01:24 PM.