Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Creating EFI partition and installing Grub

Ask for help with issues regarding the Installations of the Debian O/S.
Post Reply
Message
Author
williamk
Posts: 6
Joined: 2017-05-26 16:06

Creating EFI partition and installing Grub

#1 Post by williamk »

Hey,

Have read the Debian Wiki on grub but still a little confused on how to fix my situation. I have a multi hard drive system that boots Ubuntu, Windows and Debian. Currently grub is installed on sda1 on a 512 MB EFI partition. I can boot to Debian on sdd1 using that grub install. I want to dump Ubuntu, create an EFI partition on sdd1, and install grub on it so I can boot to grub on sdd. Once I get that working I can format sda and reuse it for something else. Not sure if I can just use Gparted to resize sdd1 and create a 512 MB fat 32 partition and flag it as boot and esp. If I can do that, not sure how to create a new grub install on the new partition. Is there an easy way to do this without doing a total reinstall of Debian? Really hate to lose everything I have setup on my current install.

Here is my fdisk output:

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: D7E538F1-0298-4949-8B4C-46391937A2C0

Device Start End Sectors Size Type
/dev/sda1 2048 1050623 1048576 512M EFI System
/dev/sda2 1050624 2050047 999424 488M Linux filesystem
/dev/sda3 2050048 976771071 974721024 464.8G Linux LVM

Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: B43CCA85-905F-4058-AD59-C50A1574B2AF

Device Start End Sectors Size Type
/dev/sdb1 2048 487462911 487460864 232.5G Microsoft basic data
/dev/sdb2 487462912 488384511 921600 450M Windows recovery environment
/dev/sdb3 488386560 488419327 32768 16M Microsoft reserved
/dev/sdb4 488419328 976773119 488353792 232.9G Linux filesystem

Disk /dev/sdc: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf8dab888

Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 1953523711 1953521664 931.5G 83 Linux

Disk /dev/sdd: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe2f0b224

Device Boot Start End Sectors Size Id Type
/dev/sdd1 2048 479801343 479799296 228.8G 83 Linux
/dev/sdd2 479803390 500117503 20314114 9.7G 5 Extended
/dev/sdd5 479803392 500117503 20314112 9.7G 82 Linux swap / Solaris

Disk /dev/mapper/ubuntu--vg-root: 448.9 GiB, 482009415680 bytes, 941424640 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/ubuntu--vg-swap_1: 15.9 GiB, 17045651456 bytes, 33292288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

fsmithred
Posts: 1873
Joined: 2008-01-02 14:52

Re: Creating EFI partition and installing Grub

#2 Post by fsmithred »

That sounds like a recipe for some interesting problems. I don't know what happens if you have two efi partitions connected at the same time.

The approach I would take is to unplug sda, use a live-usb (or live-CD) to run gparted and shrink sdd1 to make room for the new efi partition. Put the new partition at the front. It will be called /dev/sdd3, I think. There's some e2fsck magic to change the numbers so that the new efi partition can be sdd1, but I don't recall what the command is. You might be able to get it to work if you leave it as sdd3. That probably depends on the uefi implementation from the manufacturer, which might follow no standards.

Then, either use an installer CD to install grub or manually chroot the debian from the live session and install grub. If you do it manually, remember to mount the efi partition on sdd to /boot/efi in the debian installation. The command is just 'grub-install' with no device. Grub will find the efi partition and use it. Then run update-grub to create a boot menu.

Then shut down, plug in sda again, boot the live media again and remove the boot,esp flags from sda1 (or reformat all of sda if you want.)
Then you can reboot debian and do whatever you want with sda. I think it should work, but make sure you back up any important data in case of a disaster. You might need to change the boot order if your motherboard expects the efi partition to be on the first hard disk.

Post Reply