From de822b0ee77a2805f5d32a456b04fafe3379812f Mon Sep 17 00:00:00 2001 From: Jens True Date: Mon, 3 May 2021 16:15:05 +0200 Subject: [PATCH] Blog post about making a GRUB tampoline --- config/_default/params.yaml | 2 +- content/post/bit-magic/index.md | 2 +- content/post/grub-trampoline/index.md | 86 +++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 content/post/grub-trampoline/index.md diff --git a/config/_default/params.yaml b/config/_default/params.yaml index 09aeb3b..04c9b5a 100644 --- a/config/_default/params.yaml +++ b/config/_default/params.yaml @@ -69,7 +69,7 @@ address_format: dk # Site features -highlight: false +highlight: true math: false diagram: false privacy_pack: false diff --git a/content/post/bit-magic/index.md b/content/post/bit-magic/index.md index 9889ba1..9115a84 100644 --- a/content/post/bit-magic/index.md +++ b/content/post/bit-magic/index.md @@ -4,6 +4,7 @@ subtitle: "Tips and trick for embedded C/C++" summary: "Tips and trick for embedded C/C++" date: 2020-06-13T19:01:19+02:00 lastmod: 2020-06-13T19:01:19+02:00 +highlight: true --- # Set a bit @@ -24,7 +25,6 @@ output = input & ~(1 << bit); variable &= ~(1 << bit); // Multiple bits variable &= ~(0b101 << bit); - ``` # Toggle a bit diff --git a/content/post/grub-trampoline/index.md b/content/post/grub-trampoline/index.md new file mode 100644 index 0000000..3854261 --- /dev/null +++ b/content/post/grub-trampoline/index.md @@ -0,0 +1,86 @@ +--- +# Documentation: https://wowchemy.com/docs/managing-content/ + +title: "GRUB Trampoline" +subtitle: "Install GRUB on a spare drive" +summary: "Using a spare drive to act as a trampoline during the boot process." +date: 2021-05-03T15:28:14+02:00 +lastmod: 2021-05-03T15:28:14+02:00 +highlight: true +--- +# Background + +Due to a BIOS bug in my HP MicroServer I have applied this workaround. The MicroServer Gen8 has a bug that prevents the use of the 5th SATA port as the primary boot device. It will automatically attempt to boot from SATA port 1 if a drive is inserted, then port 2 and so forth. By removing all the fixed drives it is possible to make the system boot from port 5. + +It is however possible to boot from the internal USB port or the internal MicroSD slot. So to solve this issue we are going to install GRUB onto a spare MicroSD card or a USB stick. The size or quality of the drive should not matter since we only need it for GRUB to jump to the drive present on the 5th SATA port. + +# Steps +## Format the USB/SD Card +Find the correct device identifier. + +```shell +lsblk +``` + +Clear the drive by writing all zeros to the drive (for good measure) + +```shell +sudo dd if=/dev/zero of=/dev/sdX +``` + +Format the disk + +```shell +sudo fdisk /dev/sdX +``` + +Fdisk provides a shell where you can enter commands. +- Set the type to "o" for MSDOS +- Set the disk to be bootable "a" +- Make a new primary partition "n" followed by "n" Accept the remaining as default. +- Use "w" to commit the changes and exit the tool. + +Now create a filesystem in the newly created partition. + +```shell +sudo mkfs -t ext2 /dev/sdX1 +``` + +## Prepare for GRUB install +Create a mount point + +```shell +mkdir /tmp/mysub +``` + +Mount the new parition + +```shell +sudo mount /dev/sdX1 /tmp/myusb +``` + +Create a folder named "boot" on the drive + +```shell +sudo mkdir /tmp/myusb/boot +``` + +## Install GRUB +Install GRUB by running the grub-install script + +```shell +sudo grub-install --boot-directory=/tmp/myusb/boot /dev/sdX +``` + +Update the GRUB configuration + +```shell +sudo update-grub --output=/tmp/myusb/boot/grub/grub.cfg +``` + +## Test +Finally unmount and reboot +```shell +sudo unmount /tmp/myusb +sudo reboot +```