refs #2414 make initCache.py output more silent
parent
83c1c7763a
commit
73721d70f7
|
@ -94,8 +94,8 @@ def ogCreateCache (ndsk=1, part=4, sizecache=0):
|
|||
sfdisk_line = f'{DISK}{NVME_PREFIX}{part} : start= {START}, size= {SIZE}, type={ID}, name=CACHE'
|
||||
elif 'MSDOS' == get_ptt:
|
||||
# Si la tabla de particiones no es valida, volver a generarla.
|
||||
if subprocess.run (['parted', '-s', DISK, 'print']).returncode: ## if True, then parted failed
|
||||
subprocess.run (['fdisk', DISK], input='w\n', text=True)
|
||||
if subprocess.run (['parted', '-s', DISK, 'print'], capture_output=True).returncode: ## if True, then parted failed
|
||||
subprocess.run (['fdisk', DISK], input='w\n', text=True, capture_output=True)
|
||||
|
||||
ID = DiskLib.ogTypeToId ('CACHE', 'MSDOS')
|
||||
sfdisk_line = f'{DISK}{NVME_PREFIX}{part} : start= {START}, size= {SIZE}, Id={ID}'
|
||||
|
@ -143,15 +143,15 @@ def ogDeleteCache():
|
|||
ptt = DiskLib.ogGetPartitionTableType (ndisk)
|
||||
if 'GPT' == ptt:
|
||||
# Si la tabla de particiones no es valida, volver a generarla.
|
||||
if subprocess.run (['sgdisk', '-p', disk]).returncode: ## if True, then sgdisk failed
|
||||
subprocess.run (['gdisk', disk], input='2\nw\nY\n', text=True)
|
||||
if subprocess.run (['sgdisk', '-p', disk], capture_output=True).returncode: ## if True, then sgdisk failed
|
||||
subprocess.run (['gdisk', disk], input='2\nw\nY\n', text=True, capture_output=True)
|
||||
subprocess.run (['sgdisk', disk, f'-d{npart}'])
|
||||
elif 'MSDOS' == ptt:
|
||||
# Si la tabla de particiones no es valida, volver a generarla.
|
||||
if subprocess.run (['parted', '-s', disk, 'print']).returncode: ## if True, then parted failed
|
||||
subprocess.run (['fdisk', disk], input='w', text=True)
|
||||
if subprocess.run (['parted', '-s', disk, 'print'], capture_output=True).returncode: ## if True, then parted failed
|
||||
subprocess.run (['fdisk', disk], input='w', text=True, capture_output=True)
|
||||
# Eliminar la partición de caché.
|
||||
subprocess.run (['fdisk', disk], input=f'd\n{npart}\nw', text=True)
|
||||
subprocess.run (['fdisk', disk], input=f'd\n{npart}\nw', text=True, capture_output=True)
|
||||
# Borrar etiqueta de la caché.
|
||||
if os.path.exists ('/dev/disk/by-label/CACHE'):
|
||||
os.unlink ('/dev/disk/by-label/CACHE')
|
||||
|
|
|
@ -50,6 +50,8 @@ def main (NDISK, NPART, SIZE, MOUNT):
|
|||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_CACHE, 'failed to create cache')
|
||||
return False
|
||||
DiskLib.ogUpdatePartitionTable()
|
||||
else:
|
||||
print("[10] Partición de caché solicitada es del mismo tamaño que la existente, ignorar.")
|
||||
|
||||
# Si caché no montada y no formateada o cambia el tamaño: formatear.
|
||||
cache = CacheLib.ogFindCache()
|
||||
|
|
Loading…
Reference in New Issue