16

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

Also what is the best practice for formatting a USB stick? Is it best to format the USB stick only for Linux use rather than for both Linux and Windows use?

I am new to Linux and I am using Ubuntu 20.04.

Would appreciate exact steps to follow.

Reme
  • 303
  • 2
  • 3
  • 7
  • This link may help you decide what file system to use. - It might be a good idea to use NTFS, because it works well both with Ubuntu and Windows. If you want the fastest and most flexible file system for Ubuntu, you should use a Linux file system, for example ext4, but Windows refuses to read it. - In Ubuntu you can install and use the graphical tool gparted to create [a partition table and] one or more partitions with a suitable file system. – sudodus Oct 10 '20 at 17:15
  • 1
    If you don't need to use any special file attribute and permission stuff, you can use NTFS as a common denominator. NTFS formatted disks work reliably on both systems (Windows and Linux). – FedKad Oct 10 '20 at 17:42
  • Thank you I will use gparted and format to NTFS. – Reme Oct 10 '20 at 22:23

2 Answers2

16

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. Since kernel version 5.4, exFAT is a native filesystem for Linux and does not rely on FUSE anymore.

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

$ sudo apt install exfatprogs # Debian/Ubuntu
$ sudo dnf install exfatprogs # Red Hat/Fedora/CentOS
$ sudo pacman -S exfatprogs # Arch Linux/Manjaro

Note: On systems with older kernels, use exfat-utils instead of exfatprogs.

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 
    
  3. Unmount mounted partitions.
    $ umount /dev/sdb1
    
  4. 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.
  5. 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.
    
  • Beware though, as exFAT is patent-encumbered, and thus leaves you at the goodwill of a company that has been convicted of large and organized crimes many times. Including luring people into relying and becoming dependent on a technology in order to strongarm them into a situation harmful to them. (The biggest example being JScript in Internet Explorer being used almost kllling all other browser makers at the turn of the millennium. OOXML (Office Open XML, not to be confused with OpenDocument by OpenOffice XML) is another example.) // That is why many people still use FAT32. –  Jul 23 '22 at 16:46
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.

Gonzz
  • 21
  • 1