Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Booting from SD card
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1768
Location: PB, Germany

PostPosted: Tue Oct 18, 2016 7:01 am    Post subject: [SOLVED] Booting from SD card Reply with quote

Hi,

I can't get some grub2 booting from SD card.
Background is that I like to put the bootloader and the GPG-encrypted LUKS key on the SD card. The root system is stored on some large btrfs-on-luks. So I have the local harddrive as one huge luks-encrypted blockdevice. Booting requires 2 security levels that is the SD-Card (with bootloader and encrypted KEY file) and the GPG password to decrypt the KEY.

Installing grub2 on a USB pendrive, it works fine:
Code:
Model: Intenso Premium (scsi)
Disk /dev/sdc: 4043MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
 1      2097kB  4042MB  4040MB  primary  ext2
The same installed on the SD card is not possible to boot eventhough the boot devices of the bios offers SD.

However the hardware can boot from SD-card, at least with some recent sysresccd installed. But this comes from some iso image, that required some isohybrid to be bootable from SD:
Code:
Error: Invalid partition table - recursive partition on /dev/mmcblk0.
Ignore/Cancel? I   
Model: SD SD02G (sd/mmc)
Disk /dev/mmcblk0: 1980MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start  End  Size  Type  File system  Flags
Code:
# file systemrescuecd-x86-4.8.1.iso
systemrescuecd-x86-4.8.1.iso: ISO 9660 CD-ROM filesystem data 'sysrcd-4.8.1' (bootable)

_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770


Last edited by Massimo B. on Mon Nov 14, 2016 10:09 am; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54214
Location: 56N 3W

PostPosted: Tue Oct 18, 2016 9:16 am    Post subject: Reply with quote

Massimo B.,

Quote:
The same installed on the SD card is not possible to boot eventhough the boot devices of the bios offers SD.


Where does it go wrong?

Do you get a grub menu?
Does the kernel load ...
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1768
Location: PB, Germany

PostPosted: Tue Oct 18, 2016 9:19 am    Post subject: Reply with quote

It just skips very early and turns over to the default boot device as if there is no SD card inserted. No GRUB menu appearing. I would just guess that the hardware cannot boot from SD card if it wouldn't work successfully with the sysresccd image.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54214
Location: 56N 3W

PostPosted: Tue Oct 18, 2016 9:32 am    Post subject: Reply with quote

Massimo B.

How is the MMC card partitioned and what filesystems does it contain?
Are you using BIOS or EFI mode?
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1768
Location: PB, Germany

PostPosted: Tue Oct 18, 2016 10:00 am    Post subject: Reply with quote

I format the SD card exactly like the USB pendrive I showed above. It works on USB but not on the SD-Card.
Currently I copied that sysresccd iso image via dd on that SD, so this does not seem to have a valid partition map but some ISO 9660. But it is booting without issues.

I just prefer the SD-Card over USB pendrive as security key, because of its small form factor, fitting in my portemonnaie.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1768
Location: PB, Germany

PostPosted: Mon Nov 07, 2016 2:44 pm    Post subject: Reply with quote

Not a single idea why booting from SD with the ISO 9660 works, but not with grub and msdos or gpt partition table?
How does ISO 9660 boot, is there grub also installed in that filesystem? Can I make my own SD-card like that?
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
snkmoorthy
Guru
Guru


Joined: 19 Nov 2002
Posts: 376

PostPosted: Mon Nov 07, 2016 3:03 pm    Post subject: Reply with quote

may be you need to enable the 'boot' flag on the partition. Some BIOSes look for that specifically.(In fdisk use the 'a' option)
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1768
Location: PB, Germany

PostPosted: Mon Nov 14, 2016 10:09 am    Post subject: Reply with quote

I solved it, somehow I needed to use --force for grub-install as grub was not able to "embed" on the SD drive, no matter how much space I left in front of the first partition.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54214
Location: 56N 3W

PostPosted: Mon Nov 14, 2016 10:43 am    Post subject: Reply with quote

Massimo B.

--force makes grub use block lists to load itself. The block list is written when grub is installed to the MBR.
If you ever update grub on the SD card, you must reinstall it to the MBR too or the block lists will not point to the updated grub.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1768
Location: PB, Germany

PostPosted: Mon Nov 14, 2016 12:47 pm    Post subject: Reply with quote

Why do I need --force here at all, what about that blocklist mode and how can I avoid it?
As this is working:
Code:
 # grub-install --force --no-floppy /dev/mmcblk0 -v
