What is the best way to format a USB stick such that it can be used with both Linux and Windows?

Solution 1:

Currently, the best filesystem to share content between Windows and Linux is exFAT, specially on USB pendrives and SD cards. exFAT is, roughly speaking, a revision of FAT32 without the 4GB max file size limitation.

If not installed, you will have to install exFAT support.

$ sudo apt install exfat-utils

From here, you have two options. Use a graphical tool like gparted or the command line (which is more fun). Find below steps for the latter.

  1. Plug-in the USB pendrive/SD card.
  2. Identify the device. It should be one of /dev/sd?. In a terminal, run the below command which will show connected devices and partition mount points. In this example, /dev/sdb is the device, with two partitions, the first of which is mounted.
$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb           8:16   1    15G  0 disk 
├─sdb1        8:17   1   256M  0 part /media/myuser/mydevice
└─sdb2        8:18   1  14,7G  0 part 
nvme0n1     259:0    0 931,5G  0 disk 
├─nvme0n1p1 259:1    0   512M  0 part /boot/efi
├─nvme0n1p2 259:2    0    64G  0 part /
├─nvme0n1p3 259:3    0   256G  0 part /home
├─nvme0n1p4 259:4    0    38G  0 part [SWAP]
├─nvme0n1p5 259:5    0   448G  0 part /data
├─nvme0n1p6 259:6    0    16M  0 part 
└─nvme0n1p7 259:7    0   125G  0 part 
  1. Unmount mounted partitions.
$ umount /dev/sdb1
  1. Create a new partition table and partition of type HPFS/NTFS/exFAT.
$ sudo fdisk /dev/sdb # Pay attention! No final digit is used.

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help):
  • Create a new (dos) partition table: press o and enter.
  • Create a new partition: press n, enter and accept default options.
  • Change the partition type to HPFS/NTFS/exFAT: press t, enter, 7, enter.
  • Quit saving changes: press w and enter.
  • You can quit without saving changes: press q and enter.
  1. Format the partition.
$ sudo mkfs.exfat -n "my label" /dev/sdb1 # Pay attention! Final digit is used.
mkexfatfs 1.3.0
Creating... done.
Flushing... done.
File system created successfully.

Solution 2:

I am also a kind of newbie into the Linux world, even though I have used Ubuntu for years now, so I think that I can give you a kind of straightforward answer.

There are some file systems such as ext4 that will perform better in a Linux environment, but because of how it is built, the Linux Virtual File System (also known as VFS) can virtualize almost any filesystem, such as NTFS. So if you want to share the usage of that USB stick I wouldn't worry anymore and I would format it into NTFS, since a Linux machine can deal with it with no problem, and you will be using a native file system when using windows.

Btw, if you are looking for the best way to do it, I would recommend you the Gnome Disk Utility (you can find it searching for Disk at the ubuntu program launcher), it's very newbie-friendly and easy to use.