diff options
Diffstat (limited to 'docs/gnulinux/grub_cbfs.md')
-rw-r--r-- | docs/gnulinux/grub_cbfs.md | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/docs/gnulinux/grub_cbfs.md b/docs/gnulinux/grub_cbfs.md index d3222e66..b76dd654 100644 --- a/docs/gnulinux/grub_cbfs.md +++ b/docs/gnulinux/grub_cbfs.md @@ -31,11 +31,11 @@ which (if you don't know) allows you to download files from the internet. If you don't already have it installed, you can install it, using the `apt-get` command (in Debian-based distributions): - $ sudo apt-get install wget + $ sudo apt-get install wget You can install it in Arch-based systems, using `pacman`: - $ sudo pacman -S wget + $ sudo pacman -S wget Once you've installed `wget`, use it to download the file, simply by passing it the URL as an argument; you can save the file anywhere, @@ -43,23 +43,23 @@ but for the purpose of this guide, save it in **~/Downloads** (your **Home** directory's downloads folder). First, change the current working directory to **~/Downloads**: - $ cd ~/Downloads + $ cd ~/Downloads This guide assumes you are using the **20160907** version of Libreboot; if using a different version, modify the following commands accordingly: - $ wget https://www.mirrorservice.org/sites/libreboot.org/release/stable/20160907/\ - >libreboot_r20160907_util.tar.xz + $ wget https://www.mirrorservice.org/sites/libreboot.org/release/stable/20160907/\ + >libreboot_r20160907_util.tar.xz After the file is downloaded, use the `tar` command to extract its contents: - $ tar -xf libreboot_r20160907_util.tar.xz + $ tar -xf libreboot_r20160907_util.tar.xz After extraction, the folder will have the same name as the archive: in this case, **libreboot\_r20160907\_util**. For simplicity's sake, we'll rename it **libreboot\_util**, using the `mv` command: - $ mv "libreboot_r20160907_util" "libreboot_util" + $ mv "libreboot_r20160907_util" "libreboot_util" Now you have the folder with all the utilities necessary to read and modify the contents of the ROM. @@ -78,11 +78,11 @@ You could also compile both of these utilities; see [How to Build flashrom](../g `flashrom` is also available from the repositories; if using an Arch-based distribution, use `pacman`: - $ sudo pacman -S flashrom + $ sudo pacman -S flashrom Or, if you have a Debian-based distribution, use `apt-get`: - $ sudo apt-get install flashrom + $ sudo apt-get install flashrom ### Get the ROM Image You can either work directly with one of the ROM images already included @@ -102,12 +102,12 @@ variable flash chip sizes only apply for the Thinkpads that Libreboot supports ( You can find the flash chip size, by running the following command: - # flashrom -p internal -V + # flashrom -p internal -V Look for a line like this: - Found Macronix flash chip "MX25L6406E/MX25L6408E" (8192 kB, SPI) \ - mapped at physical address 0x00000000ff800000. + Found Macronix flash chip "MX25L6406E/MX25L6408E" (8192 kB, SPI) \ + mapped at physical address 0x00000000ff800000. Running this command on my Thinkpad X200 gives me the above result, so I know that my flash chip size is **8mb**. @@ -118,30 +118,30 @@ to download the correct ROM images for that model. First, we're going to navigate to the **libreboot\_util** folder: - $ cd ~/Downloads/libreboot_util/ + $ cd ~/Downloads/libreboot_util/ Then, we will download the ROM images, using `wget`: - $ wget https://www.mirrorservice.org/sites/libreboot.org/release/stable/\ - 20160907/rom/grub/libreboot_r20160907_grub_x200_8mb.tar.xz + $ wget https://www.mirrorservice.org/sites/libreboot.org/release/stable/\ + >20160907/rom/grub/libreboot_r20160907_grub_x200_8mb.tar.xz Extract the archive, using `tar`: - $ tar -xf libreboot_r20160907_grub_x200_8mb.tar.xz + $ tar -xf libreboot_r20160907_grub_x200_8mb.tar.xz Navigate to the directory that you just created: - $ cd libreboot_r20160907_grub_x200_8mb + $ cd libreboot_r20160907_grub_x200_8mb Now that we are in the archive, we must choose the correct ROM image. To figure out the correct image, we must first parse the filenames for each ROM. For example, for the file named **x200_8mb_usqwerty_vesafb.rom**: - Model Name: x200 - Flash Chip Size: 8mb - Country: us - Keyboard Layout: qwerty - ROM Type: vesafb or txtmode + Model Name: x200 + Flash Chip Size: 8mb + Country: us + Keyboard Layout: qwerty + ROM Type: vesafb or txtmode Since I am using a QWERTY keyboard, I will ignore all the non-QWERTY options. Note that there are two types of ROMs: **vesafb** and **txtmode**; @@ -152,19 +152,19 @@ used by coreboot native graphics initialization. I'll choose **x200_8mb_usqwerty_vesafb.rom**; I'll copy the file (to the `cbfstool` directory), and rename it with one command: - $ mv "x200_8mb_usqwerty_vesafb.rom" ../cbfstool/x86_64/cbfstool/x86_64/libreboot.rom + $ mv "x200_8mb_usqwerty_vesafb.rom" ../cbfstool/x86_64/cbfstool/x86_64/libreboot.rom #### 2. Create an Image from the Current ROM The simpler way to get a ROM image is to just create it from your current ROM, using `flashrom`, making sure to save it in the `cbfstool` folder, inside **libreboot\_util**: - $ sudo flashrom -p internal -r ~/Downloads/libreboot_util/cbfstool/\ - x86_64/cbfstool/x86_64/libreboot.rom + $ sudo flashrom -p internal -r ~/Downloads/libreboot_util/cbfstool/\ + >x86_64/cbfstool/x86_64/libreboot.rom If you are told to specify the chip, add the option `-c {your chip}` to the command, like this: - $ sudo flashrom -c MX25L6405 -p internal -r ~/Downloads/libreboot_util/\ - cbfstool/x86_64/cbfstool/x86_64/libreboot.rom + $ sudo flashrom -c MX25L6405 -p internal -r ~/Downloads/libreboot_util/\ + >cbfstool/x86_64/cbfstool/x86_64/libreboot.rom Now you are ready to extract the GRUB configuration files from the ROM, and modify them the way you want. @@ -173,12 +173,12 @@ Now you are ready to extract the GRUB configuration files from the ROM, and modi You can check the contents of the ROM image, inside CBFS, using `cbfstool`. First, navigate to the cbfstool folder: - $ cd ~/Downloads/libreboot_util/cbfstool/x86_64/cbfstool/x86_64/ + $ cd ~/Downloads/libreboot_util/cbfstool/x86_64/cbfstool/x86_64/ Then, run the `cbfstool` commmand, with the `print` option; this will display a list of all the files located in the ROM: - $ ./cbfstool libreboot.rom print + $ ./cbfstool libreboot.rom print You should see **grub.cfg** and **grubtest.cfg** in the list. **grub.cfg** is loaded by default, with a menu entry for switching to **grubtest.cfg**. In @@ -187,7 +187,7 @@ reduce the possibility of bricking your device, so *DO NOT SKIP THIS!* Extract (i.e., get a copy of ) **grubtest.cfg** from the ROM image: - $ ./cbfstool libreboot.rom extract -n grubtest.cfg -f grubtest.cfg + $ ./cbfstool libreboot.rom extract -n grubtest.cfg -f grubtest.cfg By default `cbfstool` will extract files to the current working directory; so, **grubtest.cfg** should appear in the same folder as **libreboot.rom**. @@ -199,24 +199,24 @@ or the one located in the ROM, the modifications will be the same. Once the file is open, look for the following line (it will be towards the bottom of the file): - menuentry 'Load Operating System [o]' --hotkey='o' --unrestricted + menuentry 'Load Operating System [o]' --hotkey='o' --unrestricted After this line, there will be an opening bracket **{**, followed by a several lines of code, and then a closing bracket **}**; delete everything that is between those two brackets, and replace it with the following code, if you're using an Arch-based disribution (e.g., Parabola GNU+Linux-Libre): - cryptomount -a - set root='lvm/matrix-root' - linux /boot/vmlinuz-linux-libre root=/dev/matrix/root cryptdevice=/dev/sda1:root \ - cryptkey=rootfs:/etc/mykeyfile - initrd /boot/initramfs-linux-libre.img + cryptomount -a + set root='lvm/matrix-root' + linux /boot/vmlinuz-linux-libre root=/dev/matrix/root cryptdevice=/dev/sda1:root \ + cryptkey=rootfs:/etc/mykeyfile + initrd /boot/initramfs-linux-libre.img Or, replace it with this, if you are using a Debian-based distribution (e.g., Trisquel GNU+Linux): - cryptomount -a - set root='lvm/matrix-rootvol' - linux /vmlinuz root=/dev/mapper/matrix-rootvolcryptdevice=/dev/mapper/matrix-rootvol:root - initrd /initrd.img + cryptomount -a + set root='lvm/matrix-rootvol' + linux /vmlinuz root=/dev/mapper/matrix-rootvolcryptdevice=/dev/mapper/matrix-rootvol:root + initrd /initrd.img Remember, that these names come from the instructions to install GNU+Linux on Libreboot systems, located [here](index.md). If you followed different instructions, @@ -243,8 +243,8 @@ the main storage for **/boot/grub/libreboot\_grub.cfg** or **/grub/libreboot\_gr Therefore, we need to either copy **libreboot\_grub.cfg** to **/grub**, or to **/boot/grub**: - $ sudo cp ~/Downloads/libreboot_util/cbfstool/x86_64/cbfstool/x86_64/grubtest.cfg \ - >/boot/grub # or /grub + $ sudo cp ~/Downloads/libreboot_util/cbfstool/x86_64/cbfstool/x86_64/grubtest.cfg \ + >/boot/grub # or /grub Now, the next time we boot our computer, GRUB (in Libreboot) will automatically switch to this configuration file. *This means that you do not have to re-flash, @@ -259,11 +259,11 @@ Now that you have the modified **grubtest.cfg**, we need to remove the old **grubtest.cfg** from the ROM, and put in our new one. To remove the old one, we will use `cbfstool`: - $ ./cbfstool libreboot.rom remove -n grubtest.cfg + $ ./cbfstool libreboot.rom remove -n grubtest.cfg Then, add the new one to the ROM: - $ ./cbfstool libreboot.rom add -n grubtest.cfg -f grubtest.cfg -t raw + $ ./cbfstool libreboot.rom add -n grubtest.cfg -f grubtest.cfg -t raw #### Change MAC address in ROM The last step before flashing the new ROM, is to change the MAC address inside it. @@ -286,12 +286,12 @@ and look for a set of characters like this: `00:f3:f0:45:91:fe`. Next, you need to move **libreboot.rom** to the following folder; this is where the executable for `ich9gen` is located: - $ mv libreboot.rom ~/Downloads/libreboot_r20160907_util/ich9deblob/ + $ mv libreboot.rom ~/Downloads/libreboot_r20160907_util/ich9deblob/ Once there, run the following command, making sure to use your own MAC address, instead of what's written below: - $ ./ich9gen --macaddress XX:XX:XX:XX:XX:XX + $ ./ich9gen --macaddress XX:XX:XX:XX:XX:XX Three new files will be created: @@ -304,11 +304,11 @@ if your flash chip size is **8mb**, you'll want to use **ich9fdgbe_8m.bin**. Now, insert this file (called the `descriptor+gbe`) into the ROM image, using `dd`: - dd if=ich9fdgbe_8m.bin of=libreboot.rom bs=1 count=12k conv=notrunc + $ dd if=ich9fdgbe_8m.bin of=libreboot.rom bs=1 count=12k conv=notrunc Move **libreboot.rom** back to the **libreboot\_util** directory: - $ mv libreboot.rom ~/Downloads/libreboot_util + $ mv libreboot.rom ~/Downloads/libreboot_util You are finally ready to flash the ROM! @@ -316,18 +316,18 @@ You are finally ready to flash the ROM! The last step of flashing the ROM requires us to change our current working directory to **libreboot\_util**: - $ cd ~/Downloads/libreboot_util + $ cd ~/Downloads/libreboot_util Now, all we have to do is use the `flash` script in this directory, with the `update` option, using **libreboot.rom** as the argument: - $ sudo ./flash update libreboot.rom + $ sudo ./flash update libreboot.rom Ocassionally, coreboot changes the name of a given board. If `flashrom` complains about a board mismatch, but you are sure that you chose the correct ROM image, then run this alternative command: - $ sudo ./flash forceupdate libreboot.rom + $ sudo ./flash forceupdate libreboot.rom You will see the `flashrom` program running for a little while, and you might see errors, but if it says `Verifying flash... VERIFIED` at the end, then it’s flashed, @@ -354,11 +354,11 @@ of **grubtest.cfg**, called **grub.cfg**. First, go to the `cbfstool` directory: - $ cd ~/Downloads/libreboot_util/cbfstool/x86_64/cbfstool/x86_64/ + $ cd ~/Downloads/libreboot_util/cbfstool/x86_64/cbfstool/x86_64/ Then, create a copy of **grubest.cfg**, named **grub.cfg**: - $ cp grubtest.cfg ./grub.cfg + $ cp grubtest.cfg ./grub.cfg Now you will use the `sed` command to make several changes to the file: the menu entry `'Switch to grub.cfg'` will be changed to `Switch to grubtest.cfg`, @@ -367,25 +367,25 @@ This is so that the main configuration still links (in the menu) to **grubtest.c so that you don't have to manually switch to it, in case you ever want to follow this guide again in the future (modifying the already modified config).: - $ sed -e 's:(cbfsdisk)/grub.cfg:(cbfsdisk)/grubtest.cfg:g' -e \ - >'s:Switch to grub.cfg:Switch to grubtest.cfg:g' < grubtest.cfg > \ - >grub.cfg + $ sed -e 's:(cbfsdisk)/grub.cfg:(cbfsdisk)/grubtest.cfg:g' -e \ + >'s:Switch to grub.cfg:Switch to grubtest.cfg:g' < grubtest.cfg > \ + >grub.cfg Move **libreboot.rom** from **libreboot\_util** to your current directory: - $ mv ~/Downloads/libreboot_util/libreboot.rom . + $ mv ~/Downloads/libreboot_util/libreboot.rom . Delete the **grub.cfg** that's already inside the ROM: - $ ./cbfstool libreboot.rom remove -n grub.cfg + $ ./cbfstool libreboot.rom remove -n grub.cfg Add your modified **grub.cfg** to the ROM: - $ ./cbfstool libreboot.rom add -n grub.cfg -f grub.cfg -t raw + $ ./cbfstool libreboot.rom add -n grub.cfg -f grub.cfg -t raw Move **libreboot.rom** back to **libreboot\_util**: - $ mv libreboot.rom ../.. + $ mv libreboot.rom ../.. If you don't remember how to flash it, refer back to the *Flash Updated ROM Image*, above; it's the same method as you used before. Afterwards, reboot the machine with your new configuration. |