Formatting a disk or partition in Linux writes a new filesystem layout to the target device so the kernel can mount it cleanly for application data, removable media, or a newly attached data volume.
Linux exposes storage as block devices such as /dev/vdb and /dev/vdb1. lsblk is the quickest way to identify the correct target and see whether it is already mounted, wipefs shows any filesystem signatures that are about to be replaced, mkfs.ext4 writes the new ext4 metadata, and blkid reads the new label, type, and UUID directly from the device after the format finishes.
Formatting is destructive because the old filesystem metadata is replaced immediately. The flow below uses ext4 on a current Ubuntu-based system and assumes the target is not the running root or boot filesystem; if the device still serves live workloads, unmount it first or continue from maintenance media instead. In minimal rescue or container environments, blkid is the more direct post-format confirmation because it reads the device itself instead of waiting for udev metadata to catch up.
Steps to format a disk or partition in Linux:
- List the available block devices to identify the exact disk or partition that should be formatted.
$ lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS NAME SIZE TYPE FSTYPE MOUNTPOINTS nvme0n1 100G disk |-nvme0n1p1 512M part vfat /boot/efi `-nvme0n1p2 99.5G part ext4 / vdb 64G disk `-vdb1 64G part
Use a partition path such as /dev/vdb1 when only one volume should be reformatted. Use a whole-disk path such as /dev/vdb only when the filesystem should live directly on the disk without partitions.
- If the target from the previous step is mounted, unmount it before writing the new filesystem.
$ sudo umount /dev/vdb1
No output usually means the unmount completed cleanly.
Related: How to unmount a disk in Linux
- Inspect any existing signatures on the target before overwriting them.
$ sudo wipefs --output DEVICE,OFFSET,TYPE,UUID,LABEL /dev/vdb1 DEVICE OFFSET TYPE UUID LABEL vdb1 0x36 vfat D408-739B USB vdb1 0x0 vfat D408-739B USB vdb1 0x1fe vfat D408-739B USB
If wipefs returns no data rows, the target does not currently expose a filesystem or partition-table signature that wipefs can identify.
- Create the new ext4 filesystem and assign a label while writing the metadata.
$ sudo mkfs.ext4 -L data /dev/vdb1 Creating filesystem with 16384 4k blocks and 16384 inodes Allocating group tables: done Writing inode tables: done Creating journal (1024 blocks): done Writing superblocks and filesystem accounting information: done
This step overwrites the previous filesystem metadata on the selected target. Replace data with the label required for that filesystem, and switch to another mkfs.* helper only when a different filesystem is intentionally required on the same confirmed device path.
- Read the new filesystem metadata directly from the device to confirm that the format completed.
$ sudo blkid /dev/vdb1 /dev/vdb1: LABEL="data" UUID="0cb29b3d-16ed-499c-9ed3-4deca785119f" BLOCK_SIZE="4096" TYPE="ext4"
This is the decisive success check for the format step. The UUID value is the stable identifier normally used later in /etc/fstab for persistent mounts.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
