Skip to content

Instantly share code, notes, and snippets.

@nero-dv
Last active April 16, 2025 16:55
Show Gist options
  • Save nero-dv/659b6d85d7fa3806ce89fc4811375d3c to your computer and use it in GitHub Desktop.
Save nero-dv/659b6d85d7fa3806ce89fc4811375d3c to your computer and use it in GitHub Desktop.
Formatting an external drive and starting clean with a GPT partition table. If you run: sudo mkfs.ext4 /dev/sdb, you're formatting the entire raw device as an ext4 without any partition table. This is okay in some specific situations, but generally not recommended for general purpose storage.
read -p "Enter drive path (ex: /dev/sdb): " drivepath
# wipe all partitions on 'drivepath'
sudo wipefs -a $drivepath
# create a gpt partition table, ext4 partition
sudo parted $drivepath mklabel gpt
sudo parted -a opt $drivepath mkpart primary ext4 0% 100%
sudo mkfs.ext4 drivepath\1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment