Saltar al contenido
Marcos Peña
Menú
  • Acerca de…
Menú

Cómo aumentar el tamaño de la partición /boot

Publicada el enero 27, 2019febrero 18, 2020 por Marcos

Escenario

Cloudatcost es una empresa canadiense que, entre otras cosas, ofrece un servicio de hosting que, en vez de pagar todos los meses, lo compras con un único pago. Te permiten comprar un número de CPUs, espacio en disco y cantidad de memoria RAM para que la gestiones como mejor te convenga, distribuyendo los recursos entre una o varias instancias.

Problema

Pues resulta que compré un paquete de recursos hace un tiempo y el otro día decidí desplegar una instancia desde su panel de control. Seleccioné una imagen de ubuntu 16.04, le asigné 2 cores, 2 Gb de ram y 50 gigas de disco SSD. Una vez finalizada la configuración de la instancia puedes acceder a ella con el usuario root y con la contraseña que se indica en el panel de control. Hasta aquí todo bien, después de hacer login por SSH, lo primero que hago es actualizar el sistema operativo:
Shell
1
$ sudo apt-get update && sudo apt-get dist-upgrade
Pero, al cabo de un rato, el proceso de actualización se detiene porque la partición de /boot no tiene suficiente espacio disponible. En mi caso no llegaba ni a los cien megas.

Solución

Ampliar la partición obviamente, pero no es tarea baladí. Después de probar varias supuestas soluciones, por fin di con este artículo de hace siete años que describe los pasos a seguir. Aquí los resumo, por si alguna vez me da por desplegar otra instancia:

Pasos a seguir

  1. Listar el contenido de las tablas de partición:
  2. Shell
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # fdisk -l
    Disk /dev/sda: 750.2 GB, 750156374016 bytes
    255 heads, 63 sectors/track, 91201 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0001a00e
    Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          13      104391   83  Linux
    /dev/sda2              14        1057     8385930   82  Linux swap / Solaris
    /dev/sda3            1058       91201   724081680   83  Linux
  3. Asegúrate que /dev/sda1 es la partición de boot y /dev/sda2 el la partición swap, apunta la etiqueta de la partición swap
  4. Shell
    1
    2
    # blkid /dev/sda1 /dev/sda2
    /dev/sda1: LABEL="/boot" UUID="9d056123-abcc-4522-aaaa-126dc8b27890" SEC_TYPE="ext2" TYPE="ext3"  /dev/sda2: TYPE="swap" LABEL="SWAP-sda2"
  5. Deshabilita el espacio swap.
  6. Shell
    1
    # swapoff -a
  7. Desmonta la partición /boot
  8. Shell
    1
    # umount /boot
  9. Elimina journal de /dev/sda1
  10. Shell
    1
    # tune2fs -O ^has_journal /dev/sda1
  11. Abre la tabla de particiones
  12. Shell
    1
    # fdisk /dev/sda
  13. Borra la partición swap
  14. Shell
    1
    2
    Command (m for help): d
    Partition number (1-4): 2
  15. Crea una nueva partición swap cuyo primer cilindro sea 2-3 veces mayor que el original.
  16. 1
    2
    3
    4
    5
    6
    7
    8
    9
    Command (m for help): n
    Command action
    e   extended
    p   primary partition (1-4)
    p
    Partition number (1-4): 2
    First cylinder (14-91201, default 14): 42
    Last cylinder, +cylinders or +size{K,M,G} (42-1057, default 1057):
    Using default value 1057
  17. Cambia el tipo de disco en /dev/sda2 a 82 – Linux swap / Solaris.
  18. Shell
    1
    2
    3
    4
    Command (m for help): t
    Partition number (1-4): 2
    Hex code (type L to list codes): 82
    Changed system type of partition 2 to 82 (Linux swap / Solaris)
  19. Borra la partición /dev/sda1.
  20. Shell
    1
    2
    Command (m for help): d
    Partition number (1-4): 1
  21. Añade una nueva partición en /dev/sda1 usando los valores por defecto
  22. Shell
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Command (m for help): n
    Command action
    e   extended
    p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-91201, default 1):
    Using default value 1
    Last cylinder, +cylinders or +size{K,M,G} (1-41, default 41):
    Using default value 41
  23. Verifica la tabla de particiones
  24. Shell
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    Command (m for help): p
    Disk /dev/sda: 750.2 GB, 750156374016 bytes
    255 heads, 63 sectors/track, 91201 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0001a00e
    Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1          41      329301   83  Linux
    /dev/sda2              42        1057     8161020   82  Linux swap / Solaris
    /dev/sda3            1058       91201   724081680   83  Linux
  25. Marca la primera partición como «bootable»
  26. Shell
    1
    2
    3
    Command (m for help): a
    Partition number (1-4): 1
    Command (m for help): w
  27. Si la tabla de partición es correcta, escribe en disco con w. De lo contrario, sal con q.
  28. Shell
    1
    2
    3
    4
    5
    6
    7
    Command (m for help): w
    The partition table has been altered!
    Calling ioctl() to re-read partition table.
    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table. The new table will be used at
    the next reboot or after you run partprobe(8) or kpartx(8)
    Syncing disks.
  29. Comprueba que no haya errores en /dev/sda1 for errors para asegurarnos que no hemos corrompido nada en /boot.
  30. Shell
    1
    2
    3
    4
    5
    6
    7
    8
    # e2fsck -f /dev/sda1
    e2fsck 1.41.12 (17-May-2010)
    Pass 1: Checking inodes, blocks, and sizes
    Pass 2: Checking directory structure
    Pass 3: Checking directory connectivity
    Pass 4: Checking reference counts
    Pass 5: Checking group summary information
    /boot1: 90/26104 files (7.8% non-contiguous), 72369/104388 blocks
  31. Reinicia el sistema
  32. Shell
    1
    # reboot
  33. Deshabilita el swap
  34. Shell
    1
    # swapoff -a
  35. Si no se puede deshabilitar y el sistema devuelve el siguiente error:
  36. Shell
    1
    swapoff: cannot find the device for UUID=<uuid></uuid>
    Pasa directamente al siguiente paso.
  37. Recrea el swap usando la etiqueta de la partición del paso 2
  38. Shell
    1
    # mkswap -L SWAP-sda2 /dev/sda2
  39. Habilita el swap
  40. Shell
    1
    # swapon -a
  41. Desmonta /boot
  42. Shell
    1
    # umount /boot
  43. Redimensiona la partición /dev/sda1.
  44. Shell
    1
    2
    3
    4
    # resize2fs /dev/sda1
    resize2fs 1.41.12 (17-May-2010)
    Resizing the filesystem on /dev/sda1 to 329300 (1k) blocks.
    The filesystem on /dev/sda1 is now 329300 blocks long.
  45. Añade journal a /dev/sda1
  46. Shell
    1
    2
    3
    4
    5
    # tune2fs -j /dev/sda1
    tune2fs 1.41.12 (17-May-2010)
    Creating journal inode: done
    This filesystem will be automatically checked every -1 mounts or
    0 days, whichever comes first.  Use tune2fs -c or -i to override.
  47. Monta /boot
  48. Shell
    1
    # mount /boot
