[9f29ba6] | 1 | #!/bin/bash |
---|
| 2 | #/** |
---|
| 3 | #@file Disk.lib |
---|
[9f57de01] | 4 | #@brief Librería o clase Disk |
---|
[9f29ba6] | 5 | #@class Disk |
---|
[2e15649] | 6 | #@brief Funciones para gestión de discos y particiones. |
---|
[afc1e74] | 7 | #@version 1.0.5 |
---|
[9f29ba6] | 8 | #@warning License: GNU GPLv3+ |
---|
| 9 | #*/ |
---|
| 10 | |
---|
[5dbb046] | 11 | |
---|
[be48687] | 12 | # Función ficticia para lanzar parted con timeout, evitando cuelgues del programa. |
---|
| 13 | function parted () |
---|
| 14 | { |
---|
| 15 | timeout -k 5s -s KILL 3s $(which parted) "$@" |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | |
---|
[5dbb046] | 19 | #/** |
---|
[42669ebf] | 20 | # ogCreatePartitions int_ndisk str_parttype:int_partsize ... |
---|
[b094c59] | 21 | #@brief Define el conjunto de particiones de un disco. |
---|
[42669ebf] | 22 | #@param int_ndisk nº de orden del disco |
---|
| 23 | #@param str_parttype mnemónico del tipo de partición |
---|
| 24 | #@param int_partsize tamaño de la partición (en KB) |
---|
[73c8417] | 25 | #@return (nada, por determinar) |
---|
[73488c9] | 26 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 27 | #@exception OG_ERR_NOTFOUND disco o partición no detectado (no es un dispositivo). |
---|
| 28 | #@exception OG_ERR_PARTITION error en partición o en tabla de particiones. |
---|
[73c8417] | 29 | #@attention El nº de partición se indica por el orden de los párametros \c parttype:partsize |
---|
| 30 | #@attention Pueden definirse particiones vacías de tipo \c EMPTY |
---|
[16f7627] | 31 | #@attention No puede definirse partición de cache y no se modifica si existe. |
---|
[73c8417] | 32 | #@note Requisitos: sfdisk, parted, partprobe, awk |
---|
| 33 | #@todo Definir atributos (arranque, oculta) y tamaños en MB, GB, etc. |
---|
[afc1e74] | 34 | #@version 0.9 - Primera versión para OpenGnSys |
---|
[73c8417] | 35 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 36 | #@date 2009/09/09 |
---|
[bc7dfe7] | 37 | #@version 0.9.1 - Corrección del redondeo del tamaño del disco. |
---|
[4b45aff] | 38 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 39 | #@date 2010/03/09 |
---|
[73488c9] | 40 | #@version 1.0.4 - Llamada a función específica para tablas GPT. |
---|
| 41 | #@author Universidad de Huelva |
---|
| 42 | #@date 2012/03/30 |
---|
[1e7eaab] | 43 | #*/ ## |
---|
[42669ebf] | 44 | function ogCreatePartitions () |
---|
| 45 | { |
---|
[73c8417] | 46 | # Variables locales. |
---|
[0cea822] | 47 | local ND DISK PTTYPE PART SECTORS START SIZE TYPE CACHEPART CACHESIZE EXTSTART EXTSIZE tmpsfdisk |
---|
[1e7eaab] | 48 | # Si se solicita, mostrar ayuda. |
---|
[1a7130a] | 49 | if [ "$*" == "help" ]; then |
---|
[73c8417] | 50 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk str_parttype:int_partsize ..." \ |
---|
| 51 | "$FUNCNAME 1 NTFS:10000000 EXT3:5000000 LINUX-SWAP:1000000" |
---|
| 52 | return |
---|
| 53 | fi |
---|
[a73649d] | 54 | # Error si no se reciben al menos 2 parámetros. |
---|
[55ad138c] | 55 | [ $# -ge 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[73c8417] | 56 | |
---|
[4b45aff] | 57 | # Nº total de sectores, para evitar desbordamiento (evitar redondeo). |
---|
[6d3f526] | 58 | ND="$1" |
---|
| 59 | DISK=$(ogDiskToDev "$ND") || return $? |
---|
[73488c9] | 60 | PTTYPE=$(ogGetPartitionTableType $1) |
---|
[a06ac2d] | 61 | PTTYPE=${PTTYPE:-"MSDOS"} # Por defecto para discos vacíos. |
---|
[73488c9] | 62 | case "$PTTYPE" in |
---|
| 63 | GPT) ogCreateGptPartitions "$@" |
---|
| 64 | return $? ;; |
---|
[0cea822] | 65 | MSDOS) ;; |
---|
[73488c9] | 66 | *) ogRaiseError $OG_ERR_PARTITION "$PTTYPE" |
---|
| 67 | return $? ;; |
---|
| 68 | esac |
---|
[0cea822] | 69 | SECTORS=$(ogGetLastSector $1) |
---|
[16f7627] | 70 | # Se recalcula el nº de sectores del disco 1, si existe partición de caché. |
---|
[d7c35ad] | 71 | CACHEPART=$(ogFindCache 2>/dev/null) |
---|
[6d3f526] | 72 | [ "$ND" = "${CACHEPART% *}" ] && CACHESIZE=$(ogGetCacheSize 2>/dev/null | awk '{print $0*2}') |
---|
[d7c35ad] | 73 | [ -n "$CACHESIZE" ] && SECTORS=$[SECTORS-CACHESIZE] |
---|
[16f7627] | 74 | # Sector de inicio (la partición 1 empieza en el sector 63). |
---|
[73c8417] | 75 | START=63 |
---|
| 76 | PART=1 |
---|
| 77 | |
---|
[b094c59] | 78 | # Fichero temporal de entrada para "sfdisk" |
---|
[73c8417] | 79 | tmpsfdisk=/tmp/sfdisk$$ |
---|
| 80 | trap "rm -f $tmpsfdisk" 1 2 3 9 15 |
---|
| 81 | |
---|
| 82 | echo "unit: sectors" >$tmpsfdisk |
---|
| 83 | echo >>$tmpsfdisk |
---|
| 84 | |
---|
[42669ebf] | 85 | # Generar fichero de entrada para "sfdisk" con las particiones. |
---|
[16f7627] | 86 | shift |
---|
[73c8417] | 87 | while [ $# -gt 0 ]; do |
---|
[16f7627] | 88 | # Conservar los datos de la partición de caché. |
---|
[6d3f526] | 89 | if [ "$ND $PART" == "$CACHEPART" -a -n "$CACHESIZE" ]; then |
---|
[16f7627] | 90 | echo "$DISK$PART : start=$[SECTORS+1], size=$CACHESIZE, Id=ca" >>$tmpsfdisk |
---|
| 91 | PART=$[PART+1] |
---|
| 92 | fi |
---|
[42669ebf] | 93 | # Leer formato de cada parámetro - Tipo:Tamaño |
---|
[73c8417] | 94 | TYPE="${1%%:*}" |
---|
| 95 | SIZE="${1#*:}" |
---|
[42e31fd] | 96 | # Obtener identificador de tipo de partición válido. |
---|
[5af5d5f] | 97 | ID=$(ogTypeToId "$TYPE" MSDOS) |
---|
[42e31fd] | 98 | [ "$TYPE" != "CACHE" -a -n "$ID" ] || ogRaiseError $OG_ERR_PARTITION "$TYPE" || return $? |
---|
| 99 | # Comprobar tamaño numérico y convertir en sectores de 512 B. |
---|
| 100 | [[ "$SIZE" == *([0-9]) ]] || ogRaiseError $OG_ERR_FORMAT "$SIZE" || return $? |
---|
| 101 | SIZE=$[SIZE*2] |
---|
[42669ebf] | 102 | # Comprobar si la partición es extendida. |
---|
| 103 | if [ $ID = 5 ]; then |
---|
[6bde19d] | 104 | [ $PART -le 4 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[42669ebf] | 105 | EXTSTART=$START |
---|
| 106 | EXTSIZE=$SIZE |
---|
| 107 | fi |
---|
[1e7eaab] | 108 | # Incluir particiones lógicas dentro de la partición extendida. |
---|
[73c8417] | 109 | if [ $PART = 5 ]; then |
---|
[6bde19d] | 110 | [ -n "$EXTSTART" ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[73c8417] | 111 | START=$EXTSTART |
---|
| 112 | SECTORS=$[EXTSTART+EXTSIZE] |
---|
| 113 | fi |
---|
[1e7eaab] | 114 | # Generar datos para la partición. |
---|
[73c8417] | 115 | echo "$DISK$PART : start=$START, size=$SIZE, Id=$ID" >>$tmpsfdisk |
---|
[42669ebf] | 116 | # Error si se supera el nº total de sectores. |
---|
[73c8417] | 117 | START=$[START+SIZE] |
---|
[16f7627] | 118 | [ $START -le $SECTORS ] || ogRaiseError $OG_ERR_FORMAT "$[START/2] > $[SECTORS/2]" || return $? |
---|
[73c8417] | 119 | PART=$[PART+1] |
---|
| 120 | shift |
---|
| 121 | done |
---|
[16f7627] | 122 | # Si no se indican las 4 particiones primarias, definirlas como vacías, conservando la partición de caché. |
---|
[73c8417] | 123 | while [ $PART -le 4 ]; do |
---|
[6d3f526] | 124 | if [ "$ND $PART" == "$CACHEPART" -a -n "$CACHESIZE" ]; then |
---|
[16f7627] | 125 | echo "$DISK$PART : start=$[SECTORS+1], size=$CACHESIZE, Id=ca" >>$tmpsfdisk |
---|
| 126 | else |
---|
| 127 | echo "$DISK$PART : start=0, size=0, Id=0" >>$tmpsfdisk |
---|
| 128 | fi |
---|
[73c8417] | 129 | PART=$[PART+1] |
---|
| 130 | done |
---|
[b094c59] | 131 | # Si se define partición extendida sin lógicas, crear particion 5 vacía. |
---|
[73c8417] | 132 | if [ $PART = 5 -a -n "$EXTSTART" ]; then |
---|
| 133 | echo "${DISK}5 : start=$EXTSTART, size=$EXTSIZE, Id=0" >>$tmpsfdisk |
---|
| 134 | fi |
---|
| 135 | |
---|
[7510561] | 136 | # Desmontar los sistemas de archivos del disco antes de realizar las operaciones. |
---|
[6d3f526] | 137 | ogUnmountAll $ND 2>/dev/null |
---|
| 138 | [ -n "$CACHESIZE" ] && ogUnmountCache 2>/dev/null |
---|
[7510561] | 139 | |
---|
[73c8417] | 140 | # Si la tabla de particiones no es valida, volver a generarla. |
---|
[0cea822] | 141 | ogCreatePartitionTable $ND |
---|
[1e7eaab] | 142 | # Definir particiones y notificar al kernel. |
---|
[c6087b9] | 143 | sfdisk -f $DISK < $tmpsfdisk 2>/dev/null && partprobe $DISK |
---|
[73c8417] | 144 | rm -f $tmpsfdisk |
---|
[6d3f526] | 145 | [ -n "$CACHESIZE" ] && ogMountCache 2>/dev/null |
---|
[73c8417] | 146 | } |
---|
| 147 | |
---|
| 148 | |
---|
| 149 | #/** |
---|
[73488c9] | 150 | # ogCreateGptPartitions int_ndisk str_parttype:int_partsize ... |
---|
| 151 | #@brief Define el conjunto de particiones de un disco GPT |
---|
| 152 | #@param int_ndisk nº de orden del disco |
---|
| 153 | #@param str_parttype mnemónico del tipo de partición |
---|
| 154 | #@param int_partsize tamaño de la partición (en KB) |
---|
| 155 | #@return (nada, por determinar) |
---|
| 156 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 157 | #@exception OG_ERR_NOTFOUND disco o partición no detectado (no es un dispositivo). |
---|
| 158 | #@exception OG_ERR_PARTITION error en partición o en tabla de particiones. |
---|
| 159 | #@attention El nº de partición se indica por el orden de los párametros \c parttype:partsize |
---|
| 160 | #@attention Pueden definirse particiones vacías de tipo \c EMPTY |
---|
| 161 | #@attention No puede definirse partición de caché y no se modifica si existe. |
---|
| 162 | #@note Requisitos: sfdisk, parted, partprobe, awk |
---|
| 163 | #@todo Definir atributos (arranque, oculta) y tamaños en MB, GB, etc. |
---|
| 164 | #@version 1.0.4 - Primera versión para OpenGnSys |
---|
| 165 | #@author Universidad de Huelva |
---|
| 166 | #@date 2012/03/30 |
---|
| 167 | #*/ ## |
---|
| 168 | function ogCreateGptPartitions () |
---|
| 169 | { |
---|
| 170 | # Variables locales. |
---|
[0cea822] | 171 | local ND DISK PART SECTORS ALIGN START SIZE TYPE CACHEPART CACHESIZE DELOPTIONS OPTIONS |
---|
[73488c9] | 172 | # Si se solicita, mostrar ayuda. |
---|
| 173 | if [ "$*" == "help" ]; then |
---|
| 174 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk str_parttype:int_partsize ..." \ |
---|
| 175 | "$FUNCNAME 1 NTFS:10000000 EXT3:5000000 LINUX-SWAP:1000000" |
---|
| 176 | return |
---|
| 177 | fi |
---|
| 178 | # Error si no se reciben menos de 2 parámetros. |
---|
| 179 | [ $# -ge 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 180 | |
---|
| 181 | # Nº total de sectores, para evitar desbordamiento (evitar redondeo). |
---|
| 182 | ND="$1" |
---|
| 183 | DISK=$(ogDiskToDev "$ND") || return $? |
---|
| 184 | # Se calcula el ultimo sector del disco (total de sectores usables) |
---|
[0cea822] | 185 | SECTORS=$(ogGetLastSector $1) |
---|
| 186 | [ "$ND" = "${CACHEPART% *}" ] && CACHESIZE=$(ogGetCacheSize 2>/dev/null | awk '{print $0*2}') |
---|
| 187 | [ -n "$CACHESIZE" ] && SECTORS=$[SECTORS-CACHESIZE] |
---|
| 188 | # Si el disco es GPT empieza en el sector 2048 por defecto, pero podria cambiarse |
---|
[499bf46] | 189 | ALIGN=$(sgdisk -D $DISK 2>/dev/null) |
---|
[0cea822] | 190 | START=$ALIGN |
---|
| 191 | PART=1 |
---|
[73488c9] | 192 | |
---|
[0cea822] | 193 | # Leer parámetros con definición de particionado. |
---|
| 194 | shift |
---|
| 195 | |
---|
| 196 | while [ $# -gt 0 ]; do |
---|
| 197 | # Si PART es la cache, nos la saltamos y seguimos con el siguiente numero para conservar los datos de la partición de caché. |
---|
| 198 | if [ "$ND $PART" == "$CACHEPART" -a -n "$CACHESIZE" ]; then |
---|
| 199 | PART=$[PART+1] |
---|
| 200 | fi |
---|
| 201 | # Leer formato de cada parámetro - Tipo:Tamaño |
---|
| 202 | TYPE="${1%%:*}" |
---|
| 203 | SIZE="${1#*:}" |
---|
| 204 | # Error si la partición es extendida (no válida en discos GPT). |
---|
[499bf46] | 205 | if [ "$TYPE" == "EXTENDED" ]; then |
---|
| 206 | ogRaiseError $OG_ERR_PARTITION "EXTENDED" |
---|
| 207 | return $? |
---|
| 208 | fi |
---|
[0cea822] | 209 | # Comprobar si existe la particion actual, capturamos su tamaño para ver si cambio o no |
---|
[499bf46] | 210 | PARTSIZE=$(ogGetPartitionSize $ND $PART 2>/dev/null) |
---|
[0cea822] | 211 | # En sgdisk no se pueden redimensionar las particiones, es necesario borrarlas y volver a crealas |
---|
| 212 | [ $PARTSIZE ] && DELOPTIONS="$DELOPTIONS -d$PART" |
---|
| 213 | # Creamos la particion |
---|
| 214 | # Obtener identificador de tipo de partición válido. |
---|
[5af5d5f] | 215 | ID=$(ogTypeToId "$TYPE" GPT) |
---|
[0cea822] | 216 | [ "$TYPE" != "CACHE" -a -n "$ID" ] || ogRaiseError $OG_ERR_PARTITION "$TYPE" || return $? |
---|
| 217 | # Comprobar tamaño numérico y convertir en sectores de 512 B. |
---|
| 218 | [[ "$SIZE" == *([0-9]) ]] || ogRaiseError $OG_ERR_FORMAT "$SIZE" || return $? |
---|
| 219 | SIZE=$[SIZE*2] |
---|
| 220 | # SIZE debe ser múltiplo de ALIGN, si no gdisk lo mueve automáticamente. |
---|
| 221 | DIV=$[$SIZE/$ALIGN] |
---|
| 222 | SIZE=$[$DIV*$ALIGN] |
---|
| 223 | # En el caso de que la partición sea EMPTY no se crea nada |
---|
| 224 | if [ "$TYPE" != "EMPTY" ]; then |
---|
| 225 | OPTIONS="$OPTIONS -n$PART:$START:+$SIZE -t$PART:$ID " |
---|
| 226 | fi |
---|
| 227 | START=$[START+SIZE] |
---|
| 228 | # Error si se supera el nº total de sectores. |
---|
| 229 | [ $START -le $SECTORS ] || ogRaiseError $OG_ERR_FORMAT "$[START/2] > $[SECTORS/2]" || return $? |
---|
| 230 | PART=$[PART+1] |
---|
| 231 | shift |
---|
| 232 | done |
---|
| 233 | |
---|
| 234 | # Desmontar los sistemas de archivos del disco antes de realizar las operaciones. |
---|
| 235 | ogUnmountAll $ND 2>/dev/null |
---|
| 236 | [ -n "$CACHESIZE" ] && ogUnmountCache 2>/dev/null |
---|
| 237 | |
---|
| 238 | # Si la tabla de particiones no es valida, volver a generarla. |
---|
| 239 | ogCreatePartitionTable $ND |
---|
| 240 | # Definir particiones y notificar al kernel. |
---|
| 241 | # Borramos primero las particiones y luego creamos las nuevas |
---|
[499bf46] | 242 | sgdisk $DELOPTIONS $OPTIONS $DISK 2>/dev/null && partprobe $DISK |
---|
[0cea822] | 243 | [ -n "$CACHESIZE" ] && ogMountCache 2>/dev/null |
---|
[73488c9] | 244 | } |
---|
| 245 | |
---|
| 246 | |
---|
| 247 | #/** |
---|
[942dfd7] | 248 | # ogCreatePartitionTable int_ndisk [str_tabletype] |
---|
[f2c8049] | 249 | #@brief Genera una tabla de particiones en caso de que no sea valida, si es valida no hace nada. |
---|
[942dfd7] | 250 | #@param int_ndisk nº de orden del disco |
---|
| 251 | #@param str_tabletype tipo de tabla de particiones (opcional) |
---|
| 252 | #@return (por determinar) |
---|
| 253 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
[f2c8049] | 254 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
---|
[942dfd7] | 255 | #@note tabletype: { MSDOS, GPT } |
---|
| 256 | #@note Requisitos: sfdisk, sgdisk |
---|
[afc1e74] | 257 | #@version 1.0.4 - Primera versión compatible con OpenGnSys. |
---|
[942dfd7] | 258 | #@author Universidad de Huelva |
---|
| 259 | #@date 2012/03/06 |
---|
| 260 | #*/ ## |
---|
[6e390b1] | 261 | function ogCreatePartitionTable () |
---|
[942dfd7] | 262 | { |
---|
| 263 | # Variables locales. |
---|
| 264 | local DISK PTTYPE CREATE CREATEPTT |
---|
| 265 | |
---|
| 266 | # Si se solicita, mostrar ayuda. |
---|
| 267 | if [ "$*" == "help" ]; then |
---|
| 268 | ogHelp "$FUNCNAME int_ndisk [str_partype]" \ |
---|
| 269 | "$FUNCNAME 1 GPT" "$FUNCNAME 1" |
---|
| 270 | return |
---|
| 271 | fi |
---|
| 272 | # Error si no se reciben 1 o 2 parámetros. |
---|
| 273 | case $# in |
---|
[f2c8049] | 274 | 1) CREATEPTT="" ;; |
---|
| 275 | 2) CREATEPTT="$2" ;; |
---|
| 276 | *) ogRaiseError $OG_ERR_FORMAT |
---|
| 277 | return $? ;; |
---|
[942dfd7] | 278 | esac |
---|
| 279 | |
---|
| 280 | # Capturamos el tipo de tabla de particiones actual |
---|
| 281 | DISK=$(ogDiskToDev $1) || return $? |
---|
| 282 | PTTYPE=$(ogGetPartitionTableType $1) |
---|
[a06ac2d] | 283 | PTTYPE=${PTTYPE:-"MSDOS"} # Por defecto para discos vacíos. |
---|
[942dfd7] | 284 | CREATEPTT=${CREATEPTT:-"$PTTYPE"} |
---|
| 285 | |
---|
[a06ac2d] | 286 | # Si la tabla actual y la que se indica son iguales, se comprueba si hay que regenerarla. |
---|
[942dfd7] | 287 | if [ "$CREATEPTT" == "$PTTYPE" ]; then |
---|
| 288 | case "$PTTYPE" in |
---|
| 289 | GPT) [ ! $(sgdisk -p $DISK 2>&1 >/dev/null) ] || CREATE="GPT" ;; |
---|
| 290 | MSDOS) [ $(parted -s $DISK print >/dev/null) ] || CREATE="MSDOS" ;; |
---|
| 291 | esac |
---|
| 292 | else |
---|
| 293 | CREATE="$CREATEPTT" |
---|
| 294 | fi |
---|
| 295 | # Dependiendo del valor de CREATE, creamos la tabla de particiones en cada caso. |
---|
| 296 | case "$CREATE" in |
---|
| 297 | GPT) |
---|
| 298 | # Si es necesario crear una tabla GPT pero la actual es MSDOS |
---|
| 299 | if [ "$PTTYPE" == "MSDOS" ]; then |
---|
| 300 | sgdisk -g $DISK |
---|
| 301 | else |
---|
| 302 | echo -e "2\nw\nY\n" | gdisk $DISK |
---|
| 303 | fi |
---|
| 304 | partprobe $DISK 2>/dev/null |
---|
| 305 | ;; |
---|
| 306 | MSDOS) |
---|
| 307 | # Si es necesario crear una tabla MSDOS pero la actual es GPT |
---|
| 308 | if [ "$PTTYPE" == "GPT" ]; then |
---|
[2ba98be] | 309 | sgdisk -Z $DISK |
---|
[942dfd7] | 310 | fi |
---|
[2ba98be] | 311 | fdisk $DISK <<< "w" |
---|
[942dfd7] | 312 | partprobe $DISK 2>/dev/null |
---|
| 313 | ;; |
---|
| 314 | esac |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | |
---|
| 318 | #/** |
---|
[43892687] | 319 | # ogDeletePartitionTable ndisk |
---|
| 320 | #@brief Borra la tabla de particiones del disco. |
---|
| 321 | #@param int_ndisk nº de orden del disco |
---|
| 322 | #@return la informacion propia del fdisk |
---|
| 323 | #@version 0.1 - Integracion para OpenGnSys |
---|
| 324 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
---|
[942dfd7] | 325 | #@date 2008/10/27 |
---|
[43892687] | 326 | #@version 1.0.4 - Adaptado para su uso con discos GPT |
---|
| 327 | #@author Universidad de Huelva |
---|
| 328 | #@date 2012/03/13 |
---|
| 329 | #*/ ## |
---|
| 330 | function ogDeletePartitionTable () |
---|
| 331 | { |
---|
| 332 | # Variables locales. |
---|
| 333 | local DISK |
---|
| 334 | |
---|
| 335 | # Si se solicita, mostrar ayuda. |
---|
| 336 | if [ "$*" == "help" ]; then |
---|
| 337 | ogHelp "$FUNCNAME int_ndisk" "$FUNCNAME 1" |
---|
| 338 | return |
---|
| 339 | fi |
---|
| 340 | # Error si no se reciben 1 parámetros. |
---|
| 341 | [ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 342 | |
---|
| 343 | # Obteniendo Identificador linux del disco. |
---|
| 344 | DISK=$(ogDiskToDev $1) || return $? |
---|
| 345 | # Crear una tabla de particiones vacía. |
---|
| 346 | case "$(ogGetPartitionTableType $1)" in |
---|
| 347 | GPT) sgdisk -o $DISK ;; |
---|
| 348 | MSDOS) echo -ne "o\nw" | fdisk $DISK ;; |
---|
| 349 | esac |
---|
| 350 | } |
---|
| 351 | |
---|
| 352 | |
---|
| 353 | #/** |
---|
[42669ebf] | 354 | # ogDevToDisk path_device |
---|
[5dbb046] | 355 | #@brief Devuelve el nº de orden de dicso (y partición) correspondiente al nombre de fichero de dispositivo. |
---|
[42669ebf] | 356 | #@param path_device Camino del fichero de dispositivo. |
---|
| 357 | #@return int_ndisk (para dispositivo de disco) |
---|
| 358 | #@return int_ndisk int_npartition (para dispositivo de partición). |
---|
[5dbb046] | 359 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 360 | #@exception OG_ERR_NOTFOUND Dispositivo no detectado. |
---|
| 361 | #@note Requisitos: awk |
---|
[985bef0] | 362 | #@version 0.1 - Integracion para Opengnsys - EAC: DiskEAC() en ATA.lib |
---|
| 363 | #@author Antonio J. Doblas Viso, Universidad de Malaga |
---|
| 364 | #@date 2008/10/27 |
---|
[afc1e74] | 365 | #@version 0.9 - Primera version para OpenGnSys |
---|
[5dbb046] | 366 | #@author Ramon Gomez, ETSII Universidad Sevilla |
---|
[985bef0] | 367 | #@date 2009/07/20 |
---|
[1e7eaab] | 368 | #*/ ## |
---|
[42669ebf] | 369 | function ogDevToDisk () |
---|
| 370 | { |
---|
[73c8417] | 371 | # Variables locales. |
---|
[5dbb046] | 372 | local d n |
---|
[1e7eaab] | 373 | # Si se solicita, mostrar ayuda. |
---|
[1a7130a] | 374 | if [ "$*" == "help" ]; then |
---|
[5dbb046] | 375 | ogHelp "$FUNCNAME" "$FUNCNAME path_device" \ |
---|
| 376 | "$FUNCNAME /dev/sda => 1 1" |
---|
| 377 | return |
---|
| 378 | fi |
---|
| 379 | |
---|
[1e7eaab] | 380 | # Error si no se recibe 1 parámetro. |
---|
[5dbb046] | 381 | [ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[42669ebf] | 382 | # Error si no es fichero de bloques. |
---|
[5dbb046] | 383 | [ -b "$1" ] || ogRaiseError $OG_ERR_NOTFOUND "$1" || return $? |
---|
| 384 | |
---|
[1e7eaab] | 385 | # Procesa todos los discos para devolver su nº de orden y de partición. |
---|
[5dbb046] | 386 | n=1 |
---|
| 387 | for d in $(ogDiskToDev); do |
---|
| 388 | [ -n "$(echo $1 | grep $d)" ] && echo "$n ${1#$d}" && return |
---|
| 389 | n=$[n+1] |
---|
| 390 | done |
---|
| 391 | ogRaiseError $OG_ERR_NOTFOUND "$1" |
---|
| 392 | return $OG_ERR_NOTFOUND |
---|
| 393 | } |
---|
| 394 | |
---|
| 395 | |
---|
[9f29ba6] | 396 | #/** |
---|
[42669ebf] | 397 | # ogDiskToDev [int_ndisk [int_npartition]] |
---|
[9f57de01] | 398 | #@brief Devuelve la equivalencia entre el nº de orden del dispositivo (dicso o partición) y el nombre de fichero de dispositivo correspondiente. |
---|
[42669ebf] | 399 | #@param int_ndisk nº de orden del disco |
---|
| 400 | #@param int_npartition nº de orden de la partición |
---|
[9f57de01] | 401 | #@return Para 0 parametros: Devuelve los nombres de ficheros de los dispositivos sata/ata/usb linux encontrados. |
---|
| 402 | #@return Para 1 parametros: Devuelve la ruta del disco duro indicado. |
---|
| 403 | #@return Para 2 parametros: Devuelve la ruta de la particion indicada. |
---|
| 404 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 405 | #@exception OG_ERR_NOTFOUND Dispositivo no detectado. |
---|
[2717297] | 406 | #@note Requisitos: awk, lvm |
---|
[985bef0] | 407 | #@version 0.1 - Integracion para Opengnsys - EAC: Disk() en ATA.lib; HIDRA: DetectarDiscos.sh |
---|
| 408 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 409 | #@Date 2008/06/19 |
---|
| 410 | #@author Antonio J. Doblas Viso, Universidad de Malaga |
---|
| 411 | #@date 2008/10/27 |
---|
[afc1e74] | 412 | #@version 0.9 - Primera version para OpenGnSys |
---|
[9f57de01] | 413 | #@author Ramon Gomez, ETSII Universidad Sevilla |
---|
| 414 | #@date 2009-07-20 |
---|
[19b1a2f] | 415 | #@version 1.0.5 - Comprobación correcta de parámetros para soportar valores > 9. |
---|
| 416 | #@author Ramon Gomez, ETSII Universidad Sevilla |
---|
| 417 | #@date 2013-05-07 |
---|
[1e7eaab] | 418 | #*/ ## |
---|
[42669ebf] | 419 | function ogDiskToDev () |
---|
| 420 | { |
---|
[59f9ad2] | 421 | # Variables locales |
---|
[2717297] | 422 | local ALLDISKS VOLGROUPS DISK PART |
---|
[9f29ba6] | 423 | |
---|
[1e7eaab] | 424 | # Si se solicita, mostrar ayuda. |
---|
[1a7130a] | 425 | if [ "$*" == "help" ]; then |
---|
[aae34f6] | 426 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk [int_npartition]" \ |
---|
| 427 | "$FUNCNAME => /dev/sda /dev/sdb" \ |
---|
| 428 | "$FUNCNAME 1 => /dev/sda" \ |
---|
| 429 | "$FUNCNAME 1 1 => /dev/sda1" |
---|
| 430 | return |
---|
| 431 | fi |
---|
| 432 | |
---|
[1e7eaab] | 433 | # Listar dispositivo para los discos duros (tipos: 3=hd, 8=sd). |
---|
[a5df9b9] | 434 | ALLDISKS=$(awk '($1==3 || $1==8) && $4!~/[0-9]/ {printf "/dev/%s ",$4}' /proc/partitions) |
---|
[13ccdf5] | 435 | VOLGROUPS=$(vgs -a --noheadings 2>/dev/null | awk '{printf "/dev/%s ",$1}') |
---|
[2717297] | 436 | ALLDISKS="$ALLDISKS $VOLGROUPS" |
---|
[9f29ba6] | 437 | |
---|
[1e7eaab] | 438 | # Mostrar salidas segun el número de parametros. |
---|
[9f29ba6] | 439 | case $# in |
---|
[2717297] | 440 | 0) # Muestra todos los discos, separados por espacios. |
---|
| 441 | echo $ALLDISKS |
---|
| 442 | ;; |
---|
[19b1a2f] | 443 | 1) # Error si el parámetro no es un número positivo. |
---|
| 444 | [[ "$1" =~ ^[1-9][0-9]*$ ]] || ogRaiseError $OG_ERR_FORMAT "$1" || return $? |
---|
[2717297] | 445 | DISK=$(echo "$ALLDISKS" | awk -v n=$1 '{print $n}') |
---|
| 446 | # Error si el fichero no existe. |
---|
| 447 | [ -e "$DISK" ] || ogRaiseError $OG_ERR_NOTFOUND "$1" || return $? |
---|
| 448 | echo "$DISK" |
---|
| 449 | ;; |
---|
[19b1a2f] | 450 | 2) # Error si los 2 parámetros no son números positivos. |
---|
| 451 | [[ "$1" =~ ^[1-9][0-9]*$ ]] && [[ "$2" =~ ^[1-9][0-9]*$ ]] || ogRaiseError $OG_ERR_FORMAT "$1 $2" || return $? |
---|
[2717297] | 452 | DISK=$(echo "$ALLDISKS" | awk -v n=$1 '{print $n}') |
---|
| 453 | [ -e "$DISK" ] || ogRaiseError $OG_ERR_NOTFOUND "$1" || return $? |
---|
| 454 | PART="$DISK$2" |
---|
[1e7eaab] | 455 | # Comprobar si es partición. |
---|
[2717297] | 456 | if [ -b "$PART" ]; then |
---|
| 457 | echo "$PART" |
---|
| 458 | elif [ -n "$VOLGROUPS" ]; then |
---|
[0bfbbe1] | 459 | # Comprobar si volumen lógico. /* (comentario Doxygen) |
---|
[2717297] | 460 | PART=$(lvscan -a 2>/dev/null | grep "'$DISK/" | awk -v n=$2 -F\' '{if (NR==n) print $2}') |
---|
| 461 | [ -e "$PART" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2" || return $? |
---|
[0bfbbe1] | 462 | # (comentario Doxygen) */ |
---|
[2717297] | 463 | echo "$PART" |
---|
| 464 | else |
---|
| 465 | ogRaiseError $OG_ERR_NOTFOUND "$1 $2" || return $? |
---|
| 466 | fi |
---|
| 467 | ;; |
---|
| 468 | *) # Formato erroneo. |
---|
| 469 | ogRaiseError $OG_ERR_FORMAT |
---|
[aae34f6] | 470 | return $OG_ERR_FORMAT |
---|
| 471 | ;; |
---|
[9f29ba6] | 472 | esac |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | |
---|
| 476 | #/** |
---|
[739d358] | 477 | # ogGetDiskSize int_ndisk |
---|
| 478 | #@brief Muestra el tamaño en KB de un disco. |
---|
| 479 | #@param int_ndisk nº de orden del disco |
---|
| 480 | #@return int_size - Tamaño en KB del disco. |
---|
| 481 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
[be0a5cf] | 482 | #@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo). |
---|
[739d358] | 483 | #@note Requisitos: sfdisk, awk |
---|
| 484 | #@version 0.9.2 - Primera version para OpenGnSys |
---|
| 485 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 486 | #@date 2010/09/15 |
---|
| 487 | #*/ ## |
---|
| 488 | function ogGetDiskSize () |
---|
| 489 | { |
---|
| 490 | # Variables locales. |
---|
| 491 | local DISK |
---|
| 492 | |
---|
| 493 | # Si se solicita, mostrar ayuda. |
---|
| 494 | if [ "$*" == "help" ]; then |
---|
[cbbb046] | 495 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk" "$FUNCNAME 1 => 244198584" |
---|
[739d358] | 496 | return |
---|
| 497 | fi |
---|
| 498 | # Error si no se recibe 1 parámetro. |
---|
| 499 | [ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 500 | |
---|
[43892687] | 501 | # Obtener el tamaño del disco. |
---|
[739d358] | 502 | DISK="$(ogDiskToDev $1)" || return $? |
---|
[43892687] | 503 | awk -v D=${DISK#/dev/} '{if ($4==D) {print $3}}' /proc/partitions |
---|
[739d358] | 504 | } |
---|
| 505 | |
---|
| 506 | |
---|
[d7c35ad] | 507 | #/** |
---|
[b994bc73] | 508 | # ogGetDiskType path_device |
---|
| 509 | #@brief Muestra el tipo de disco (real, RAID, meta-disco, etc.). |
---|
| 510 | #@warning Función en pruebas |
---|
| 511 | #*/ ## |
---|
| 512 | function ogGetDiskType () |
---|
| 513 | { |
---|
| 514 | local DEV MAJOR TYPE |
---|
| 515 | |
---|
| 516 | # Obtener el driver del dispositivo de bloques. |
---|
| 517 | [ -b "$1" ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 518 | DEV=${1#/dev/} |
---|
| 519 | MAJOR=$(awk -v D="$DEV" '{if ($4==D) print $1;}' /proc/partitions) |
---|
| 520 | TYPE=$(awk -v D=$MAJOR '/Block/ {bl=1} {if ($1==D&&bl) print toupper($2)}' /proc/devices) |
---|
| 521 | # Devolver mnemónico del driver de dispositivo. |
---|
| 522 | case "$TYPE" in |
---|
| 523 | SD) TYPE="DISK" ;; |
---|
| 524 | SR|IDE*) TYPE="CDROM" ;; # FIXME Comprobar discos IDE. |
---|
| 525 | MD|CCISS*) TYPE="RAID" ;; |
---|
| 526 | DEVICE-MAPPER) TYPE="MAPPER" ;; # FIXME Comprobar LVM y RAID. |
---|
| 527 | esac |
---|
| 528 | echo $TYPE |
---|
| 529 | } |
---|
| 530 | |
---|
| 531 | |
---|
| 532 | #/** |
---|
[73488c9] | 533 | # ogGetLastSector int_ndisk [int_npart] |
---|
[6e390b1] | 534 | #@brief Devuelve el último sector usable del disco o de una partición. |
---|
[73488c9] | 535 | #@param int_ndisk nº de orden del disco |
---|
| 536 | #@param int_npart nº de orden de la partición (opcional) |
---|
| 537 | #@return Último sector usable. |
---|
| 538 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 539 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponde con un dispositivo. |
---|
| 540 | #@note Requisitos: sfdisk, sgdisk |
---|
| 541 | #@version 1.0.4 - Primera versión compatible con OpenGnSys. |
---|
| 542 | #@author Universidad de Huelva |
---|
| 543 | #@date 2012/06/03 |
---|
| 544 | #*/ ## |
---|
| 545 | |
---|
| 546 | function ogGetLastSector () |
---|
| 547 | { |
---|
| 548 | # Variables locales |
---|
| 549 | local DISK PART PTTYPE LASTSECTOR SECTORS CYLS |
---|
| 550 | # Si se solicita, mostrar ayuda. |
---|
| 551 | if [ "$*" == "help" ]; then |
---|
| 552 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk [int_npart]" \ |
---|
| 553 | "$FUNCNAME 1 => 488392064" \ |
---|
| 554 | "$FUNCNAME 1 1 => 102400062" |
---|
| 555 | return |
---|
| 556 | fi |
---|
| 557 | # Error si no se reciben 1 o 2 parámetros. |
---|
| 558 | case $# in |
---|
| 559 | 1) DISK=$(ogDiskToDev $1) || return $? |
---|
| 560 | ;; |
---|
| 561 | 2) DISK=$(ogDiskToDev $1) || return $? |
---|
| 562 | PART=$(ogDiskToDev $1 $2) || return $? |
---|
| 563 | ;; |
---|
| 564 | *) ogRaiseError $OG_ERR_FORMAT |
---|
| 565 | return $? ;; |
---|
| 566 | esac |
---|
| 567 | |
---|
| 568 | # Hay que comprobar si el disco es GPT |
---|
| 569 | PTTYPE=$(ogGetPartitionTableType $1) |
---|
[a06ac2d] | 570 | PTTYPE=${PTTYPE:-"MSDOS"} # Por defecto para discos vacíos. |
---|
[73488c9] | 571 | case "$PTTYPE" in |
---|
| 572 | GPT) |
---|
| 573 | if [ $# == 1 ]; then |
---|
| 574 | LASTSECTOR=$(LANG=C sgdisk -p $DISK | awk '/last usable sector/ {print($(NF))}') |
---|
| 575 | else |
---|
| 576 | LASTSECTOR=$(LANG=C sgdisk -p $DISK | awk -v P="$2" '{if ($1==P) print $3}') |
---|
| 577 | fi |
---|
| 578 | ;; |
---|
| 579 | MSDOS) |
---|
| 580 | if [ $# == 1 ]; then |
---|
| 581 | SECTORS=$(awk -v D=${DISK#/dev/} '{if ($4==D) {print $3*2}}' /proc/partitions) |
---|
| 582 | CYLS=$(sfdisk -g $DISK | cut -f2 -d" ") |
---|
| 583 | LASTSECTOR=$[SECTORS/CYLS*CYLS-1] |
---|
| 584 | else |
---|
[b1f1311] | 585 | LASTSECTOR=$(sfdisk -uS -l $DISK 2>/dev/null | \ |
---|
[73488c9] | 586 | awk -v P="$PART" '{if ($1==P) {if ($2=="*") print $4; else print $3} }') |
---|
| 587 | fi |
---|
| 588 | ;; |
---|
| 589 | esac |
---|
| 590 | echo $LASTSECTOR |
---|
| 591 | } |
---|
| 592 | |
---|
| 593 | |
---|
| 594 | #/** |
---|
[42669ebf] | 595 | # ogGetPartitionActive int_ndisk |
---|
[a5df9b9] | 596 | #@brief Muestra que particion de un disco esta marcada como de activa. |
---|
[b9e1a8c] | 597 | #@param int_ndisk nº de orden del disco |
---|
| 598 | #@return int_npart Nº de partición activa |
---|
[a5df9b9] | 599 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 600 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
---|
| 601 | #@note Requisitos: parted |
---|
[59f9ad2] | 602 | #@todo Queda definir formato para atributos (arranque, oculta, ...). |
---|
[afc1e74] | 603 | #@version 0.9 - Primera version compatible con OpenGnSys. |
---|
[a5df9b9] | 604 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
[985bef0] | 605 | #@date 2009/09/17 |
---|
[1e7eaab] | 606 | #*/ ## |
---|
[42669ebf] | 607 | function ogGetPartitionActive () |
---|
| 608 | { |
---|
[59f9ad2] | 609 | # Variables locales |
---|
[a5df9b9] | 610 | local DISK |
---|
| 611 | |
---|
[1e7eaab] | 612 | # Si se solicita, mostrar ayuda. |
---|
[aae34f6] | 613 | if [ "$*" == "help" ]; then |
---|
| 614 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk" "$FUNCNAME 1 => 1" |
---|
| 615 | return |
---|
| 616 | fi |
---|
[1e7eaab] | 617 | # Error si no se recibe 1 parámetro. |
---|
[aae34f6] | 618 | [ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[a5df9b9] | 619 | |
---|
[1e7eaab] | 620 | # Comprobar que el disco existe y listar su partición activa. |
---|
[a5df9b9] | 621 | DISK="$(ogDiskToDev $1)" || return $? |
---|
| 622 | parted $DISK print 2>/dev/null | awk '/boot/ {print $1}' |
---|
| 623 | } |
---|
| 624 | |
---|
| 625 | |
---|
| 626 | #/** |
---|
[42669ebf] | 627 | # ogGetPartitionId int_ndisk int_npartition |
---|
[7dada73] | 628 | #@brief Devuelve el mnemónico con el tipo de partición. |
---|
[42669ebf] | 629 | #@param int_ndisk nº de orden del disco |
---|
| 630 | #@param int_npartition nº de orden de la partición |
---|
[9f57de01] | 631 | #@return Identificador de tipo de partición. |
---|
[326cec3] | 632 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
[7dada73] | 633 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponde con un dispositivo. |
---|
[a5df9b9] | 634 | #@note Requisitos: sfdisk |
---|
[7dada73] | 635 | #@version 0.9 - Primera versión compatible con OpenGnSys. |
---|
[9f57de01] | 636 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
[942dfd7] | 637 | #@date 2009/03/25 |
---|
[7dada73] | 638 | #@version 1.0.2 - Detectar partición vacía. |
---|
| 639 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
[942dfd7] | 640 | #@date 2011/12/23 |
---|
[1e7eaab] | 641 | #*/ ## |
---|
[42669ebf] | 642 | function ogGetPartitionId () |
---|
| 643 | { |
---|
[59f9ad2] | 644 | # Variables locales. |
---|
[ad3f531] | 645 | local DISK PART ID |
---|
[2e15649] | 646 | |
---|
[1e7eaab] | 647 | # Si se solicita, mostrar ayuda. |
---|
[aae34f6] | 648 | if [ "$*" == "help" ]; then |
---|
| 649 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
---|
| 650 | "$FUNCNAME 1 1 => 7" |
---|
| 651 | return |
---|
| 652 | fi |
---|
[1e7eaab] | 653 | # Error si no se reciben 2 parámetros. |
---|
[aae34f6] | 654 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[2e15649] | 655 | |
---|
[7dada73] | 656 | # Detectar id. de tipo de partición y codificar al mnemónico. |
---|
[2e15649] | 657 | DISK=$(ogDiskToDev $1) || return $? |
---|
[ad3f531] | 658 | PART=$(ogDiskToDev $1 $2) || return $? |
---|
[8baebd4] | 659 | case "$(ogGetPartitionTableType $1)" in |
---|
| 660 | GPT) ID=$(sgdisk -p $DISK 2>/dev/null | awk -v p="$2" '{if ($1==p) print $6;}') || ogRaiseError $OG_ERR_NOTFOUND "$1,$2" || return $? |
---|
[f12cc5d] | 661 | [ "$ID" == "8301" -a "$1 $2" == "$(ogFindCache)" ] && ID=CA00 |
---|
[8baebd4] | 662 | ;; |
---|
| 663 | MSDOS) ID=$(sfdisk --id $DISK $2 2>/dev/null) || ogRaiseError $OG_ERR_NOTFOUND "$1,$2" || return $? ;; |
---|
| 664 | esac |
---|
[7dada73] | 665 | echo $ID |
---|
[9f29ba6] | 666 | } |
---|
| 667 | |
---|
[a5df9b9] | 668 | |
---|
| 669 | #/** |
---|
[42669ebf] | 670 | # ogGetPartitionSize int_ndisk int_npartition |
---|
[a5df9b9] | 671 | #@brief Muestra el tamano en KB de una particion determinada. |
---|
[42669ebf] | 672 | #@param int_ndisk nº de orden del disco |
---|
| 673 | #@param int_npartition nº de orden de la partición |
---|
| 674 | #@return int_partsize - Tamaño en KB de la partición. |
---|
[a5df9b9] | 675 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 676 | #@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo). |
---|
| 677 | #@note Requisitos: sfdisk, awk |
---|
[985bef0] | 678 | #@version 0.1 - Integracion para Opengnsys - EAC: SizePartition () en ATA.lib |
---|
| 679 | #@author Antonio J. Doblas Viso, Universidad de Malaga |
---|
| 680 | #@date 2008/10/27 |
---|
[afc1e74] | 681 | #@version 0.9 - Primera version para OpenGnSys |
---|
[a5df9b9] | 682 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 683 | #@date 2009/07/24 |
---|
[1e7eaab] | 684 | #*/ ## |
---|
[42669ebf] | 685 | function ogGetPartitionSize () |
---|
| 686 | { |
---|
[59f9ad2] | 687 | # Variables locales. |
---|
[739d358] | 688 | local DISK PART |
---|
[a5df9b9] | 689 | |
---|
[1e7eaab] | 690 | # Si se solicita, mostrar ayuda. |
---|
[aae34f6] | 691 | if [ "$*" == "help" ]; then |
---|
| 692 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
---|
| 693 | "$FUNCNAME 1 1 => 10000000" |
---|
| 694 | return |
---|
| 695 | fi |
---|
[1e7eaab] | 696 | # Error si no se reciben 2 parámetros. |
---|
[aae34f6] | 697 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[a5df9b9] | 698 | |
---|
[1e7eaab] | 699 | # Obtener el tamaño de la partición. |
---|
[3543b3e] | 700 | DISK="$(ogDiskToDev $1)" || return $? |
---|
[a5df9b9] | 701 | PART="$(ogDiskToDev $1 $2)" || return $? |
---|
[3543b3e] | 702 | case "$(ogGetPartitionId $1 $2)" in |
---|
| 703 | 5|f) # Procesar detección de tamaño de partición Extendida. |
---|
[55ad138c] | 704 | sfdisk -l $DISK 2>/dev/null | \ |
---|
[c438bd3] | 705 | awk -v p=$PART '{if ($1==p) {sub (/[^0-9]+/,"",$5); print $5} }' |
---|
[3543b3e] | 706 | ;; |
---|
| 707 | *) sfdisk -s $PART |
---|
| 708 | ;; |
---|
| 709 | esac |
---|
[a5df9b9] | 710 | } |
---|
| 711 | |
---|
| 712 | |
---|
[b094c59] | 713 | #/** |
---|
[73488c9] | 714 | # ogGetPartitionsNumber int_ndisk |
---|
| 715 | #@brief Detecta el numero de particiones del disco duro indicado. |
---|
| 716 | #@param int_ndisk nº de orden del disco |
---|
| 717 | #@return Devuelve el numero paritiones del disco duro indicado |
---|
| 718 | #@warning Salidas de errores no determinada |
---|
| 719 | #@attention Requisitos: parted |
---|
| 720 | #@note Notas sin especificar |
---|
| 721 | #@version 0.1 - Integracion para Opengnsys - EAC: DetectNumberPartition () en ATA.lib |
---|
| 722 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 723 | #@date Date: 27/10/2008 |
---|
| 724 | #@version 1.0 - Uso de sfdisk Primera version para OpenGnSys |
---|
| 725 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 726 | #@date 2009/07/24 |
---|
| 727 | #@version 1.0.4 - Uso de /proc/partitions para detectar el numero de particiones |
---|
| 728 | #@author Universidad de Huelva |
---|
| 729 | #@date 2012/03/28 |
---|
| 730 | #*/ ## |
---|
| 731 | function ogGetPartitionsNumber () |
---|
| 732 | { |
---|
| 733 | # Variables locales. |
---|
| 734 | local DISK |
---|
| 735 | # Si se solicita, mostrar ayuda. |
---|
| 736 | if [ "$*" == "help" ]; then |
---|
| 737 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk" \ |
---|
| 738 | "$FUNCNAME 1 => 3" |
---|
| 739 | return |
---|
| 740 | fi |
---|
| 741 | # Error si no se recibe 1 parámetro. |
---|
| 742 | [ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 743 | |
---|
| 744 | # Contar el nº de veces que aparece el disco en su lista de particiones. |
---|
| 745 | DISK=$(ogDiskToDev $1) 2>/dev/null |
---|
[5de6fb0] | 746 | case "$(ogGetPartitionTableType $1)" in |
---|
| 747 | GPT) grep -c "${DISK#/dev/}." /proc/partitions ;; |
---|
| 748 | MSDOS) sfdisk -l $DISK 2>/dev/null | grep -c "^$DISK" ;; |
---|
| 749 | esac |
---|
[73488c9] | 750 | } |
---|
| 751 | |
---|
| 752 | |
---|
| 753 | #/** |
---|
[60fc799] | 754 | # ogGetPartitionTableType int_ndisk |
---|
| 755 | #@brief Devuelve el tipo de tabla de particiones del disco (GPT o MSDOS) |
---|
| 756 | #@param int_ndisk nº de orden del disco |
---|
| 757 | #@return str_tabletype - Tipo de tabla de paritiones |
---|
| 758 | #@warning Salidas de errores no determinada |
---|
[6e390b1] | 759 | #@note tabletype = { MSDOS, GPT } |
---|
[60fc799] | 760 | #@note Requisitos: parted |
---|
| 761 | #@version 1.0.4 - Primera versión para OpenGnSys |
---|
| 762 | #@author Universidad de Huelva |
---|
| 763 | #@date 2012/03/01 |
---|
[6e390b1] | 764 | #*/ ## |
---|
[60fc799] | 765 | function ogGetPartitionTableType () |
---|
| 766 | { |
---|
| 767 | # Variables locales. |
---|
| 768 | local DISK |
---|
| 769 | |
---|
| 770 | # Si se solicita, mostrar ayuda. |
---|
| 771 | if [ "$*" == "help" ]; then |
---|
| 772 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk" \ |
---|
[6e390b1] | 773 | "$FUNCNAME 1 => MSDOS" |
---|
[60fc799] | 774 | return |
---|
| 775 | fi |
---|
| 776 | # Error si no se recibe 1 parámetro. |
---|
| 777 | [ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 778 | |
---|
| 779 | # Sustituye n de disco por su dispositivo. |
---|
| 780 | DISK=`ogDiskToDev $1` || return $? |
---|
| 781 | parted -sm $DISK print | awk -F: -v D=$DISK '{ if($1 == D) print toupper($6)}' |
---|
| 782 | } |
---|
| 783 | |
---|
| 784 | |
---|
| 785 | #/** |
---|
[344d6e7] | 786 | # ogGetPartitionType int_ndisk int_npartition |
---|
[5804229] | 787 | #@brief Devuelve el mnemonico con el tipo de partición. |
---|
| 788 | #@param int_ndisk nº de orden del disco |
---|
| 789 | #@param int_npartition nº de orden de la partición |
---|
| 790 | #@return Mnemonico |
---|
[be48687] | 791 | #@note Mnemonico: valor devuelto por ogIdToType. |
---|
[5804229] | 792 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
[824b0dd] | 793 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
---|
| 794 | #@version 0.1 - Integracion para Opengnsys - EAC: TypeFS() en ATA.lib |
---|
[5804229] | 795 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 796 | #@date 2008-10-27 |
---|
| 797 | #@version 0.9 - Primera adaptacion para OpenGnSys. |
---|
| 798 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 799 | #@date 2009-07-21 |
---|
| 800 | #@version 1.0.3 - Código trasladado de antigua función ogGetFsType. |
---|
| 801 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 802 | #@date 2011-12-01 |
---|
[be48687] | 803 | #@version 1.0.5 - Usar función ogIdToType para hacer la conversión id. a tipo. |
---|
| 804 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 805 | #@date 2013-09-19 |
---|
[344d6e7] | 806 | #*/ ## |
---|
| 807 | function ogGetPartitionType () |
---|
| 808 | { |
---|
[5804229] | 809 | # Variables locales. |
---|
| 810 | local ID TYPE |
---|
| 811 | |
---|
| 812 | # Si se solicita, mostrar ayuda. |
---|
| 813 | if [ "$*" == "help" ]; then |
---|
| 814 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
---|
| 815 | "$FUNCNAME 1 1 => NTFS" |
---|
| 816 | return |
---|
| 817 | fi |
---|
| 818 | # Error si no se reciben 2 parámetros. |
---|
| 819 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 820 | |
---|
| 821 | # Detectar id. de tipo de partición y codificar al mnemonico. |
---|
| 822 | ID=$(ogGetPartitionId "$1" "$2") || return $? |
---|
[b663655] | 823 | TYPE=$(ogIdToType "$ID") |
---|
[5804229] | 824 | echo "$TYPE" |
---|
[344d6e7] | 825 | } |
---|
| 826 | |
---|
| 827 | |
---|
| 828 | #/** |
---|
[b09d0fa] | 829 | # ogHidePartition int_ndisk int_npartition |
---|
| 830 | #@brief Oculta un apartición visible. |
---|
| 831 | #@param int_ndisk nº de orden del disco |
---|
| 832 | #@param int_npartition nº de orden de la partición |
---|
| 833 | #@return (nada) |
---|
| 834 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
[053993f] | 835 | #@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo). |
---|
[b09d0fa] | 836 | #@exception OG_ERR_PARTITION tipo de partición no reconocido. |
---|
| 837 | #@version 1.0 - Versión en pruebas. |
---|
| 838 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 839 | #@date 2010/01/12 |
---|
| 840 | #*/ ## |
---|
| 841 | function ogHidePartition () |
---|
| 842 | { |
---|
| 843 | # Variables locales. |
---|
| 844 | local PART TYPE NEWTYPE |
---|
| 845 | # Si se solicita, mostrar ayuda. |
---|
| 846 | if [ "$*" == "help" ]; then |
---|
| 847 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
---|
| 848 | "$FUNCNAME 1 1" |
---|
| 849 | return |
---|
| 850 | fi |
---|
| 851 | # Error si no se reciben 2 parámetros. |
---|
| 852 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 853 | PART=$(ogDiskToDev "$1" "$2") || return $? |
---|
| 854 | |
---|
| 855 | # Obtener tipo de partición. |
---|
| 856 | TYPE=$(ogGetPartitionType "$1" "$2") |
---|
| 857 | case "$TYPE" in |
---|
| 858 | NTFS) NEWTYPE="HNTFS" ;; |
---|
| 859 | FAT32) NEWTYPE="HFAT32" ;; |
---|
| 860 | FAT16) NEWTYPE="HFAT16" ;; |
---|
| 861 | FAT12) NEWTYPE="HFAT12" ;; |
---|
| 862 | *) ogRaiseError $OG_ERR_PARTITION "$TYPE" |
---|
| 863 | return $? ;; |
---|
| 864 | esac |
---|
| 865 | # Cambiar tipo de partición. |
---|
[ec6de25] | 866 | ogSetPartitionType $1 $2 $NEWTYPE |
---|
[b09d0fa] | 867 | } |
---|
| 868 | |
---|
| 869 | |
---|
| 870 | #/** |
---|
[afc1e74] | 871 | # ogIdToType int_idpart |
---|
| 872 | #@brief Devuelve el identificador correspondiente a un tipo de partición. |
---|
| 873 | #@param int_idpart identificador de tipo de partición. |
---|
| 874 | #@return str_parttype mnemónico de tipo de partición. |
---|
| 875 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 876 | #@version 1.0.5 - Primera version para OpenGnSys |
---|
| 877 | #@author Ramon Gomez, ETSII Universidad Sevilla |
---|
| 878 | #@date 2013-02-07 |
---|
| 879 | #*/ ## |
---|
| 880 | function ogIdToType () |
---|
| 881 | { |
---|
| 882 | # Variables locales |
---|
| 883 | local ID TYPE |
---|
| 884 | |
---|
| 885 | # Si se solicita, mostrar ayuda. |
---|
| 886 | if [ "$*" == "help" ]; then |
---|
| 887 | ogHelp "$FUNCNAME" "$FUNCNAME int_idpart" \ |
---|
| 888 | "$FUNCNAME 83 => LINUX" |
---|
| 889 | return |
---|
| 890 | fi |
---|
| 891 | # Error si no se recibe 1 parámetro. |
---|
| 892 | [ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 893 | |
---|
| 894 | # Obtener valor hexadecimal de 4 caracteres rellenado con 0 por delante. |
---|
| 895 | ID=$(printf "%4s" "$1" | tr ' ' '0') |
---|
| 896 | case "${ID,,}" in |
---|
| 897 | 0000) TYPE="EMPTY" ;; |
---|
| 898 | 0001) TYPE="FAT12" ;; |
---|
| 899 | 0005|000f) TYPE="EXTENDED" ;; |
---|
| 900 | 0006|000e) TYPE="FAT16" ;; |
---|
| 901 | 0007) TYPE="NTFS" ;; |
---|
| 902 | 000b|000c) TYPE="FAT32" ;; |
---|
| 903 | 0011) TYPE="HFAT12" ;; |
---|
| 904 | 0012) TYPE="COMPAQDIAG" ;; |
---|
| 905 | 0016|001e) TYPE="HFAT16" ;; |
---|
| 906 | 0017) TYPE="HNTFS" ;; |
---|
| 907 | 001b|001c) TYPE="HFAT32" ;; |
---|
| 908 | 0042) TYPE="WIN-DYNAMIC" ;; |
---|
| 909 | 0082|8200) TYPE="LINUX-SWAP" ;; |
---|
| 910 | 0083|8300) TYPE="LINUX" ;; |
---|
| 911 | 008e|8E00) TYPE="LINUX-LVM" ;; |
---|
[b663655] | 912 | 00a5|a503) TYPE="FREEBSD" ;; |
---|
[afc1e74] | 913 | 00a6) TYPE="OPENBSD" ;; |
---|
| 914 | 00a7) TYPE="CACHE" ;; # (compatibilidad con Brutalix) |
---|
| 915 | 00af|af00) TYPE="HFS" ;; |
---|
| 916 | 00be|be00) TYPE="SOLARIS-BOOT" ;; |
---|
| 917 | 00bf|bf0[0145]) TYPE="SOLARIS" ;; |
---|
| 918 | 00ca|ca00) TYPE="CACHE" ;; |
---|
| 919 | 00da) TYPE="DATA" ;; |
---|
| 920 | 00ee) TYPE="GPT" ;; |
---|
| 921 | 00ef|ef00) TYPE="EFI" ;; |
---|
| 922 | 00fb) TYPE="VMFS" ;; |
---|
| 923 | 00fd|fd00) TYPE="LINUX-RAID" ;; |
---|
| 924 | 0700) TYPE="WINDOWS" ;; |
---|
| 925 | 0c01) TYPE="WIN-RESERV" ;; |
---|
| 926 | 7f00) TYPE="CHROMEOS-KRN" ;; |
---|
| 927 | 7f01) TYPE="CHROMEOS" ;; |
---|
| 928 | 7f02) TYPE="CHROMEOS-RESERV" ;; |
---|
| 929 | 8301) TYPE="LINUX-RESERV" ;; |
---|
| 930 | a500) TYPE="FREEBSD-DISK" ;; |
---|
| 931 | a501) TYPE="FREEBSD-BOOT" ;; |
---|
| 932 | a502) TYPE="FREEBSD-SWAP" ;; |
---|
[b663655] | 933 | ab00) TYPE="HFS-BOOT" ;; |
---|
[afc1e74] | 934 | af01) TYPE="HFS-RAID" ;; |
---|
| 935 | bf02) TYPE="SOLARIS-SWAP" ;; |
---|
| 936 | bf03) TYPE="SOLARIS-DISK" ;; |
---|
| 937 | ef01) TYPE="MBR" ;; |
---|
| 938 | ef02) TYPE="BIOS-BOOT" ;; |
---|
| 939 | *) TYPE="UNKNOWN" ;; |
---|
| 940 | esac |
---|
| 941 | echo "$TYPE" |
---|
| 942 | } |
---|
| 943 | |
---|
| 944 | |
---|
| 945 | #/** |
---|
[73c8417] | 946 | # ogListPartitions int_ndisk |
---|
[a5df9b9] | 947 | #@brief Lista las particiones definidas en un disco. |
---|
[42669ebf] | 948 | #@param int_ndisk nº de orden del disco |
---|
| 949 | #@return str_parttype:int_partsize ... |
---|
[a5df9b9] | 950 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 951 | #@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo). |
---|
| 952 | #@note Requisitos: \c parted \c awk |
---|
[73c8417] | 953 | #@attention El nº de partición se indica por el orden de los párametros \c parttype:partsize |
---|
[59f9ad2] | 954 | #@attention Las tuplas de valores están separadas por espacios. |
---|
[afc1e74] | 955 | #@version 0.9 - Primera versión para OpenGnSys |
---|
[a5df9b9] | 956 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 957 | #@date 2009/07/24 |
---|
[1e7eaab] | 958 | #*/ ## |
---|
[42669ebf] | 959 | function ogListPartitions () |
---|
| 960 | { |
---|
[59f9ad2] | 961 | # Variables locales. |
---|
[55ad138c] | 962 | local DISK PART NPARTS TYPE SIZE |
---|
[aae34f6] | 963 | |
---|
[42669ebf] | 964 | # Si se solicita, mostrar ayuda. |
---|
[1a7130a] | 965 | if [ "$*" == "help" ]; then |
---|
[aae34f6] | 966 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk" \ |
---|
[73c8417] | 967 | "$FUNCNAME 1 => NTFS:10000000 EXT3:5000000 LINUX-SWAP:1000000" |
---|
[aae34f6] | 968 | return |
---|
| 969 | fi |
---|
[42669ebf] | 970 | # Error si no se recibe 1 parámetro. |
---|
[5dbb046] | 971 | [ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT "$FORMAT" || return $? |
---|
[a5df9b9] | 972 | |
---|
[42669ebf] | 973 | # Procesar la salida de \c parted . |
---|
[b094c59] | 974 | DISK="$(ogDiskToDev $1)" || return $? |
---|
[3543b3e] | 975 | NPARTS=$(ogGetPartitionsNumber $1) |
---|
| 976 | for (( PART = 1; PART <= NPARTS; PART++ )); do |
---|
[5804229] | 977 | TYPE=$(ogGetPartitionType $1 $PART 2>/dev/null) |
---|
[3543b3e] | 978 | if [ $? -eq 0 ]; then |
---|
[55ad138c] | 979 | SIZE=$(ogGetPartitionSize $1 $PART 2>/dev/null) |
---|
| 980 | echo -n "$TYPE:$SIZE " |
---|
[3543b3e] | 981 | else |
---|
| 982 | echo -n "EMPTY:0 " |
---|
| 983 | fi |
---|
[a5df9b9] | 984 | done |
---|
| 985 | echo |
---|
| 986 | } |
---|
| 987 | |
---|
[326cec3] | 988 | |
---|
| 989 | #/** |
---|
[55ad138c] | 990 | # ogListPrimaryPartitions int_ndisk |
---|
[942dfd7] | 991 | #@brief Metafunción que lista las particiones primarias no vacías de un disco. |
---|
[42669ebf] | 992 | #@param int_ndisk nº de orden del disco |
---|
[55ad138c] | 993 | #@see ogListPartitions |
---|
[1e7eaab] | 994 | #*/ ## |
---|
[42669ebf] | 995 | function ogListPrimaryPartitions () |
---|
| 996 | { |
---|
[55ad138c] | 997 | # Variables locales. |
---|
[942dfd7] | 998 | local PTTYPE PARTS |
---|
[55ad138c] | 999 | |
---|
[942dfd7] | 1000 | PTTYPE=$(ogGetPartitionTableType $1) || return $? |
---|
[55ad138c] | 1001 | PARTS=$(ogListPartitions "$@") || return $? |
---|
[942dfd7] | 1002 | case "$PTTYPE" in |
---|
| 1003 | GPT) echo $PARTS | sed 's/\( EMPTY:0\)*$//' ;; |
---|
| 1004 | MSDOS) echo $PARTS | cut -sf1-4 -d" " | sed 's/\( EMPTY:0\)*$//' ;; |
---|
| 1005 | esac |
---|
[55ad138c] | 1006 | } |
---|
| 1007 | |
---|
| 1008 | |
---|
| 1009 | #/** |
---|
| 1010 | # ogListLogicalPartitions int_ndisk |
---|
[942dfd7] | 1011 | #@brief Metafunción que lista las particiones lógicas de una tabla tipo MSDOS. |
---|
[42669ebf] | 1012 | #@param int_ndisk nº de orden del disco |
---|
[55ad138c] | 1013 | #@see ogListPartitions |
---|
[1e7eaab] | 1014 | #*/ ## |
---|
[b061ad0] | 1015 | function ogListLogicalPartitions () |
---|
| 1016 | { |
---|
[55ad138c] | 1017 | # Variables locales. |
---|
[942dfd7] | 1018 | local PTTYPE PARTS |
---|
[55ad138c] | 1019 | |
---|
[942dfd7] | 1020 | PTTYPE=$(ogGetPartitionTableType $1) || return $? |
---|
| 1021 | [ "$PTTYPE" == "MSDOS" ] || ogRaiseError $OG_ERR_PARTITION "" || return $? |
---|
[55ad138c] | 1022 | PARTS=$(ogListPartitions "$@") || return $? |
---|
| 1023 | echo $PARTS | cut -sf5- -d" " |
---|
| 1024 | } |
---|
| 1025 | |
---|
| 1026 | |
---|
| 1027 | #/** |
---|
[42669ebf] | 1028 | # ogSetPartitionActive int_ndisk int_npartition |
---|
[89403cd] | 1029 | #@brief Establece cual es la partición activa de un disco. |
---|
[42669ebf] | 1030 | #@param int_ndisk nº de orden del disco |
---|
| 1031 | #@param int_npartition nº de orden de la partición |
---|
| 1032 | #@return (nada). |
---|
[326cec3] | 1033 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 1034 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo. |
---|
| 1035 | #@note Requisitos: parted |
---|
[985bef0] | 1036 | #@version 0.1 - Integracion para Opengnsys - EAC: SetPartitionActive() en ATA.lib |
---|
| 1037 | #@author Antonio J. Doblas Viso, Universidad de Malaga |
---|
| 1038 | #@date 2008/10/27 |
---|
[afc1e74] | 1039 | #@version 0.9 - Primera version compatible con OpenGnSys. |
---|
[326cec3] | 1040 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 1041 | #@date 2009/09/17 |
---|
[1e7eaab] | 1042 | #*/ ## |
---|
[42669ebf] | 1043 | function ogSetPartitionActive () |
---|
| 1044 | { |
---|
[326cec3] | 1045 | # Variables locales |
---|
| 1046 | local DISK PART |
---|
| 1047 | |
---|
[1e7eaab] | 1048 | # Si se solicita, mostrar ayuda. |
---|
[326cec3] | 1049 | if [ "$*" == "help" ]; then |
---|
| 1050 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
---|
| 1051 | "$FUNCNAME 1 1" |
---|
| 1052 | return |
---|
| 1053 | fi |
---|
[1e7eaab] | 1054 | # Error si no se reciben 2 parámetros. |
---|
[326cec3] | 1055 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 1056 | |
---|
[1e7eaab] | 1057 | # Comprobar que el disco existe y activar la partición indicada. |
---|
[326cec3] | 1058 | DISK="$(ogDiskToDev $1)" || return $? |
---|
| 1059 | PART="$(ogDiskToDev $1 $2)" || return $? |
---|
| 1060 | parted -s $DISK set $2 boot on 2>/dev/null |
---|
| 1061 | } |
---|
| 1062 | |
---|
| 1063 | |
---|
[1553fc7] | 1064 | #/** |
---|
[ec6de25] | 1065 | # ogSetPartitionId int_ndisk int_npartition hex_partid |
---|
[5af5d5f] | 1066 | #@brief Cambia el identificador de la partición. |
---|
| 1067 | #@param int_ndisk nº de orden del disco |
---|
| 1068 | #@param int_npartition nº de orden de la partición |
---|
[ec6de25] | 1069 | #@param hex_partid identificador de tipo de partición |
---|
[5af5d5f] | 1070 | #@return (nada) |
---|
[ec6de25] | 1071 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 1072 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo. |
---|
| 1073 | #@exception OG_ERR_OUTOFLIMIT Valor no válido. |
---|
| 1074 | #@exception OG_ERR_PARTITION Error al cambiar el id. de partición. |
---|
[5af5d5f] | 1075 | #@attention Requisitos: fdisk, sgdisk |
---|
| 1076 | #@version 0.1 - Integracion para Opengnsys - SetPartitionType() en ATA.lib |
---|
| 1077 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 1078 | #@date 2008/10/27 |
---|
| 1079 | #@version 1.0.4 - Soporte para discos GPT. |
---|
| 1080 | #@author Universidad de Huelva |
---|
| 1081 | #@date 2012/03/13 |
---|
[ec6de25] | 1082 | #@version 1.0.5 - Utiliza el id. de tipo de partición (no el mnemónico) |
---|
| 1083 | #@author Universidad de Huelva |
---|
[0a693d3] | 1084 | #@date 2012/05/14 |
---|
[5af5d5f] | 1085 | #*/ ## |
---|
[6e390b1] | 1086 | function ogSetPartitionId () |
---|
| 1087 | { |
---|
[5af5d5f] | 1088 | # Variables locales |
---|
| 1089 | local DISK PART PTTYPE ID |
---|
| 1090 | |
---|
| 1091 | # Si se solicita, mostrar ayuda. |
---|
| 1092 | if [ "$*" == "help" ]; then |
---|
[8ca8f5e] | 1093 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition hex_partid" \ |
---|
| 1094 | "$FUNCNAME 1 1 7" |
---|
[5af5d5f] | 1095 | return |
---|
| 1096 | fi |
---|
| 1097 | # Error si no se reciben 3 parámetros. |
---|
| 1098 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 1099 | |
---|
[ec6de25] | 1100 | # Sustituye nº de disco y nº partición por su dispositivo. |
---|
| 1101 | DISK=$(ogDiskToDev $1) || return $? |
---|
| 1102 | PART=$(ogDiskToDev $1 $2) || return $? |
---|
| 1103 | # Error si el id. de partición no es hexadecimal. |
---|
| 1104 | ID="${3^^}" |
---|
| 1105 | [[ "$ID" =~ ^[0-9A-F]+$ ]] || ogRaiseError $OG_ERR_OUTOFLIMIT "$3" || return $? |
---|
[5af5d5f] | 1106 | |
---|
| 1107 | # Elección del tipo de partición. |
---|
| 1108 | PTTYPE=$(ogGetPartitionTableType $1) |
---|
| 1109 | case "$PTTYPE" in |
---|
[0a693d3] | 1110 | GPT) sgdisk -t$2:$ID $DISK 2>/dev/null ;; |
---|
[5af5d5f] | 1111 | MSDOS) echo -ne "t\n$2\n${ID}\nw\n" | fdisk $DISK &>/dev/null ;; |
---|
[ec6de25] | 1112 | *) ogRaiseError $OG_ERR_OUTOFLIMIT "$1,$PTTYPE" |
---|
| 1113 | return $? ;; |
---|
[5af5d5f] | 1114 | esac |
---|
[ec6de25] | 1115 | if [ $? == 0 ]; then |
---|
| 1116 | partprobe $DISK 2>/dev/null |
---|
| 1117 | else |
---|
| 1118 | ogRaiseError $OG_ERR_PARTITION "$1,$2,$3" |
---|
| 1119 | return $? |
---|
| 1120 | fi |
---|
[5af5d5f] | 1121 | } |
---|
| 1122 | |
---|
| 1123 | |
---|
| 1124 | #/** |
---|
[42669ebf] | 1125 | # ogSetPartitionSize int_ndisk int_npartition int_size |
---|
[2ecd096] | 1126 | #@brief Muestra el tamano en KB de una particion determinada. |
---|
[5af5d5f] | 1127 | #@param int_ndisk nº de orden del disco |
---|
[42669ebf] | 1128 | #@param int_npartition nº de orden de la partición |
---|
| 1129 | #@param int_size tamaño de la partición (en KB) |
---|
[2ecd096] | 1130 | #@return (nada) |
---|
| 1131 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
| 1132 | #@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo). |
---|
| 1133 | #@note Requisitos: sfdisk, awk |
---|
| 1134 | #@todo Compruebar que el tamaño sea numérico positivo y evitar que pueda solaparse con la siguiente partición. |
---|
[afc1e74] | 1135 | #@version 0.9 - Primera versión para OpenGnSys |
---|
[2ecd096] | 1136 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 1137 | #@date 2009/07/24 |
---|
[1e7eaab] | 1138 | #*/ ## |
---|
[42669ebf] | 1139 | function ogSetPartitionSize () |
---|
| 1140 | { |
---|
[2ecd096] | 1141 | # Variables locales. |
---|
| 1142 | local DISK PART SIZE |
---|
| 1143 | |
---|
[1e7eaab] | 1144 | # Si se solicita, mostrar ayuda. |
---|
[2ecd096] | 1145 | if [ "$*" == "help" ]; then |
---|
[311532f] | 1146 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition int_size" \ |
---|
[2ecd096] | 1147 | "$FUNCNAME 1 1 10000000" |
---|
| 1148 | return |
---|
| 1149 | fi |
---|
[1e7eaab] | 1150 | # Error si no se reciben 3 parámetros. |
---|
[2ecd096] | 1151 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 1152 | |
---|
[1e7eaab] | 1153 | # Obtener el tamaño de la partición. |
---|
[2ecd096] | 1154 | DISK="$(ogDiskToDev $1)" || return $? |
---|
| 1155 | PART="$(ogDiskToDev $1 $2)" || return $? |
---|
| 1156 | # Convertir tamaño en KB a sectores de 512 B. |
---|
| 1157 | SIZE=$[$3*2] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
[3915005] | 1158 | # Redefinir el tamaño de la partición. |
---|
[1c04494] | 1159 | sfdisk -f -uS -N$2 $DISK <<< ",$SIZE" &>/dev/null || ogRaiseError $OG_ERR_PARTITION "$1,$2" || return $? |
---|
[942dfd7] | 1160 | partprobe $DISK 2>/dev/null |
---|
[2ecd096] | 1161 | } |
---|
| 1162 | |
---|
[5af5d5f] | 1163 | |
---|
[b09d0fa] | 1164 | #/** |
---|
[ec6de25] | 1165 | # ogSetPartitionType int_ndisk int_npartition str_type |
---|
| 1166 | #@brief Cambia el identificador de la partición. |
---|
| 1167 | #@param int_ndisk nº de orden del disco |
---|
| 1168 | #@param int_npartition nº de orden de la partición |
---|
[8ca8f5e] | 1169 | #@param str_type mnemónico de tipo de partición |
---|
[ec6de25] | 1170 | #@return (nada) |
---|
| 1171 | #@attention Requisitos: fdisk, sgdisk |
---|
| 1172 | #@version 0.1 - Integracion para Opengnsys - SetPartitionType() en ATA.lib |
---|
| 1173 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 1174 | #@date 2008/10/27 |
---|
| 1175 | #@version 1.0.4 - Soporte para discos GPT. |
---|
| 1176 | #@author Universidad de Huelva |
---|
| 1177 | #@date 2012/03/13 |
---|
| 1178 | #@version 1.0.5 - Renombrada de ogSetPartitionId. |
---|
| 1179 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 1180 | #@date 2013/03/07 |
---|
| 1181 | #*/ ## |
---|
| 1182 | function ogSetPartitionType () |
---|
| 1183 | { |
---|
| 1184 | # Variables locales |
---|
| 1185 | local DISK PART PTTYPE ID |
---|
| 1186 | |
---|
| 1187 | # Si se solicita, mostrar ayuda. |
---|
| 1188 | if [ "$*" == "help" ]; then |
---|
| 1189 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition str_type" \ |
---|
| 1190 | "$FUNCNAME 1 1 NTFS" |
---|
| 1191 | return |
---|
| 1192 | fi |
---|
| 1193 | # Error si no se reciben 3 parámetros. |
---|
| 1194 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 1195 | |
---|
| 1196 | # Sustituye nº de disco por su dispositivo. |
---|
| 1197 | DISK=`ogDiskToDev $1` || return $? |
---|
| 1198 | PART=`ogDiskToDev $1 $2` || return $? |
---|
| 1199 | |
---|
| 1200 | # Elección del tipo de partición. |
---|
| 1201 | PTTYPE=$(ogGetPartitionTableType $1) |
---|
| 1202 | ID=$(ogTypeToId "$3" "$PTTYPE") |
---|
| 1203 | [ -n "$ID" ] || ogRaiseError $OG_ERR_FORMAT "$3,$PTTYPE" || return $? |
---|
| 1204 | ogSetPartitionId $1 $2 $ID |
---|
| 1205 | } |
---|
| 1206 | |
---|
| 1207 | |
---|
| 1208 | #/** |
---|
[afc1e74] | 1209 | # ogTypeToId str_parttype [str_tabletype] |
---|
| 1210 | #@brief Devuelve el identificador correspondiente a un tipo de partición. |
---|
| 1211 | #@param str_parttype mnemónico de tipo de partición. |
---|
| 1212 | #@param str_tabletype mnemónico de tipo de tabla de particiones (MSDOS por defecto). |
---|
| 1213 | #@return int_idpart identificador de tipo de partición. |
---|
| 1214 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 1215 | #@note tabletype = { MSDOS, GPT }, (MSDOS, por defecto) |
---|
| 1216 | #@version 0.1 - Integracion para Opengnsys - EAC: TypeFS () en ATA.lib |
---|
| 1217 | #@author Antonio J. Doblas Viso, Universidad de Malaga |
---|
| 1218 | #@date 2008/10/27 |
---|
| 1219 | #@version 0.9 - Primera version para OpenGnSys |
---|
| 1220 | #@author Ramon Gomez, ETSII Universidad Sevilla |
---|
| 1221 | #@date 2009-12-14 |
---|
| 1222 | #@version 1.0.4 - Soportar discos GPT (sustituye a ogFsToId). |
---|
| 1223 | #@author Universidad de Huelva |
---|
| 1224 | #@date 2012/03/30 |
---|
| 1225 | #*/ ## |
---|
| 1226 | function ogTypeToId () |
---|
| 1227 | { |
---|
| 1228 | # Variables locales |
---|
| 1229 | local PTTYPE ID |
---|
| 1230 | |
---|
| 1231 | # Si se solicita, mostrar ayuda. |
---|
| 1232 | if [ "$*" == "help" ]; then |
---|
| 1233 | ogHelp "$FUNCNAME" "$FUNCNAME str_parttype [str_tabletype]" \ |
---|
| 1234 | "$FUNCNAME LINUX => 83" \ |
---|
| 1235 | "$FUNCNAME LINUX MSDOS => 83" |
---|
| 1236 | return |
---|
| 1237 | fi |
---|
| 1238 | # Error si no se reciben 1 o 2 parámetros. |
---|
| 1239 | [ $# -lt 1 -o $# -gt 2 ] && (ogRaiseError $OG_ERR_FORMAT; return $?) |
---|
| 1240 | |
---|
| 1241 | # Asociar id. de partición para su mnemónico. |
---|
| 1242 | PTTYPE=${2:-"MSDOS"} |
---|
| 1243 | case "$PTTYPE" in |
---|
| 1244 | GPT) # Se incluyen mnemónicos compatibles con tablas MSDOS. |
---|
| 1245 | case "$1" in |
---|
| 1246 | EMPTY) ID=0 ;; |
---|
| 1247 | WINDOWS|NTFS|EXFAT|FAT32|FAT16|FAT12|HNTFS|HFAT32|HFAT16|HFAT12) |
---|
| 1248 | ID=0700 ;; |
---|
| 1249 | WIN-RESERV) ID=0C01 ;; |
---|
| 1250 | CHROMEOS-KRN) ID=7F00 ;; |
---|
| 1251 | CHROMEOS) ID=7F01 ;; |
---|
| 1252 | CHROMEOS-RESERV) ID=7F02 ;; |
---|
| 1253 | LINUX-SWAP) ID=8200 ;; |
---|
| 1254 | LINUX|EXT[234]|REISERFS|REISER4|XFS|JFS) |
---|
| 1255 | ID=8300 ;; |
---|
| 1256 | LINUX-RESERV) ID=8301 ;; |
---|
| 1257 | LINUX-LVM) ID=8E00 ;; |
---|
| 1258 | FREEBSD-DISK) ID=A500 ;; |
---|
| 1259 | FREEBSD-BOOT) ID=A501 ;; |
---|
| 1260 | FREEBSD-SWAP) ID=A502 ;; |
---|
| 1261 | FREEBSD) ID=A503 ;; |
---|
[b663655] | 1262 | HFS-BOOT) ID=AB00 ;; |
---|
[afc1e74] | 1263 | HFS|HFS+) ID=AF00 ;; |
---|
| 1264 | HFS-RAID) ID=AF01 ;; |
---|
| 1265 | SOLARIS-BOOT) ID=BE00 ;; |
---|
| 1266 | SOLARIS) ID=BF00 ;; |
---|
| 1267 | SOLARIS-SWAP) ID=BF02 ;; |
---|
| 1268 | SOLARIS-DISK) ID=BF03 ;; |
---|
| 1269 | CACHE) ID=CA00;; |
---|
| 1270 | EFI) ID=EF00 ;; |
---|
| 1271 | LINUX-RAID) ID=FD00 ;; |
---|
| 1272 | *) ID="" ;; |
---|
| 1273 | esac |
---|
| 1274 | ;; |
---|
| 1275 | MSDOS) |
---|
| 1276 | case "$1" in |
---|
| 1277 | EMPTY) ID=0 ;; |
---|
| 1278 | FAT12) ID=1 ;; |
---|
| 1279 | EXTENDED) ID=5 ;; |
---|
| 1280 | FAT16) ID=6 ;; |
---|
| 1281 | WINDOWS|NTFS|EXFAT) |
---|
| 1282 | ID=7 ;; |
---|
| 1283 | FAT32) ID=b ;; |
---|
| 1284 | HFAT12) ID=11 ;; |
---|
| 1285 | HFAT16) ID=16 ;; |
---|
| 1286 | HNTFS) ID=17 ;; |
---|
| 1287 | HFAT32) ID=1b ;; |
---|
| 1288 | LINUX-SWAP) ID=82 ;; |
---|
| 1289 | LINUX|EXT[234]|REISERFS|REISER4|XFS|JFS) |
---|
| 1290 | ID=83 ;; |
---|
| 1291 | LINUX-LVM) ID=8e ;; |
---|
| 1292 | FREEBSD) ID=a5 ;; |
---|
| 1293 | OPENBSD) ID=a6 ;; |
---|
| 1294 | HFS|HFS+) ID=af ;; |
---|
| 1295 | SOLARIS-BOOT) ID=be ;; |
---|
| 1296 | SOLARIS) ID=bf ;; |
---|
| 1297 | CACHE) ID=ca ;; |
---|
| 1298 | DATA) ID=da ;; |
---|
| 1299 | GPT) ID=ee ;; |
---|
| 1300 | EFI) ID=ef ;; |
---|
| 1301 | VMFS) ID=fb ;; |
---|
| 1302 | LINUX-RAID) ID=fd ;; |
---|
| 1303 | *) ID="" ;; |
---|
| 1304 | esac |
---|
| 1305 | ;; |
---|
| 1306 | esac |
---|
| 1307 | echo $ID |
---|
| 1308 | } |
---|
| 1309 | |
---|
| 1310 | |
---|
| 1311 | #/** |
---|
[b09d0fa] | 1312 | # ogUnhidePartition int_ndisk int_npartition |
---|
| 1313 | #@brief Hace visible una partición oculta. |
---|
| 1314 | #@param int_ndisk nº de orden del disco |
---|
| 1315 | #@param int_npartition nº de orden de la partición |
---|
| 1316 | #@return (nada) |
---|
| 1317 | #@exception OG_ERR_FORMAT formato incorrecto. |
---|
[053993f] | 1318 | #@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo). |
---|
[b09d0fa] | 1319 | #@exception OG_ERR_PARTITION tipo de partición no reconocido. |
---|
| 1320 | #@version 1.0 - Versión en pruebas. |
---|
| 1321 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 1322 | #@date 2010/01/12 |
---|
| 1323 | #*/ ## |
---|
| 1324 | function ogUnhidePartition () |
---|
| 1325 | { |
---|
| 1326 | # Variables locales. |
---|
| 1327 | local PART TYPE NEWTYPE |
---|
| 1328 | # Si se solicita, mostrar ayuda. |
---|
| 1329 | if [ "$*" == "help" ]; then |
---|
| 1330 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
---|
| 1331 | "$FUNCNAME 1 1" |
---|
| 1332 | return |
---|
| 1333 | fi |
---|
| 1334 | # Error si no se reciben 2 parámetros. |
---|
| 1335 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 1336 | PART=$(ogDiskToDev "$1" "$2") || return $? |
---|
| 1337 | |
---|
| 1338 | # Obtener tipo de partición. |
---|
| 1339 | TYPE=$(ogGetPartitionType "$1" "$2") |
---|
| 1340 | case "$TYPE" in |
---|
| 1341 | HNTFS) NEWTYPE="NTFS" ;; |
---|
| 1342 | HFAT32) NEWTYPE="FAT32" ;; |
---|
| 1343 | HFAT16) NEWTYPE="FAT16" ;; |
---|
| 1344 | HFAT12) NEWTYPE="FAT12" ;; |
---|
| 1345 | *) ogRaiseError $OG_ERR_PARTITION "$TYPE" |
---|
| 1346 | return $? ;; |
---|
| 1347 | esac |
---|
| 1348 | # Cambiar tipo de partición. |
---|
[ec6de25] | 1349 | ogSetPartitionType $1 $2 $NEWTYPE |
---|
[b09d0fa] | 1350 | } |
---|
| 1351 | |
---|
[2ecd096] | 1352 | |
---|
| 1353 | #/** |
---|
[6cdca0c] | 1354 | # ogUpdatePartitionTable |
---|
[1553fc7] | 1355 | #@brief Fuerza al kernel releer la tabla de particiones de los discos duros |
---|
[42669ebf] | 1356 | #@param no requiere |
---|
[1553fc7] | 1357 | #@return informacion propia de la herramienta |
---|
| 1358 | #@note Requisitos: \c partprobe |
---|
| 1359 | #@warning pendiente estructurar la funcion a opengnsys |
---|
[985bef0] | 1360 | #@version 0.1 - Integracion para Opengnsys - EAC: UpdatePartitionTable() en ATA.lib |
---|
| 1361 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 1362 | #@date 27/10/2008 |
---|
[3915005] | 1363 | #*/ ## |
---|
[42669ebf] | 1364 | function ogUpdatePartitionTable () |
---|
| 1365 | { |
---|
[3915005] | 1366 | local i |
---|
[c6087b9] | 1367 | for i in `ogDiskToDev` |
---|
| 1368 | do |
---|
| 1369 | partprobe $i |
---|
| 1370 | done |
---|
[1553fc7] | 1371 | } |
---|
[1a7130a] | 1372 | |
---|
| 1373 | |
---|
[6cdca0c] | 1374 | #/** @function ogDiskToRelativeDev: @brief Traduce los ID de discos o particiones EAC a ID Linux relativos, es decir 1 1 => sda1 |
---|
| 1375 | #@param Admite 1 parametro: $1 int_numdisk |
---|
| 1376 | #@param Admite 2 parametro: $1 int_numdisk $2 int_partition |
---|
| 1377 | #@return Para 1 parametros traduce Discos Duros: Devuelve la ruta relativa linux del disco duro indicado con nomenclatura EAC.........ejemplo: IdPartition 1 => sda |
---|
| 1378 | #@return Para 2 parametros traduce Particiones: Devuelve la ruta relativa linux de la particion indicado con nomenclatura EAC........... ejemplo: IdPartition 2 1 => sdb1 |
---|
| 1379 | #@warning No definidas |
---|
| 1380 | #@attention |
---|
| 1381 | #@note Notas sin especificar |
---|
[985bef0] | 1382 | #@version 0.1 - Integracion para Opengnsys - EAC: IdPartition en ATA.lib |
---|
| 1383 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 1384 | #@date 27/10/2008 |
---|
[6cdca0c] | 1385 | #*/ |
---|
[985bef0] | 1386 | function ogDiskToRelativeDev () { |
---|
[6cdca0c] | 1387 | if [ $# = 0 ] |
---|
| 1388 | then |
---|
| 1389 | Msg "Info: Traduce el identificador del dispositivo EAC a dispositivo linux \n" info |
---|
| 1390 | Msg "Sintaxis1: IdPartition int_disk -----------------Ejemplo1: IdPartition 1 -> sda " example |
---|
| 1391 | Msg "Sintaxis2: IdPartition int_disk int_partition --Ejemplo2: IdPartition 1 2 -> sda2 " example |
---|
| 1392 | |
---|
| 1393 | return |
---|
| 1394 | fi |
---|
| 1395 | #PART="$(Disk|cut -f$1 -d' ')$2" # se comenta esta linea porque doxygen no reconoce la funcion disk y no crea los enlaces y referencias correctas. |
---|
| 1396 | PART=$(ogDiskToDev|cut -f$1 -d' ')$2 |
---|
| 1397 | echo $PART | cut -f3 -d \/ |
---|
| 1398 | } |
---|
[26c729b] | 1399 | |
---|
[4e1dc53] | 1400 | |
---|
[97da528] | 1401 | #/** @function ogDeletePartitionsLabels: @brief Elimina la informacion que tiene el kernel del cliente og sobre los labels de los sistemas de archivos |
---|
[cc6ad14] | 1402 | #@param No requiere |
---|
| 1403 | #@return Nada |
---|
| 1404 | #@warning |
---|
| 1405 | #@attention Requisitos: comando interno linux rm |
---|
| 1406 | #@note |
---|
[985bef0] | 1407 | #@version 0.1 - Integracion para Opengnsys - EAC: DeletePartitionTable() en ATA.lib |
---|
| 1408 | #@author Antonio J. Doblas Viso. Universidad de Malaga |
---|
| 1409 | #@date 27/10/2008 |
---|
[cc6ad14] | 1410 | #*/ |
---|
[985bef0] | 1411 | function ogDeletePartitionsLabels () { |
---|
[4e1dc53] | 1412 | # Si se solicita, mostrar ayuda. |
---|
| 1413 | if [ "$*" == "help" ]; then |
---|
| 1414 | ogHelp "$FUNCNAME" "$FUNCNAME " \ |
---|
| 1415 | "$FUNCNAME " |
---|
| 1416 | return |
---|
| 1417 | fi |
---|
| 1418 | |
---|
[cc6ad14] | 1419 | rm /dev/disk/by-label/* # */ COMENTARIO OBLIGATORIO PARA DOXYGEN |
---|
| 1420 | } |
---|
| 1421 | |
---|