How do you format a usb stick through the terminal?
4 Answers
You can use the fdisk command.
You can also use the mkfs command
Here is a link on using the fdisk command in Ubuntu
Using mkfs in Ubuntu (here)
2If you can connect to the server via ssh and become root on the server (i.e. if you have the permissions required to format partitions), then you can use the Ubuntu standard Disk Utility over ssh to manage disks just like you would on your desktop/laptop computer. Just start up the disk utility on your local computer and go to File -> Connect to Server, and type in the ssh name of your server.
I like using the Disk Utility because it won't let you do silly data-destroying things like formatting mounted filesystems, or resizing partitions without first resizing the underlying filesystem.
I don't know if the packages required for this are installed in Ubuntu Server by default, and I don't remember what they are. If anyone does know, please edit or comment.
Find the device
$ df -h
...
/dev/sdc1 30G 2.8G 28G 10% /media/agp/UNTITLEDFormat device
sudo mkfs -t vfat /dev/sdc1Final note
you can use vfat or any other available format in your system
$ find /sbin/ -name 'mkfs.*'
/sbin/mkfs.ext3
/sbin/mkfs.minix
/sbin/mkfs.bfs
/sbin/mkfs.cramfs
/sbin/mkfs.msdos
/sbin/mkfs.ext4dev
/sbin/mkfs.ext4
/sbin/mkfs.vfat
/sbin/mkfs.fat
/sbin/mkfs.ext2
/sbin/mkfs.ntfs with:
cat /proc/partitionsyou can see all detected partitions by the kernel
major minor #blocks name
8 0 4883737600 sda
8 1 4883735552 sda1to format the "right" one with:
mkfs.vfat /dev/<your_device|partition>will format with fat32 file system