summaryrefslogtreecommitdiffstats
path: root/client/engine
diff options
context:
space:
mode:
authorIrina Gómez <irinagomez@us.es>2019-05-13 10:14:38 +0200
committerIrina Gómez <irinagomez@us.es>2019-05-13 10:14:38 +0200
commit04b15943a1c2000616da87528418cd96f28e70ff (patch)
tree746224bbaecbd4701a81ddbc4970f01d2b17f957 /client/engine
parentb845aabe00bd8f91093c654aacee96407897d26c (diff)
parentfec3e4f55169609aa6a13b9f29272113fe9ffa0c (diff)
Merge branch 'devel' into uefi (fast-forward)
Diffstat (limited to 'client/engine')
-rwxr-xr-xclient/engine/Cache.lib15
-rwxr-xr-xclient/engine/Disk.lib29
2 files changed, 33 insertions, 11 deletions
diff --git a/client/engine/Cache.lib b/client/engine/Cache.lib
index 0e7f51ef..bda02951 100755
--- a/client/engine/Cache.lib
+++ b/client/engine/Cache.lib
@@ -4,7 +4,7 @@
#@brief Librería o clase Cache
#@class Cache
#@brief Funciones para gestión de la caché local de disco.
-#@version 1.1.0
+#@version 1.1.1
#@warning License: GNU GPLv3+
#*/
@@ -44,7 +44,8 @@
function ogCreateCache ()
{
# Variables locales.
-local FINDCACHE IOSIZE NDSK SIZECACHE PART DISK START END ENDPREVPART SIZE MINSIZE MAXSIZE PTTYPE ID TMPFILE
+local FINDCACHE IOSIZE NDSK SIZECACHE PART DISK START END ENDPREVPART SIZE MINSIZE MAXSIZE
+local PTTYPE ID TMPFILE NVME_PREFIX
# Si se solicita, mostrar ayuda.
if [ "$*" == "help" ]; then
ogHelp "$FUNCNAME" "$FUNCNAME [int_ndisk [int_npart]] int_partsize" \
@@ -81,6 +82,14 @@ esac
TMPFILE=/tmp/sfdisk$$
DISK=$(ogDiskToDev $NDSK) || return $?
+
+ # PATCH Para discos nvme la particion debe ser p1, p2, etc...en lugar de 1,2, sino falla sfdisk
+NVME_PREFIX=""
+if [[ $DISK == *"nvme"* ]]; then
+ NVME_PREFIX="p"
+fi
+
+
END=$[$(ogGetLastSector $NDSK 2>/dev/null)] # Sector final del disco.
SIZE=$[$SIZECACHE*2] # Tamaño en sectores de 512 B.
# Inicio partición cache según el disco tenga sectores de 4k o menores
@@ -127,7 +136,7 @@ case "$(ogGetPartitionTableType $NDSK)" in
# Salvamos la configuración de las particiones e incluimos la cache.
trap "rm -f $TMPFILE" 1 2 3 9 15
sfdisk --dump $DISK | grep -v $DISK$PART > $TMPFILE
- echo "$DISK$PART : start= $START, size= $SIZE, Id=$ID" >> $TMPFILE
+ echo "$DISK$NVME_PREFIX$PART : start= $START, size= $SIZE, Id=$ID" >> $TMPFILE
# Ordenamos las líneas de los dispositivos
UNIT=$(grep unit $TMPFILE)
grep ^/dev $TMPFILE|sort -o $TMPFILE
diff --git a/client/engine/Disk.lib b/client/engine/Disk.lib
index 050438d7..f7535370 100755
--- a/client/engine/Disk.lib
+++ b/client/engine/Disk.lib
@@ -4,7 +4,7 @@
#@brief Librería o clase Disk
#@class Disk
#@brief Funciones para gestión de discos y particiones.
-#@version 1.1.0
+#@version 1.1.1
#@warning License: GNU GPLv3+
#*/
@@ -47,7 +47,8 @@ timeout -k 5s -s KILL 3s $(which parted) "$@"
function ogCreatePartitions ()
{
# Variables locales.
-local ND DISK PTTYPE PART SECTORS START SIZE TYPE CACHEPART IODISCO IOSIZE CACHESIZE EXTSTART EXTSIZE tmpsfdisk
+local ND DISK PTTYPE PART SECTORS START SIZE TYPE CACHEPART IODISCO IOSIZE CACHESIZE
+local EXTSTART EXTSIZE NVME_PREFIX tmpsfdisk
# Si se solicita, mostrar ayuda.
if [ "$*" == "help" ]; then
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk str_parttype:int_partsize ..." \
@@ -94,12 +95,18 @@ trap "rm -f $tmpsfdisk" 1 2 3 9 15
echo "unit: sectors" >$tmpsfdisk
echo >>$tmpsfdisk
+NVME_PREFIX=""
+if [[ $DISK == *"nvme"* ]]; then
+ NVME_PREFIX="p"
+fi
+
+
# Generar fichero de entrada para "sfdisk" con las particiones.
shift
while [ $# -gt 0 ]; do
# Conservar los datos de la partición de caché.
if [ "$ND $PART" == "$CACHEPART" -a -n "$CACHESIZE" ]; then
- echo "$DISK$PART : start=$[SECTORS+1], size=$CACHESIZE, Id=ca" >>$tmpsfdisk
+ echo "$DISK$NVME_PREFIX$PART : start=$[SECTORS+1], size=$CACHESIZE, Id=ca" >>$tmpsfdisk
PART=$[PART+1]
fi
# Leer formato de cada parámetro - Tipo:Tamaño
@@ -125,7 +132,7 @@ while [ $# -gt 0 ]; do
SECTORS=$[EXTSTART+EXTSIZE]
fi
# Generar datos para la partición.
- echo "$DISK$PART : start=$START, size=$SIZE, Id=$ID" >>$tmpsfdisk
+ echo "$DISK$NVME_PREFIX$PART : start=$START, size=$SIZE, Id=$ID" >>$tmpsfdisk
# Error si se supera el nº total de sectores.
START=$[START+SIZE]
if [ "$IOSIZE" == "4096" -a $PART -gt 4 ]; then
@@ -138,9 +145,9 @@ done
# Si no se indican las 4 particiones primarias, definirlas como vacías, conservando la partición de caché.
while [ $PART -le 4 ]; do
if [ "$ND $PART" == "$CACHEPART" -a -n "$CACHESIZE" ]; then
- echo "$DISK$PART : start=$[SECTORS+1], size=$CACHESIZE, Id=ca" >>$tmpsfdisk
+ echo "$DISK$NVME_PREFIX$PART : start=$[SECTORS+1], size=$CACHESIZE, Id=ca" >>$tmpsfdisk
else
- echo "$DISK$PART : start=0, size=0, Id=0" >>$tmpsfdisk
+ echo "$DISK$NVME_PREFIX$PART : start=0, size=0, Id=0" >>$tmpsfdisk
fi
PART=$[PART+1]
done
@@ -396,7 +403,7 @@ esac
function ogDevToDisk ()
{
# Variables locales.
-local CACHEFILE DEV PART d n
+local CACHEFILE DEV PART NVME_PREFIX d n
# Si se solicita, mostrar ayuda.
if [ "$*" == "help" ]; then
ogHelp "$FUNCNAME" "$FUNCNAME path_device | LABEL=str_label | UUID=str_uuid" \
@@ -431,7 +438,13 @@ fi
# Si no se encuentra, procesa todos los discos para devolver su nº de orden y de partición.
n=1
for d in $(ogDiskToDev); do
- [ -n "$(echo $DEV | grep $d)" ] && echo "$n ${DEV#$d}" && return
+NVME_PREFIX=""
+if [[ $d == *"nvme"* ]]; then
+ NVME_PREFIX="p"
+fi
+
+
+ [ -n "$(echo $DEV | grep $d)" ] && echo "$n ${DEV#$d$NVME_PREFIX}" && return
n=$[n+1]
done
ogRaiseError $OG_ERR_NOTFOUND "$1"