¡Listos!

Deja una respuesta Cancelar la respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Artículos

  • abril 2022
  • marzo 2022
  • febrero 2022
  • enero 2022
  • diciembre 2021
  • noviembre 2021
  • octubre 2021
  • septiembre 2021
  • agosto 2021
  • julio 2021
  • junio 2021
  • mayo 2021
  • abril 2021
  • marzo 2021
  • febrero 2021
  • enero 2021
  • diciembre 2020
  • noviembre 2020
  • octubre 2020
  • septiembre 2020
  • agosto 2020
  • julio 2020
  • junio 2020
  • mayo 2020
  • abril 2020
  • marzo 2020
  • febrero 2020
  • enero 2020
  • diciembre 2019
  • noviembre 2019
  • octubre 2019
  • septiembre 2019
  • agosto 2019
  • julio 2019
  • junio 2019
  • mayo 2019
  • abril 2019
  • marzo 2019
  • febrero 2019
  • enero 2019
  • noviembre 2018
  • octubre 2018
  • julio 2016
  • mayo 2016
  • abril 2016
  • agosto 2015
  • febrero 2014
  • junio 2013
  • febrero 2013
  • noviembre 2012
  • octubre 2012
  • septiembre 2012
  • abril 2012
  • enero 2012

Categorías

  • Cómo
  • Consejos
  • Hacks
  • Sin sentido
  • Tutorial

Etiquetas

apache API aws cache Centos Codeigniter EAC firefox flash freebsd freenas gmail Google guacamole java Javascript jQuery kubuntu Linux mysql nas4free nginx php plesk postfix python react rtorrent Seguridad sftp sonata-admin spring spring-boot sql ssh ssl symfony symfony2 symfony4 thymeleaf ubuntu vnc wget windows wine

Entradas recientes

  • Confirmación antes de apagar
  • cURL error 60: SSL certificate problem: unable to get local issuer certificate
  • Oracle JDK 7 is NOT installed.
  • ssh: connect to host: Connection refused
  • Restringir acceso a un bucket de AWS s3 por IP

Comentarios recientes

  • Marcos en Deobbing flash
  • Irosales en Deobbing flash
  • Instalación certificado SSL de un vendedor – Marcos Peña en Instala un certificado SSL en tres pasos
  • gerMdz en Cómo instalar un certificado letsencrypt para un sitio gestionado por Cloudflare
  • Jose Olalla en Cómo ampliar el espacio en disco en 1and1

Archivos

  • abril 2022
  • marzo 2022
  • febrero 2022
  • enero 2022
  • diciembre 2021
  • noviembre 2021
  • octubre 2021
  • septiembre 2021
  • agosto 2021
  • julio 2021
  • junio 2021
  • mayo 2021
  • abril 2021
  • marzo 2021
  • febrero 2021
  • enero 2021
  • diciembre 2020
  • noviembre 2020
  • octubre 2020
  • septiembre 2020
  • agosto 2020
  • julio 2020
  • junio 2020
  • mayo 2020
  • abril 2020
  • marzo 2020
  • febrero 2020
  • enero 2020
  • diciembre 2019
  • noviembre 2019
  • octubre 2019
  • septiembre 2019
  • agosto 2019
  • julio 2019
  • junio 2019
  • mayo 2019
  • abril 2019
  • marzo 2019
  • febrero 2019
  • enero 2019
  • noviembre 2018
  • octubre 2018
  • julio 2016
  • mayo 2016
  • abril 2016
  • agosto 2015
  • febrero 2014
  • junio 2013
  • febrero 2013
  • noviembre 2012
  • octubre 2012
  • septiembre 2012
  • abril 2012
  • enero 2012

Categorías

  • Cómo
  • Consejos
  • Hacks
  • Sin sentido
  • Tutorial

Meta

  • Acceder
  • Feed de entradas
  • Feed de comentarios
  • WordPress.org
© 2022 Marcos Peña | Funciona con Minimalist Blog Tema para WordPress