[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: regenerating /boot/efi/debian/



Adrian,
       I've attached my final copy of a update-efi-booter script
(which when used with the compiled disable_journal source code allows
a user to quickly switch there /boot/efi partition over from vfat to
hfs+ so that the installed boot.efi can be blessed and the Mac option
key boot selector thus see it (eliminating the need for rEFind in
order to be able to switch between other installed OS releases)...

Tested on a fresh install of Ubuntu 16.10 x86_64 by...

gcc -o disable_journal disable_journal.c
chmod ugo+x update-efi-booter
install disable_journal update-efi-booter /usr/local/bin

identify the device that the /boot/efi partition is mounted on, umount
it and then use gdisk to delete that partition and create a new one
with the code AF00 for HFS+. Write the changes out in gdisk and then
execute mkfs.hfsplus on the device to format it. Now change the
boot/efi entry in fstab to have 'hfsplus defaults', remount the
boot/efi partition and just execute the 'update-efi-booter' script.

Afterwards the /boot/efi subdirectory will contain...
# cd /boot/efi/
# ls -lR .
.:
total 4
-rw-r--r-- 1 root root 34 Dec 16 23:04 mach_kernel
drwxr-xr-x 1 root root 3 Dec 16 23:04 System

./System:
total 0
drwxr-xr-x 1 root root 3 Dec 16 23:04 Library

./System/Library:
total 0
drwxr-xr-x 1 root root 4 Dec 16 23:04 CoreServices

./System/Library/CoreServices:
total 1968
-rw-r--r-- 1 root root 2009088 Dec 16 23:04 boot.efi
-rw-r--r-- 1 root root 380 Dec 16 23:04 SystemVersion.plist

and where the boot.efi is now blessed on a HFS+ filesystem. This
allows the option key boot selector on Macs to display the Ubuntu
operating system with a customized icon. Thus rEFind is no longer
needed to be able to switch between other installed OS releases.

The script makes the method robust to execute on any Mac. I've tested
it on a MacPro 3,1 with EFI-64 firmware as well as a MacBook Pro 2,1
with EFI-32 firmware.
                           Jack
ps The boot/efi reformatting steps are basically cribbed from
http://heeris.id.au/2014/ubuntu-plus-mac-pure-efi-boot/.

On Fri, Dec 16, 2016 at 3:17 AM, adrian15 <adrian15sgd@gmail.com> wrote:
> Not sure what you mean with that pdf you sent me.
> Can you give me feedback on what I requested you to test?
>
> It's very difficult to interact with you if I don't have clear answers to
> what I ask to you.
>
> It would be nice if you could explain to me what you tried exactly (from
> what I asked you) and what were the results you obtained.
>
> You can, of course, give me later you opinion on why it does not work as you
> tend to do. It's useful. But please first do the tests and then we polish
> them.
>
> Thank you for understanding.
>
> El 16/12/16 a las 06:42, Jack Howarth escribió:
>
>> Adrian,
>>      Actually the methodology proposed in
>>
>>
>> http://courses.cms.caltech.edu/cs171/materials/pdfs/How_to_Dual-Boot_OSX_and_Ubuntu.pdf
>>
>> isn't that bad if you have script to automate the steps.
>>                                 Jack
>>
>>
>> On Thu, Dec 15, 2016 at 6:26 AM, adrian15 <adrian15sgd@gmail.com> wrote:
>>>
>>> I CC my answer to debian-efi because I'm also interested on knowing how
>>> portable are the Debian installation disk EFI files and Debian installed
>>> on
>>> a hard disk EFI files. In such a way that portable means just replacing
>>> them
>>> in other Live CDS, i.e. Ubuntu installation disks.
>>>
>>> 1) You should use DD to put Super Grub2 Disk into your USB (Warns deletes
>>> all the content of the device).
>>>
>>> It works as a live cd . Stop asking me how to install it. You can ask me
>>> how
>>> to put it into a USB though. It does not make sense to install it in a
>>> normal hard disk because it's a boot-only system for emergency
>>> situations.
>>>
>>> You should download an old version which has i386-efi on its filename (as
>>> I
>>> more or less introduced in my first email)
>>>
>>> 2)a)
>>> I'm not sure just replacing EFI file in a USB device with Ubuntu
>>> installation in a filesystem which you can edit would actually work.
>>>
>>> I'm not sure if an ISO or USB image in order to load EFI files it saves
>>> somewhere the number of blocks to load it. Maybe EFI system is smart
>>> enough
>>> to read from the filesystem.
>>>
>>> Anyways it might be that the EFI file has something hardcoded inside of
>>> it
>>> that makes it to work inside an installed system which it's not going to
>>> work for a installation system.
>>>
>>> 2)b)
>>> If it works you should be able to use the EFI files from the
>>> /boot/efi/EFI/debian directory to do the swap. (Replace Ubuntu file
>>> contents
>>> per one of those file contents)
>>>
>>> 2)c)
>>> You can do 2)b) with Super Grub2 Disk files instead of Debian ones which
>>> might work or not. I'm not sure. Once you put SG2D into a USB it should
>>> let
>>> mount it and search the files inside it. Or you can put it into a ISO
>>> or...
>>> mount loop the ISO and find the files there.
>>>
>>>
>>> adrian15
>>>
>>>
>>> El 15/12/16 a las 02:02, Jack Howarth escribió:
>>>>
>>>>
>>>> Adrian,
>>>>       I'll definitely give SuperGrub a go this weekend on a spare USB
>>>> hard drive I have laying around. However, it will take me a few days to
>>>> work through the documentation to see how I should use it. In
>>>> particular, I was considering trying another installation of Ubuntu
>>>> 16.10 x86_64 Linux from my MacPro 3,1 and then see if replacing the
>>>> stock grub2 with SupreGrub will allow the USB drive to boot on the
>>>> EFI-32 firmware of my MacBook Pro 2,1. Do I need to install SuperGrub
>>>> with any special options invoked or will it automatically preconfigure
>>>> for booting from either EFI-32 or EFI-64 firmware?
>>>>             Jack
>>>>
>>>> On Wed, Dec 14, 2016 at 6:22 PM, adrian15 <adrian15sgd@gmail.com
>>>> <mailto:adrian15sgd@gmail.com>> wrote:
>>>>
>>>>
>>>>
>>>>      El 13/12/16 a las 09:50, Jack Howarth escribió:
>>>>
>>>>                 During my struggles to get a bootable linux installed on
>>>> a
>>>>          MacBook Pro 2,1 which has EFI-32 firmware, I discover that the
>>>>          debian-8.6.0-amd64-i386-netinst.iso multi-arch installer was
>>>> the
>>>>          only
>>>>          Linux distribution capable of achieving this. However I wanted
>>>>          to use
>>>>          the Unity Deskttop on Ubuntu 16.10 so I switched the
>>>>          /etc/apt/sources.list over to their copy to reinstall that
>>>> distro.
>>>>          This, however left me with, the following critical piece for
>>>> the
>>>>          Debian Jessie installation.
>>>>
>>>>          /boot/efi/EFI/debian/grub.efi
>>>>          /boot/efi/EFI/debian/grub.efi
>>>>
>>>>          Am I correct to assume that the command to regenerate these
>>>> under
>>>>          Ubuntu 16.10 amd64 would actually be...
>>>>
>>>>          sudo grub-install --target i386-efi --boot-directory=/boot
>>>>          --efi-directory=/boot/efi --bootloader-id="${lsb_release -ds)"
>>>>
>>>>          and for the amd64 kernel to still run should I just have
>>>>          grub-efi-ia32-bin installed or does grub-efi-ia32 also have be
>>>>          installed as well?
>>>>
>>>>
>>>>      In your situation I would install:
>>>>
>>>>      grub-efi-ia32
>>>>
>>>>      accept that it's going to remove (probably) grub-efi-amd64 and
>>>>      grub-efi-am64-bin .
>>>>
>>>>      And then install the new grub with just:
>>>>
>>>>      sudo grub-install # Grub should autodetect EFI and install there.
>>>>
>>>>
>>>>      If your system has the EFI partition mounted in /boot/efi you
>>>> should
>>>>      be fine.
>>>>
>>>>
>>>>      I'm still interested in your feedback trying Super Grub2 Disk which
>>>>      I have discussed with you in a private email.
>>>>
>>>>      If you do enough tests who knows if you might finish convincing me
>>>>      on building a refactored Ubuntu installation disk which boots from
>>>>      EFI-32 thanks to Super Grub2 Disk (or Grub2 technically speaking,
>>>>      but it's easier for me if I put everything in there).
>>>>
>>>>
>>>>      adrian15
>>>>
>>>>      --
>>>>      Support free software. Donate to Super Grub Disk. Apoya el software
>>>>      libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/
>>>>      <http://www.supergrubdisk.org/donate/>
>>>>
>>>>
>>>
>>> --
>>> Support free software. Donate to Super Grub Disk. Apoya el software
>>> libre.
>>> Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/
>
>
> --
> Support free software. Donate to Super Grub Disk. Apoya el software libre.
> Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/

Attachment: update-efi-booter_GM
Description: Binary data

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <byteswap.h>



int main(int argc, char *argv[])
{
	int fd = open(argv[1], O_RDWR);
	if(fd < 0) {
		perror("open");
		return -1;
	}
	
	unsigned char *buffer = (unsigned char *)mmap(NULL, 2048, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
	if(buffer == (unsigned char*)0xffffffff) {
		perror("mmap");
		return -1;
	}
	
	if((buffer[1024] != 'H') && (buffer[1025] != '+')) {
		fprintf(stderr, "%s: HFS+ signature not found -- aborting.\n", argv[0]);
		return -1;
	}
	
	unsigned long attributes = *(unsigned long *)(&buffer[1028]);
	attributes = bswap_32(attributes);
	printf("attributes = 0x%8.8lx\n", attributes);
	
	if(!(attributes & 0x00002000)) {
		printf("kHFSVolumeJournaledBit not currently set in the volume attributes field.\n");
	}
	
	attributes &= 0xffffdfff;
	attributes = bswap_32(attributes);
	*(unsigned long *)(&buffer[1028]) = attributes;
	
	buffer[1032] = '1';
	buffer[1033] = '0';
	buffer[1034] = '.';
	buffer[1035] = '0';
	
	buffer[1036] = 0;
	buffer[1037] = 0;
	buffer[1038] = 0;
	buffer[1039] = 0;
	
	printf("journal has been disabled.\n");
	return 0;
}

Reply to: