source: client/shared/scripts/samples/smartPartition @ 5d05b06

Last change on this file since 5d05b06 was c255425, checked in by adv <adv@…>, 7 years ago

#863 smartPartition ejemplo para establecer tablas de particionado
multiples según agrupamiento de tamaños de disco

  • Property mode set to 100644
File size: 2.2 KB
Line 
1#!/bin/bash
2#/**
3#      smartPartition.template
4#@brief  particiona los clientes del laboratorio virtual.
5#@param 1
6#@ejemplo:
7#@return: Scripts de ejemplo para establecer particionado según tamaño.
8#@exception OG_ERR_ NOTFOUND      Disco duro no encontrador.
9#@note
10#@todo:
11#@version 0.1 primera version
12#@author  adv
13#@date    2018/07/08
14
15#Calculamos el numero de discos
16NDISK=$(ogDiskToDev | wc -w)
17
18#Si no hay discos, error
19[ -z $NDISK ] && exit $(ogRaiseError $OG_ERR_NOTFOUND "ogDiskToDev | wc -w")
20
21#asignamos contador al primer disco de OpenGnsys
22COUNTER=1
23until [ $COUNTER -gt $NDISK ]; do
24        ogUnmountAll $COUNTER
25        ogDeletePartitionTable $COUNTER
26    ogCreatePartitionTable $COUNTER MSDOS
27    ogUpdatePartitionTable $COUNTER
28        let COUNTER=COUNTER+1
29done
30
31#Establecemos las Particiones CACHE con tamaños diferentes según la capacidad del disco.
32#Si el PC tiene dos discos duros, el segundo será completo para la CACHE.
33#establecemos rangos de las capacidades con expresiones regulares:  https://goo.gl/gJnK7g
34case $NDISK in
35        1)
36                #Calcular el tamaño máximo del disco duro redondeando a la baja en 500 MB para evitar problemas de calculo"
37                SIZE_DISK1=$(expr $(ogGetDiskSize 1) - 500000)
38                #entre 70 y 73'9GB
39                ogCheckStringInReg $SIZE_DISK1 "^7[0-3][0-9]{6}$" &&  initCache 1 4 32000000 NOMOUNT
40                #entre 50 y 52'9
41                ogCheckStringInReg $SIZE_DISK1 "^5[0-2][0-9]{6}$" &&  initCache 1 4 12000000 NOMOUNT
42        ;;
43        2)
44                #Calcular el tamaño máximo del disco duro redondeando a la baja en 500 MB para evitar problemas de calculo"
45                SIZE_DISK2=$(expr $(ogGetDiskSize 1) - 500000)
46                initCache 2 4 $SIZE_DISK2 NOMOUNT
47        ;;
48esac
49
50#El particionado para los sistemas operativos identicos para todos.
51#Requiere tener una tabla de particiones previa.
52ogCreatePartitions 1  NTFS:19000000 LINUX:19000000 EMPTY:0;
53
54#asignamos contador al primer disco de OpenGnsys
55COUNTER=1
56until [ $COUNTER -gt $NDISK ]; do
57        ogBootMbrGeneric $COUNTER
58        ogSetPartitionActive 1 $COUNTER
59        ogListPartitions $COUNTER
60        ogGetPartitionActive $COUNTER
61        let COUNTER=COUNTER+1
62done
Note: See TracBrowser for help on using the repository browser.