grub-install: info: executing modprobe efivars 2>/dev/null.
grub-install: info: Looking for /sys/firmware/efi ...
grub-install: info: ... not found. Looking for /proc/device-tree ...
grub-install: info: ... not found.
Installing for i386-pc platform.
grub-install: info: cannot open `/boot/grub/device.map': No such file or directory.
grub-install: info: copying `/usr/lib/grub/i386-pc/acpi.mod' -> `/boot/grub/i386-pc/acpi.mod'.
grub-install: info: copying `/usr/lib/grub/i386-pc/adler32.mod' -> `/boot/grub/i386-pc/adler32.mod'.
grub-install: info: copying `/usr/lib/grub/i386-pc/affs.mod' -> `/boot/grub/i386-pc/affs.mod'.
grub-install: info: copying `/usr/lib/grub/i386-pc/afs.mod' -> `/boot/grub/i386-pc/afs.mod'.
...
grub-install: info: Partition 0 starts from 4096.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/mmcblk0 is 3866624.
grub-install: info: guessed root_dev `hostdisk//dev/mmcblk0' from dir `/boot/grub/i386-pc'.
grub-install: info: setting the root device to `hostdisk//dev/mmcblk0,msdos1'.
grub-install: warning: Attempting to install GRUB to a disk with multiple partition labels.  This is not supported yet..
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..
grub-install: info: will leave the core image on the filesystem.
grub-install: info: opening the core image `/boot/grub/i386-pc/core.img'.
grub-install: info: saving <428840,0,24576>.
grub-install: info: saving <428888,0,4096>.
grub-install: info: opening the core image `/boot/grub/i386-pc/core.img'.
Installation finished. No error reported.
...while this is failing:
Code:

# grub-install /dev/mmcblk0 -v
grub-install: info: executing modprobe efivars 2>/dev/null.
grub-install: info: Looking for /sys/firmware/efi ...
grub-install: info: ... not found. Looking for /proc/device-tree ...
grub-install: info: ... not found.
Installing for i386-pc platform.
grub-install: info: cannot open `/boot/grub/device.map': No such file or directory.
grub-install: info: copying `/usr/lib/grub/i386-pc/acpi.mod' -> `/boot/grub/i386-pc/acpi.mod'.
grub-install: info: copying `/usr/lib/grub/i386-pc/adler32.mod' -> `/boot/grub/i386-pc/adler32.mod'.
grub-install: info: copying `/usr/lib/grub/i386-pc/affs.mod' -> `/boot/grub/i386-pc/affs.mod'.
...
grub-install: info: Scanning for mdraid09 devices on disk hostdisk//dev/mmcblk0.
grub-install: info: Scanning for dmraid_nv devices on disk hostdisk//dev/mmcblk0.
grub-install: info: Scanning for ldm devices on disk hostdisk//dev/mmcblk0.
grub-install: info: scanning hostdisk//dev/mmcblk0 for LDM.
grub-install: info: no LDM signature found.
grub-install: info: Scanning for lvm devices on disk hostdisk//dev/mmcblk0.
grub-install: info: no LVM signature found.
grub-install: info: Partition 0 starts from 4096.
grub-install: info: drive = 0.
grub-install: info: the size of hostdisk//dev/mmcblk0 is 3866624.
grub-install: info: guessed root_dev `hostdisk//dev/mmcblk0' from dir `/boot/grub/i386-pc'.
grub-install: info: setting the root device to `hostdisk//dev/mmcblk0,msdos1'.
grub-install: warning: Attempting to install GRUB to a disk with multiple partition labels.  This is not supported yet..
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..
grub-install: error: will not proceed with blocklists.

_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54214
Location: 56N 3W

PostPosted: Mon Nov 14, 2016 3:06 pm    Post subject: Reply with quote

Massimo B.,

Code:
grub-install: warning: Attempting to install GRUB to a disk with multiple partition labels.  This is not supported yet..
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


It looks like you now use an MSDOS partition table but at one time, that SD card held a GPT partition table.
This makes grub go very carefully. Its quite possible you still have two complete but different partition tables. One MSDOS, one GPT.

Sometime, there was a GPT partition table on the device. When you make a GPT partition table, you get an MSDOS partition table with one entry of partition type 0xEE.
This is a warning that GPT is in use.
There are two copies of the GPT partiton table, one starting just after the MBP at LBA 1 and the other at the end of the drive.
At this time, you have two different partition tables but one has a label to say its a fake. This works, GPT is used.

Some time later, you either make a new partition table with a tool that does not understand GPT, so the old GPT partition table is left behind.
Certainly, the copy at the end of the drive is still there, even if its data is now inside the filesystem space.

You may have used a partition table tool that does not understand GPT, to delete the single MSDOS partition that carried the 0xEE warning flag and just made new partitions.

However it happened, grub can see both partition tables and is playing safe. Embedding would overwrite the primary copy of GPT partition table. That would be a very bad thing if GPT was really in use as it would be restored from the secondary copy next boot.

Choose which disk label you want to use. Copy the data off the SD card, make a new disk label with a GPT aware tool, restore the data then reinstall grub to the MBR.
If you choose GPT, you must make at least two partitions. Embedding is not passible, so grub will look for a BIOS Boot partition, about 2Mb in size. The grub embedding stuff goes here. If you choose MSDOS, embedding is possible and your GPT disk label will be correctly destroyed.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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