How to format pen drive in ubuntu via command line with sudo.
Asked
Active
Viewed 3,566 times
1 Answers
2
Erase all data, and create a single partition that takes up all USB with an ext4 filesystem:
printf 'o\nn\np\n1\n\n\nw\n' | sudo fdisk /dev/sdX
sudo mkfs.ext4 /dev/sdX1
Choose X based on the output of:
sudo lsblk
sudo fdisk -l
fdisk automation explained at: https://superuser.com/questions/332252/creating-and-formating-a-partition-using-a-bash-script

Akshay Patil
- 320
- 1
- 4
- 10