Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

363
Vistas
Bash script with fdisk

I came across this bash script to expand the fs after making the root volume larger on an ami made with Packer. Can someone please explain the meaning of the fdisk options in the heredoc?

#!/bin/bash
fdisk /dev/xvda <<EEOF
d
n
p
1
1

w
EEOF
exit 0

Thank you!

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

To determine what these mean, look at the built-in help from fdisk. Details may differ based on your implementation; for mine, that looks like this:

Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table

...so:

  • d deletes a partition (presumably your script was developed for a version of fdisk where if there's only one partition, there's no prompt over which to delete).
  • n creates a new partition.
    • p indicates that it's a primary partition being created.
    • 1 indicates that it should be primary partition #1
    • 1 indicates that it should start at sector #1
    • the following blank line accepts the default end sector
  • w writes changes to disk.
over 4 years ago · Santiago Trujillo Denunciar

0

Try this and adjust for your conditions:

#!/bin/bash

HEREDOC_VAR_1='p q ' 
echo $HEREDOC_VAR_1

HEREDOC_VAR_2='n q ' 
echo $HEREDOC_VAR_2

echo "$HEREDOC_VAR_1" | fdisk /dev/xvda
echo "$HEREDOC_VAR_2" | fdisk /dev/xvda
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda