Format a USB stick for Linux and Windows
How to prepare a USB stick on Linux to be used with both Linux and Windows (and probably macOS as well) It can be useful to share things between two different computers using a USB stick. If they both run the same operating system, there is no major issue. Nevertheless, if one is running Linux and the other is running Windows, you need to be careful with the filesystem you'll use to format the USB stick. You need to pick up a filesystem that can be read by the two operating systems. Long story short, give Linux kernel 5.4 was released in November 2019. I will assume your system is up-to-date and focus on using In order to ensure If using Otherwise, you'll have something like the following response: Beware that your path may vary depending on the Linux system you're running on. In case Now that Before partitioning the USB stick, you need first to know its device name. Usually, using The USB stick I use is a 60GB SanDisk Ultra Fit, so I know its device name is If it is impossible to identify the stick thanks to this command, we can use Once plugged in, you should retrieve messages similar to the following ones: We can extract the device name Now that we've found the device we need to deal with, let's partition it. Partitioning a disk will make all its data inaccessible. Recovering it might be possible but it is complex with no guarantee of success. Please back up your data before partitioning the USB stick if you want to keep it. First, we need to choose the layout of the partition table between MBR and GPT. You'll find many comparisons between the two partition tables on the Internet 3. To make it simple, MBR is older, may have broader compatibility with older operating systems and is limited to 4 primary partitions for a total size of 2TB maximum. GPT is newer, more robust, has unlimited partitions and can manage up to 9.4 ZB of storage. Last but not least, GPT is only supported by modern UEFI firmware for booting while MBR may be able to boot almost everywhere. We don't care here as we just focus on transferring data between Linux and Windows. Being more recent, I thought GPT would be more suitable. Nevertheless, after several tests, I noticed that using a GPT partition table prevents proper detection of the USB stick on the Windows system I played with. It is not accessible from the Explorer even if we can see it in the disk management. Tests just consist of partitioning and formatting the USB stick as described below from a Linux system, putting a dummy text file on it, unplugging it, plugging it into a Windows system and trying to retrieve the file. Last but not least, if I plug the USB stick having a GPT partition table into Windows, destroy the partition, recreate it and format it with exFAT, then it works... The USB stick is properly recognized by the Windows system and remains accessible by the Linux system. I may be missing some options in the partition creation for GPT in order to have it properly handled by Windows. The next two parts will describe the use of each partition table. You only need to apply one and I would advise you to go with MBR. This is the partition table I recommend according to tests I made. Skip this part if you want to use a GPT partition table anyway. First, create the disk: Then, create the unique partition that uses the entire USB stick: We can use Now that the partition is created, we just need to format it. I DO NOT recommend this partition table according to tests I made. Unless you know what you're doing, I would advise to use an MBR partition table instead. First, create the disk: Then, create the unique partition that uses the entire USB stick: We can use Now that the partition is created, we just need to format it. The partition has been labelled You can check everything went well with the following command: You can now use your USB stick both on Linux and Windows (and probably on macOS but I cannot test it). https://askubuntu.com/questions/1281698/what-is-the-best-way-to-format-a-usb-stick-such-that-it-can-be-used-with-both-li ↩ Searching for "MBR vs GPT" or "MBR vs GPT usb drive" might be enough.exFAT a try 1.exFAT 2 is a filesystem designed by Microsoft in 2006 and specifically optimized for flash memory such as USB sticks and SD cards. It has been adopted by the SD Association as the default file system for some SD cards larger than 32GB. It is not only supported by Windows (since Windows Vista SP1 and Windows Server 2008) but also by macOS (since 10.6.5) and Linux (since kernel 5.4 and even before via FUSE). Can you format a partition with
exFAT?exFAT native support by the Linux kernel. If it is not the case, I would strongly advise upgrading your Linux kernel to a maintained version. At the time of writing, all the long-term release kernels have exFAT support (post kernel 5.4 release).exFAT tools are there, just check if mkfs.exfat is present on your system.exFAT to format a partition is possible, you'll have the following response:
#> /usr/sbin/mkfs.exfat
#> which: no mkfs.exfat in (/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin)
exFAT tools are missing, just install them according to your system:exFAT tools are available, let's partition the USB stick. Identify the USB stick
lsblk is enough to identify your USB stick with the following command:
#> NAME VENDOR MODEL SIZE TYPE TRAN MOUNTPOINT
#> sdX ATA Micron_1100_MTFDDAV256TBN 238,5G disk sata
#> ├─sdX1 554M part
#> ├─sdX2 4G part
#> └─sdX3 234G part
#> └─luks-redacted-0000-0000-0000-000000000000 234G crypt /
#> sdY SanDisk Ultra Fit 57,3G disk usb
#> ├─sdY1 2G part
#> └─sdY2 173M part
#> zram0 7,6G disk [SWAP]
sdY. Beware that yours may differ.dmesg by:sudo dmesg --follow-new to display all the upcoming messages
#> [ <timestamp>] usb 2-2: new SuperSpeed USB device number 3 using xhci_hcd
#> [ <timestamp>] usb 2-2: New USB device found, idVendor=0781, idProduct=5583, bcdDevice= 1.00
#> [ <timestamp>] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
#> [ <timestamp>] usb 2-2: Product: Ultra Fit
#> [ <timestamp>] usb 2-2: Manufacturer: SanDisk
#> [ <timestamp>] usb 2-2: SerialNumber: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#> [ <timestamp>] usb-storage 2-2:1.0: USB Mass Storage device detected
#> [ <timestamp>] scsi host1: usb-storage 2-2:1.0
#> [ <timestamp>] scsi 1:0:0:0: Direct-Access SanDisk Ultra Fit 1.00 PQ: 0 ANSI: 6
#> [ <timestamp>] sd 1:0:0:0: [sdY] 120176640 512-byte logical blocks: (61.5 GB/57.3 GiB)
#> [ <timestamp>] sd 1:0:0:0: [sdY] Write Protect is off
#> [ <timestamp>] sd 1:0:0:0: [sdY] Mode Sense: 43 00 00 00
#> [ <timestamp>] sd 1:0:0:0: [sdY] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
#> [ <timestamp>] sdY: sdY1 sdY2
#> [ <timestamp>] sd 1:0:0:0: [sdY] Attached SCSI removable disk
sdY from the messages. Partition the USB stick
Use an MBR partition table
#> Warning: The existing disk label on /dev/sdY will be destroyed and all data on this disk will be lost. Do you want to continue?
#> Yes/No? yes
#> Information: You may need to update /etc/fstab.
#> Information: You may need to update /etc/fstab.
ntfs instead of exfat as parted doesn't propose it as a filesystem. Use a GPT partition table
#> Warning: The existing disk label on /dev/sdY will be destroyed and all data on this disk will be lost. Do you want to continue?
#> Yes/No? yes
#> Information: You may need to update /etc/fstab.
#> Information: You may need to update /etc/fstab.
ntfs instead of exfat as parted doesn't propose it as a filesystem. Format the partition with
exFAT
#> exfatprogs version : 1.3.0
#> Creating exFAT filesystem(/dev/sdY1, cluster size=131072)
#>
#> Writing volume boot record: done
#> Writing backup volume boot record: done
#> Fat table creation: done
#> Allocation bitmap creation: done
#> Upcase table creation: done
#> Writing root directory entry: done
#> Synchronizing...
#>
#> exFAT format complete!
Data but you can change it to whatever you want. It must be short (limited to 11 characters) and I would keep it without spaces or special characters as I am not sure how it would be handled by the different operating systems.


I found this reference interesting: https://darwinsdata.com/what-type-of-partition-for-usb-drive/ ↩