You are not logged in.

#1 2016-05-11 22:14:17

leonixyz
Member
Registered: 2014-07-12
Posts: 62

Move grub from MBR to ESP

I have a thinkpad x1 carbon with windows 10 but when installing arch i accidentally installed grub to MBR. Now i cannot boot anymore into W10 (and I need it for work).

$ sudo fdisk /dev/sda -l
[sudo] password for leonixyz: 
Disk /dev/sda: 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: 0xa400ce2b

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048   1023999   1021952   499M  7 HPFS/NTFS/exFAT
/dev/sda2         1024000 326637395 325613396 155.3G  7 HPFS/NTFS/exFAT
/dev/sda3       326637568 343414783  16777216     8G 82 Linux swap / Solaris
/dev/sda4       343414784 500118191 156703408  74.7G 83 Linux

Arch is in /dev/sda4, windows 10 in /dev/sda2 and (i suppose) the EFI system partition is /dev/sda1. Unfortunately it doesn't looks like an ESP (no EFI folder inside)

$ sudo mount /dev/sda1 /mnt
$ ls /mnt 
ls: cannot open directory '/mnt': Permission denied
$ sudo ls /mnt -l
total 400
drwx------ 1 root root   8192 Jan 22 13:06 boot
-rw------- 1 root root 400228 Oct 30  2015 bootmgr
-rw------- 1 root root      1 Oct 30  2015 BOOTNXT
drwx------ 1 root root      0 Jan 22 13:09 Recovery
-rw------- 1 root root     44 Jan 22 13:07 _SMSTSVolumeID.7159644d-f741-45d5-ab29-0ad8aa4771ca
drwx------ 1 root root      0 Jan 22 13:08 'System Volume Information'

The current /boot is in /dev/sda4 and there are grub/, the kernel and initramfs inside there. There is no EFI folder also in /dev/sda2 (see this post)

1) Is actually /dev/sda1 an ESP?
2) What should i do to be able to boot both arch and windows10?

Thanks in advance

Offline

#2 2016-05-15 01:07:56

leonixyz
Member
Registered: 2014-07-12
Posts: 62

Re: Move grub from MBR to ESP

still stuck with this issue

Offline

#3 2016-05-15 05:29:26

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: Move grub from MBR to ESP

What is the output of:

lsblk -f

CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#4 2016-05-15 06:04:02

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,523

Re: Move grub from MBR to ESP

I think you should boot the ISO and chroot in it. Then repeat the grub installation. See details and the dual booting
Otherwise you might choose another boot loader that could be less complicated than grub. I.E. rEFInd.

Last edited by TheSaint (2016-05-15 06:05:24)


do it good first, it will be faster than do it twice the saint wink

Offline

#5 2016-05-16 10:30:14

leonixyz
Member
Registered: 2014-07-12
Posts: 62

Re: Move grub from MBR to ESP

@graysky

$ lsblk -f
NAME   FSTYPE LABEL    UUID                                 MOUNTPOINT
sda                                                         
├─sda1 ntfs   BDEDrive 0A16384E16383CCF                     
├─sda2 ntfs   OSDisk   DA783A41783A1CA7                     
├─sda3 swap   SWAP     853ff0ea-6a38-4fba-98ad-118b7367336e 
└─sda4 ext4   ROOT     d625d4f6-5d08-4dea-a6ef-db9a0e50efc4 /



@TheSaint
The wiki says:

For GPT, you are looking for "Partition Table: GPT". For EFI, you are looking for a small (512 MiB or less) partition with a vfat file system and the boot flag enabled.

Up to here everything ok (see first post), /dev/sda1 has size < 512MiB and boot flag enabled. But...

On it, there should be a directory named "EFI". If these criteria are met, this is your ESP. Make note of the partition number. You will need to know which one it is, so you can mount it later on while installing GRUB to it.

Unfortunately there is no EFI directory inside, and I have to mount it later on for installing grub:

The following steps install the GRUB UEFI application to esp/EFI/grub, install its modules to /boot/grub/x86_64-efi, and place the bootable grubx64.efi stub in esp/EFI/grub.

First, tell GRUB to use UEFI, set the boot directory and set the bootloader ID. Mount the ESP partition to e.g. /boot or /boot/efi and in the following change esp to that mount point (usually /boot):

# grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=grub

I have no idea on what to mount and where, beacuse the ESP doesn't look as described in the wiki

Offline

#6 2016-05-16 10:36:12

surfatwork
Member
Registered: 2012-01-05
Posts: 137

Re: Move grub from MBR to ESP

^What Saint said^
try refind.
first, sda1 is ntfs. this is wrong. The ESP needs to be fat32. and it can be any size (upto fat32 limits).

1. boot with any live image.
2. format sda1 as fat32 and set the appropriate flags (see the wiki)
3. mount /dev/sda1 and make a EFI folder inside.
4. Copy the refind files into it
5. Point your laptop UEFI to refind_x64.efi, if it doesnt find it automatically
Refind should find your win and other OSes just fine. If not, see if the configuration needs any tweaking.

Someday, we will get rid of grub.....

Last edited by surfatwork (2016-05-16 10:40:40)

Offline

#7 2016-05-16 12:11:00

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: Move grub from MBR to ESP

I don't see an EFI boot partition in your lsblk output...


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#8 2016-05-16 13:44:05

satanselbow
Member
Registered: 2011-06-15
Posts: 538

Re: Move grub from MBR to ESP

At this juncture it may be wise to set about saving your W10 installation if you have no data to rescue from your fresh Arch... did you convert your drive to GPT when W10 was installed?

Offline

#9 2016-05-16 20:04:33

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,680
Website

Re: Move grub from MBR to ESP

leonixyz wrote:

1) Is actually /dev/sda1 an ESP?

No, it is not.

leonixyz wrote:

2) What should i do to be able to boot both arch and windows10?

Try this:

# pacman -S os-prober
# grub-mkconfig -o /boot/grub/grub.cfg

If this doesn't work, please provide complete details of your installation process.

Offline

Board footer

Powered by FluxBB