refs #2412 fix bug with extended/logical partitions, remove useless variable, add some comments
parent
9cad17e4f4
commit
0d28787318
|
@ -78,10 +78,10 @@ def ogCreatePartitions (disk, parts):
|
|||
cache_disk, cache_part = CACHEPART.split()
|
||||
if int (ND) == int (cache_disk):
|
||||
CACHESIZE = int (CacheLib.ogGetCacheSize()) * 2
|
||||
|
||||
# Sector de inicio (la partición 1 empieza en el sector 63).
|
||||
IODISCO = ogDiskToDev (disk)
|
||||
IOSIZE = 0
|
||||
fdisk_out = subprocess.run (['fdisk', '-l', IODISCO], capture_output=True, text=True).stdout
|
||||
fdisk_out = subprocess.run (['fdisk', '-l', DISK], capture_output=True, text=True).stdout
|
||||
for l in fdisk_out.splitlines():
|
||||
if 'I/O' not in l: continue
|
||||
items = l.split()
|
||||
|
@ -103,6 +103,7 @@ def ogCreatePartitions (disk, parts):
|
|||
|
||||
sfdisk_input = 'unit: sectors\n\n'
|
||||
NVME_PREFIX = 'p' if 'nvme' in DISK else ''
|
||||
EXTSTART = EXTSIZE = 0
|
||||
for p in parts:
|
||||
# Conservar los datos de la partición de caché.
|
||||
if f'{ND} {PART}' == CACHEPART and CACHESIZE:
|
||||
|
@ -124,14 +125,39 @@ def ogCreatePartitions (disk, parts):
|
|||
if 'CACHE' == TYPE or not ID:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, TYPE)
|
||||
return None
|
||||
# Comprobar tamaño numérico y convertir en sectores de 512 B.
|
||||
|
||||
# Comprobar tamaño numérico y convertir en sectores de 512 B. ## BUG!! qué pasa si IOSIZE==4096
|
||||
SIZE *= 2
|
||||
|
||||
## TODO ojo, no puede haber dos extendidas
|
||||
|
||||
# Comprobar si la partición es extendida.
|
||||
EXTSTART = EXTSIZE = 0
|
||||
if 5 == ID:
|
||||
if PART > 4:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, '')
|
||||
return None
|
||||
|
||||
## la extendida debe ser:
|
||||
## - si no estamos creando cache: /dev/sda4
|
||||
## - si sí estamos creando cache: /dev/sda3
|
||||
## de lo contrario, crea eg. esto:
|
||||
## Device Boot Start End Sectors Size Id Type
|
||||
## /dev/sda1 63 222444728 222444666 106,1G 82 Linux swap / Solaris
|
||||
## /dev/sda2 222444729 244889394 22444666 10,7G 5 Extended <---------
|
||||
## /dev/sda3 244889395 251334060 6444666 3,1G 83 Linux <---------
|
||||
## /dev/sda4 314103633 314572766 469134 229,1M ca unknown
|
||||
## /dev/sda5 222446777 224891442 2444666 1,2G 83 Linux
|
||||
## /dev/sda6 224891443 229558330 4666888 2,2G 83 Linux
|
||||
## la sda2 es extendida, y las lógicas deberían ser sda5, sda6, sda7
|
||||
## pero esto mete una sda3 como lógica, y luego va el cache que es primaria... WTF
|
||||
error_in_extended = False
|
||||
if CACHEPART and PART != 3: error_in_extended = True
|
||||
if not CACHEPART and PART != 4: error_in_extended = True
|
||||
if PART > 4: error_in_extended = True
|
||||
if error_in_extended:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f'No se puede definir la partición extendida en la partición "{PART}"')
|
||||
return None
|
||||
|
||||
# El inicio de la primera partición logica es el de la extendida más 4x512
|
||||
EXTSTART = START+2048
|
||||
EXTSIZE = SIZE-2048
|
||||
|
|
Loading…
Reference in New Issue