From e9601e1f70519e9e380e6198e29df2f695ffbd94 Mon Sep 17 00:00:00 2001 From: Irina Gómez Date: Mon, 4 Feb 2019 11:34:26 +0100 Subject: #802 #889 #890 ogGrubInstallPartitions, ogGrubInstallMbr y ogRestoreEfiBootLoader: Format EFI partition if it is not. ogGetEsp: Detecting the EFI partition does not require VFAT filesystem. --- client/engine/Boot.lib | 12 ++++++++++-- client/engine/Disk.lib | 7 ++++--- client/engine/UEFI.lib | 6 +++++- 3 files changed, 19 insertions(+), 6 deletions(-) (limited to 'client') diff --git a/client/engine/Boot.lib b/client/engine/Boot.lib index 09337657..9c6d9990 100755 --- a/client/engine/Boot.lib +++ b/client/engine/Boot.lib @@ -821,7 +821,11 @@ PREFIXSECONDSTAGE="/boot/grubMBR" if ogIsEfiActive; then read EFIDISK EFIPART <<< $(ogGetEsp) # Comprobamos que exista ESP y el directorio para ubuntu - EFISECONDSTAGE=$(ogMount $EFIDISK $EFIPART) || ogRaiseError $OG_ERR_PARTITION "ESP" || return $? + EFISECONDSTAGE=$(ogMount $EFIDISK $EFIPART) + if [ $? -ne 0 ]; then + ogFormat $EFIDISK $EFIPART FAT32 + EFISECONDSTAGE=$(ogMount $EFIDISK $EFIPART) || ogRaiseError $OG_ERR_PARTITION "ESP" || return $? + fi EFISUBDIR=$(printf "Part-%02d-%02d" $DISK $PART) [ -d ${EFISECONDSTAGE}/EFI/$EFISUBDIR ] || mkdir -p ${EFISECONDSTAGE}/EFI/$EFISUBDIR EFIOPTGRUB=" --target x86_64-efi --efi-directory=${EFISECONDSTAGE}/EFI/$EFISUBDIR " @@ -943,7 +947,11 @@ PREFIXSECONDSTAGE="/boot/grubPARTITION" if ogIsEfiActive; then read EFIDISK EFIPART <<< $(ogGetEsp) # Comprobamos que exista ESP y el directorio para ubuntu - EFISECONDSTAGE=$(ogMount $EFIDISK $EFIPART) || ogRaiseError $OG_ERR_PARTITION "ESP" || return $? + EFISECONDSTAGE=$(ogMount $EFIDISK $EFIPART) + if [ $? -ne 0 ]; then + ogFormat $EFIDISK $EFIPART FAT32 + EFISECONDSTAGE=$(ogMount $EFIDISK $EFIPART) || ogRaiseError $OG_ERR_PARTITION "ESP" || return $? + fi EFISUBDIR=$(printf "Part-%02d-%02d" $DISK $PART) [ -d ${EFISECONDSTAGE}/EFI/$EFISUBDIR ] || mkdir -p ${EFISECONDSTAGE}/EFI/$EFISUBDIR EFIOPTGRUB=" --target x86_64-efi --efi-directory=${EFISECONDSTAGE}/EFI/$EFISUBDIR " diff --git a/client/engine/Disk.lib b/client/engine/Disk.lib index 50ce04e8..050438d7 100755 --- a/client/engine/Disk.lib +++ b/client/engine/Disk.lib @@ -258,7 +258,7 @@ ogCreatePartitionTable $ND # Definir particiones y notificar al kernel. # Borramos primero las particiones y luego creamos las nuevas sgdisk $DELOPTIONS $OPTIONS $DISK 2>/dev/null && partprobe $DISK -[ -n "$CACHESIZE" ] && ogMountCache 2>/dev/null +[ -n "$CACHESIZE" ] && ogMountCache 2>/dev/null || return 0 } @@ -684,8 +684,9 @@ echo $TYPE function ogGetEsp () { local PART d -for d in $(blkid -t TYPE=vfat -o device); do - PART="$(ogDevToDisk $d)" +for d in $(blkid -o device|sort); do + # Previene error para /dev/loop0 + PART="$(ogDevToDisk $d 2>/dev/null)" || continue if [ "$(ogGetPartitionId $PART)" == "$(ogTypeToId EFI GPT)" ]; then echo $PART break diff --git a/client/engine/UEFI.lib b/client/engine/UEFI.lib index 7a1afb6d..84cfb65a 100644 --- a/client/engine/UEFI.lib +++ b/client/engine/UEFI.lib @@ -159,7 +159,11 @@ fi # Comprobamos que exista partición de sistema y la ESP MNTDIR=$(ogMount $1 $2) || ogRaiseError $OG_ERR_PARTITION "$DISK $PART" || return $? -EFIDIR=$(ogMount $(ogGetEsp)) || ogRaiseError $OG_ERR_PARTITION "ESP" || return $? +EFIDIR=$(ogMount $(ogGetEsp)) +if [ "$EFIDIR" == "" ]; then + ogFormat $(ogGetEsp) FAT32 + EFIDIR=$(ogMount $(ogGetEsp)) || ogRaiseError $OG_ERR_PARTITION "ESP" || return $? +fi # Comprobamos que exista el cargador #BOOTLABEL=$(printf "Part-%02d-%02d" $1 $2) -- cgit v1.2.3-18-g5258