There are plenty of guides for how to do this online. But I end up spending 20 minutes searching every time I need to remind myself how to do it, so I’m putting it here to save me that hassle.
For the code, I’m just going to assume the drive is /dev/sdb. If you’re following this, make sure you’re using the correct drive name.
Unmount The Drive
Only needed if it’s been mounted already.
sync umount /dev/sdb1
Prepare the Drive
Fire up fdisk
If you already have a filesystem on the disk, wipe it.
Now create a new primary partition.
Enter the partition number.
It’ll now ask you to set the start and end cylinders on the disk. Just hit return for each to accept the defaults.
Change the system type to Linux.
Write the changes to disk (this can’t be undone).
Create the Filesystem
Format the new partition using Ext4.
It’ll now go off and start writing the filesystem. This can take a bit of time, but it should give you an update on what’s being written.
Mount Your Drive
Now your partition has been created, you need to mount it somewhere to use it. Here I’m using /mnt/user/ext/.
mnt /dev/sdb1 /mnt/user/ext/
And there you go.