WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [Solved] grub cannot read usb drive's ext4 partition  (Read 2335 times)

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1347
[Solved] grub cannot read usb drive's ext4 partition
« on: February 07, 2024, 07:52:29 AM »
I followed Juanito's wonderful instructions on how to create a device that will boot with either BIOS or (U)EFI here: https://forum.tinycorelinux.net/index.php/topic,19364.0.html

I have an old laptop with legacy BIOS, with frugal TCL installation on SSD. Thanks to Juanito's directions, my SSD can now boot in any laptop--I can continue to boot it in my old laptop, or I can transfer the SSD to a newer laptop that only supports UEFI. Tested and working! :)

I followed the same instructions to try to create a bootable USB stick with TCL on it (for rescue operations) but, surprisingly, I cannot get the stick to boot. My old laptop is able to find grub in the EFI partition, menu entries in grub.cfg are shown, but kernel cannot be found because grub claims the root filesystem is unknown.

Please see the attached screenshot. As you can see, grub is able to recognize an ext4 filesystem (hd1,gpt1) on my SSD just fine, but it cannot recognize an ext4 filesystem (at hd0,gpt1) on the USB drive. The filesystem is definitely ext4:

Code: [Select]
$ blkid /dev/sdb1
/dev/sdb1: UUID="7283ed99-3225-4add-be42-3d3031e5eb7b" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="Linux filesystem" PARTUUID="fdf388fb-54af-4d3c-97c5-bc17455a527f"

I already tried
Code: [Select]
insmod linux at the grub prompt and it didn't help. I also deleted all partitions from the USB stick and did everything again from the beginning, with same results.

Any idea why grub is unable to access the ext4 partition on /dev/sdb1 (which it sees as hd0,gpt1)?
« Last Edit: February 08, 2024, 06:04:51 AM by Rich »

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1347
Re: grub cannot read usb drive's ext4 partition
« Reply #1 on: February 07, 2024, 08:00:51 AM »
The partitioning scheme of the USB drive is shown in the attached screenshot.

/mnt/sdb3/EFI/BOOT/grub/grub.cfg is also attached (I tried to include it here but got a server error).

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 933
Re: grub cannot read usb drive's ext4 partition
« Reply #2 on: February 07, 2024, 08:03:09 AM »
Hi GNUser!
May old laptop be confused by GPT?

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1347
Re: grub cannot read usb drive's ext4 partition
« Reply #3 on: February 07, 2024, 08:05:40 AM »
Hi jazzbiker! I don't think that's it. Same exact strategy is currently being used on this laptop's SSD, and I can boot the SSD just fine.

EDIT: I'll try to boot this USB stick on the fancy new UEFI-only laptop, to confirm that the problem is with the USB stick.
« Last Edit: February 07, 2024, 08:07:14 AM by GNUser »

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 674
Re: grub cannot read usb drive's ext4 partition
« Reply #4 on: February 07, 2024, 08:09:28 AM »
I think you missing the gpt drivers, try to load them into grub.cfg
Code: [Select]
insmod part_gpt
insmod part_msdos

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1347
Re: grub cannot read usb drive's ext4 partition
« Reply #5 on: February 07, 2024, 08:11:54 AM »
I can confirm that the problem is with the USB stick, not my "old" daily driver laptop.

When I try to boot the USB stick on a fancy UEFI-only laptop, I see the same problem: I can't boot the stick and grub command line tells me this:

Code: [Select]
grub> ls (hd0,gpt1)
    Partition hd0,gpt1: No known filesystem detected - Partition start at 1024KiB - Total size 26214400KiB

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1347
Re: grub cannot read usb drive's ext4 partition
« Reply #6 on: February 07, 2024, 08:17:46 AM »
I think you missing the gpt drivers, try to load them into grub.cfg
Code: [Select]
insmod part_gpt
insmod part_msdos
Hi patrikg. That doesn't help on either (BIOS or UEFI) laptop, unfortunately.

