How to format a USB drive in Linux that works with Windows

0
428

[ad_1]

fatmawati achmad zaenuri / Shutterstock.com

Sometimes Linux users need to exchange files with computers running other operating systems, such as Windows or macOS. That’s pretty simple with a USB drive, as long as it’s formatted correctly.

The universal format?

Linux hard drives are usually formatted in ext4, although other formats are slowly gaining popularity, such as btrfs and ZFS. These are Linux-specific file system formats. With USB drives, it’s a different story. For maximum flexibility and use on Windows or macOS, as well as Linux, they need to be formatted to something that works on all three operating systems.

Obviously, using a Linux-only format won’t give us what we need. You’re also not using an Apple-exclusive format. The closest thing we had to an Esperanto of file storage formats was FAT32. USB drives formatted according to this Microsoft standard can be used interchangeably on Windows, Linux, and macOS. That was great until you tried to store a file that was larger than 4 GB. That was the fixed upper limit file size built into FAT32.

The exFAT file system overcomes that limitation. It is another format from Microsoft and is compatible with macOS and, since kernel 5.4, Linux. That makes it a strong contender for the best file system for USB drives that need to work with all three big operating systems. It doesn’t have the drawbacks of FAT32, but it doesn’t have the overhead and added functionality of NTFS either. That also makes it fast.

As long as you have a Linux kernel version 5.4 or higher, you can use exFAT just as easily as any other supported file system. At the time of writing, the current Linux kernel is 5.18, so as long as you have a recently updated and patched system, you’re good to go. We will demonstrate a graphical method using GNOME Disks, as well as a terminal method.

The most important steps

When you write a new file system to a USB drive, everything on it is erased. That means it’s vital that you:

  • Check that you don’t mind anything and everything on the USB drive being erased either make sure you have copied everything you want to keep to another drive.
  • Make sure you know which storage device you want to format. Don’t format the wrong drive. It’s an easy mistake to make on a computer with multiple drives.

RELATED: How to list your computer’s devices from the Linux terminal

Formatting with GNOME disks

The safest way to start is with the USB drive unplugged. In Ubuntu, you can press the “Super” key, then type “disks” in the search field. you will see the disks icon. Click on the icon to start GNOME disks request.

the disks The app lists the storage devices that you can find on the left sidebar.

List of GNOME disk storage devices

This computer has a mix of physical drives and SSD drives, and a CD/DVD optical drive.

Plug in the USB drive. Linux will detect it and the change will be reflected in the GNOME disks request.

USB drive listed in GNOME Disks

The drive has been added to the list of known storage devices and is correctly identified as Kingston Data Traveler. The total capacity of this USB drive is 32 GB, but it is listed as 31 GB. This is because you lose a bit of space when you format a drive. Don’t be surprised if the capacity of your USB drive is not as large as you expected.

Click on the unit to see information about it.

USB drive details listed in GNOME Disks

We can see that it is formatted with the ext4 file system, and its Linux designation is “/dev/sdc”.

Click the gear icon, then click the “Format Partition…” menu option.

menu option

Type a name for your USB drive, select the “Other” radio button, then click the “Next” button.

Provide a volume name for the USB drive on GNOME disks

Select the “exFAT” radio button, then click the “Next” button.

The exFAT radio button selected in the Custom Format dialog

You are warned that the USB drive will be erased and you are shown the details of the drive so you can confirm that it is the drive you want to format. Only when you are satisfied that it is the correct drive, click the red “Format” button.

The confirmation page of the format dialog.

The drive automatically formats and returns to the main screen. disks display. The USB drive entry now shows that it is formatted with the exFAT file system.

The exFAT formatted USB drive in the GNOME Disks screen

Formatting on the command line

The first step is to positively identify the USB drive. We can do this using the lsblk domain. Without connected USB drive, run the lsblk domain:

lsblk

The output of lsblk without the USB drive attached

Connect the USB drive to the computer and wait a moment for Linux to recognize and mount it. Then run the same lsblk domain:

lsblk

The output of lsblk with the USB drive attached

We can see the new entry for the USB drive. It appears as device “/dev/sdc”, and is mounted at “/run/media/dave/MetalUSB”.

Before we can format it, we need to unmount it. we will have to use sudo. Note that there is no “n” in the “unmount” command.

We pass the mount point to umount domain. What this does is unmount the File System. If we use the lsblk command we will see that the USB drive is still recognized, but is no longer associated with a mount point.

sudo umount /run/media/dave/MetalUSB
lsblk

The unmounted USB drive shown in the output of the lsblk command

To format the USB drive with the new file system, we use the mkfs.exfat domain. We need to reference the USB drive using its device name, which is “/dev/sdc”.

the -L The (label) option allows us to provide a volume label. Let’s call this USB drive “Metal32”.

sudo mkfs.exfat -L Metal32 /dev/sdc

Creating the exFAT file system on the USB drive

Unplug the USB drive, wait a moment, and then plug it back in. Use the lsblk command once more and you will see that the drive is now mounted and the mount point name has changed to reflect the name we chose when we created the file system.

lsblk

The USB drive mounted to a new mount point

To verify that the file system is exFAT, we can use the df command with the -T (type) option.

df -T /dev/sdc

Using the df command to check the file system of the USB drive

We can see that the file system is listed as exFAT.

RELATED: How to use the mkfs command in Linux

Just to make sure Microsoft Windows was happy with the USB drive, we plugged it into a Windows computer and looked at its properties. Windows 10 treated the drive as a properly formatted and functional USB drive, using the exFAT file system.

USB drive properties in Windows 10

Avoid the 4GB barrier

The theoretical maximum size of a file under exFAT is 16EB (Exbibytes). While it’s unlikely you’ll ever need to carry a file that size, the need to transfer and share files larger than 4 GB is a fairly common requirement for exFAT to be a good candidate for a universal format for USB drives.

[ad_2]