How to format USB to ext4 via SSH?

Can someone point me to a tutorial that covers this operation? I can't seem to locate one. I would like to reformat one of my USB drives while I'm SSH into the router.

fdisk + mkfs ?

1 Like

If you don't need to repartition, only change the filesystem type, you can just run mkfs.ext4 on the existing partition.

  • Install the package e2fsprogs
  • Connect the drive and identify the partition to be formatted. Unmount it if it is mounted. Of course, any existing files in that partition are about to be lost by reformatting.
  • Run mkfs.ext4 /dev/sdXN replacing X and N with your drive letter and partition number.

If You can not see the usb stick.


Thanks. I'll give it a shot.