Just to narrow down the problem, I wiped the USB drive again and created new GPT partition table, single ext4 partition, and a single helloworld.txt file in the partition. Same problem--grub cannot list the files in the partition because it claims the filesystem is "unknown".

Could it be that this USB drive does not correctly support GPT partition table?

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 674
Re: grub cannot read usb drive's ext4 partition
« Reply #7 on: February 07, 2024, 08:22:37 AM »
Strange, your are talking about grub that not founds the thing.
I can see that you tries to get into the command line in grub.
Why not just type lsmod to see what mods being loaded.
Do you have ext4 or ext2 there ??

For I don't know reason, in my arch gpt in grub i also have fat and bli module loaded.
Code: [Select]
insmod bli
Code: [Select]
insmod fat
« Last Edit: February 07, 2024, 08:31:11 AM by patrikg »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 933
Re: grub cannot read usb drive's ext4 partition
« Reply #8 on: February 07, 2024, 09:02:36 AM »
Hi GNUser!
Why not to try MBR?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11226
Re: grub cannot read usb drive's ext4 partition
« Reply #9 on: February 07, 2024, 09:15:03 AM »
Hi GNUser
Did you read this about removing the stick:
https://forum.tinycorelinux.net/index.php/topic,19364.msg143441.html#msg143441

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1347
Re: grub cannot read usb drive's ext4 partition
« Reply #10 on: February 07, 2024, 09:42:57 AM »
Hi Rich. I tried that after your tip and no luck.

As a last, desperate measure, I tried the  gdisk  and  mkfs  steps in Devuan. Lo and behold, the problem goes away.

My suspicion is that the  mkfs.ext4  step in TCL is silently failing to write some metadata to the usb stick. Without this metadata, grub cannot figure out the partition's filesystem and UUID.

I'd like to help pinpoint the problem. My preference is always to do everything in TCL.
« Last Edit: February 07, 2024, 09:44:54 AM by GNUser »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 933
Re: grub cannot read usb drive's ext4 partition
« Reply #11 on: February 07, 2024, 10:15:18 AM »
Hi GNUser!
You may experiment with my grub4tc.sh, I never had problems with it. Still You will see a number of 'sleep 10' instructions in certain places.

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1347
Re: grub cannot read usb drive's ext4 partition
« Reply #12 on: February 07, 2024, 10:17:06 AM »
I can confirm that this latest iteration of the USB stick (where I did  gdisk  and  mkfs  steps in Devuan) is booting just fine on my old BIOS laptop as well as on the new UEFI-only laptop.

I do have spare USB drives, of course, that I can use to troubleshoot this further.

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 674
Re: grub cannot read usb drive's ext4 partition
« Reply #13 on: February 07, 2024, 10:28:22 AM »
Do you see the usb drive in grub ?
Or even grub need some driver to get to the usb drive ?
nativedisk ?

https://wiki.debian.org/BootUsbWithGrubRescue#Booting_a_flash_drive_with_an_image_file_written_to_it

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1347
Re: grub cannot read usb drive's ext4 partition
« Reply #14 on: February 07, 2024, 10:39:15 AM »
Do you see the usb drive in grub ?

Yes. When I run ls at the grub command prompt, I can see the laptop's internal SSD and its ext4 parition (hd0 and hd0,gpt1 respectively) as well as the USB drive and its ext4 partition (hd1 and hd1,gpt1 respectively).

grub can show me the contents of my internal SSD with ls (hd0,gpt1)/ but cannot show me the contents of the USB drive when I try ls (hd1,gpt1)/ because it errors out with "No known filesystem". Note that both (hd0,gpt1) and (hd1,gpt1) are ext4 partitions.

I am able to browse the USB just fine when I'm fully booted into TCL on my SSD (and various tools such as  gparted  and  blkid  can tell that the USB's first partition is ext4). grub seems to be the only program confused about the USB partition's filetype.



« Last Edit: February 07, 2024, 10:45:04 AM by GNUser »