0

I want to delete existing partition on an ssd and then create a partition and then a file system on the same. How can I do it using a single command based on fdisk?

Rohan
  • 1

1 Answers1

0

You will need at least two commands since fdisk job doesn't include creating file-systems.

I would not recommend fdisk has an automation tool but still it is possible to "script" it:

# Create a new DOS partition table and a new partition on /dev/xvdb:
echo -e "o\nn\np\n1\n\n\nw" | fdisk /dev/xvdb
# Force kernel to re-read partition table on xvdb:
partprobe /dev/xvdb
# Create filesystem
mkfs.ext4 /dev:xvdb1

Basically you need to "record" the sequence of actions you would manually type in fdisk and streamline them using echo to send them to fdisk.

I think parted would be a better tool for the job however.

silmaril
  • 491
  • 3
  • 9