summaryrefslogtreecommitdiffstats
path: root/client/engine
diff options
context:
space:
mode:
authorJuan Manuel Bardallo <juanmanuel.bardallo@sic.uhu.es>2019-03-26 12:04:01 +0100
committerRamón M. Gómez <ramongomez@us.es>2019-03-27 07:50:42 +0100
commit30fa5b494415c05d135f7b18e6eb44a48dbe2feb (patch)
tree239fac362ffa9973abf40a8ab0ad0dde8e009b1c /client/engine
parentce1aa0b33271d3cad06ee52004f011d00195aebc (diff)
#906 Operations with partitions and images support NVMe
Diffstat (limited to 'client/engine')
-rwxr-xr-xclient/engine/Cache.lib10
-rwxr-xr-xclient/engine/Disk.lib22
2 files changed, 26 insertions, 6 deletions
diff --git a/client/engine/Cache.lib b/client/engine/Cache.lib
index 0e7f51ef..8565fe1c 100755
--- a/client/engine/Cache.lib
+++ b/client/engine/Cache.lib
@@ -81,6 +81,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 +135,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 ac7aab5f..3ea01bbd 100755
--- a/client/engine/Disk.lib
+++ b/client/engine/Disk.lib
@@ -94,12 +94,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 +131,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 +144,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
@@ -431,7 +437,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"