Format SD card in Linux

How do I fix my SD card in Linux? How do I format my SD card as EXT4? What is the best way to format an SD card in Linux?

In the ever-evolving landscape of digital storage, the Secure Digital (SD) card has become a ubiquitous companion, offering portability and versatility. However, harnessing its full potential, especially in the realm of Linux, requires a nuanced understanding of file systems, formatting procedures, and the intricacies of various operating systems. This comprehensive blog unveils the art of formatting an SD card in a Linux environment, exploring fundamental concepts and providing step-by-step tutorials for different Linux distributions.

An image that explains how to format SD card on Linux.

Jun 02, 2024    By Team YoungWonks *

In the realm of Linux system management, the command line serves as a potent tool for manipulating storage devices. When it comes to formatting a memory card or USB drive, knowing the intricacies of file systems is paramount. For instance, Linux users may opt for the versatile NTFS format, commonly associated with Microsoft's Windows operating systems. If you're working with an SD card reader, the command-line wizardry continues. Arch Linux enthusiasts, accustomed to the power of command-line operations, may appreciate the flexibility in creating and modifying partition tables. Meanwhile, Windows 10 users can effortlessly format storage devices by right-clicking in the file manager, a more graphical approach compared to the command-line-centric methodology embraced by the Linux community. Whether it's dealing with ISO files, formatting in VFAT, or configuring storage devices, the marriage of command-line proficiency and user-friendly interfaces exemplifies the harmonious coexistence in the diverse landscape of operating systems.

In the intricate dance of formatting storage devices, Linux users, adept at harnessing the command line for nuanced operations, often find themselves navigating the complexities of file systems and partition tables with finesse, showcasing the versatility of Linux using the command line as a formatter extraordinaire

Understanding File Systems and SD Cards

Before delving into the formatting process, let's grasp the essence of file systems. An SD card typically comes pre-formatted with a file system, often FAT32 or exFAT for compatibility with multiple operating systems, including Windows and MacOS. However, Linux systems may require a different file system, such as ext4.

Here's a brief overview of different types of formats and considerations for choosing the most suitable one:

FAT32 (File Allocation Table 32):

  • Compatibility: Highly compatible with various operating systems, including Windows, MacOS, and Linux.
  • Limitations: Maximum file size is 4 GB, and the maximum partition size is 32 GB.
  • Use Case: Suitable for small-capacity SD cards intended for general data storage and cross-platform compatibility.

exFAT (Extended File Allocation Table):

  • Compatibility: Widely compatible with Windows and MacOS. Linux support may require additional installations.
  • Advantages: Overcomes some limitations of FAT32, supporting larger file sizes and partition capacities.
  • Use Case: Ideal for larger SD cards when cross-platform compatibility is essential, and individual file sizes may exceed FAT32 limits.

NTFS (New Technology File System):

  • Compatibility: Native to Windows; limited support on MacOS and Linux.
  • Advantages: Supports large file sizes and advanced features like file compression and encryption.
  • Use Case: Best suited for SD cards primarily used with Windows systems and when dealing with large files.

ext4 (Fourth Extended Filesystem):

  • Compatibility: Native to Linux; limited support on Windows and MacOS.
  • Advantages: Journaling for improved data integrity, support for large file sizes and partitions.
  • Use Case: Ideal for Linux-based projects, such as Raspberry Pi systems, and when features like journaling are desirable.

exFAT vs NTFS vs ext4

  • Cross-Platform Considerations: exFAT is the most versatile for cross-platform use, while NTFS is more Windows-centric, and ext4 is Linux-native.
  • File Size and Partition Limits: Choose based on your expected file sizes and the overall storage capacity of the SD card.
  • Journaling: If data integrity is crucial, consider file systems with journaling capabilities like ext4.

Choosing the Right Format

  • For Small Capacities and Cross-Platform Use: FAT32.
  • For Larger Capacities and Cross-Platform Use: exFAT.
  • Windows-Centric with Large Files: NTFS.
  • Linux Native or Raspberry Pi Projects: ext4.

In essence, the choice of file system depends on your specific use case, the platforms you'll interact with, and the features and limitations that align with your storage requirements. Always consider cross-platform compatibility and the intended use of the SD card when making this decision.

Steps to Format an SD card in Linux

The following are the steps to format SD card in Linux operating system:

Step 1: Identifying Your SD Card

The initial step involves identifying the device name assigned to your SD card.  This is imperative, as operations performed on the wrong device can lead to data loss. The lsblk command becomes a valuable ally in this endeavor. Executing lsblk in the terminal provides a comprehensive list of all block devices on your system, including your SD card. The device name, often denoted as sda or sdb, is crucial for subsequent operations.

Understanding the output of lsblk is essential. For example, an SD card might be represented as /dev/sdb. The 's' typically stands for 'storage,' while 'b' denotes the second block device. This information is pivotal for ensuring precision in your operations.

Open the terminal and type:

identifying sd card

This command lists all block devices, helping you identify your SD card, often denoted as sda or sdb.

Step 2: Unmounting the SD Card

Before initiating any formatting operations, it's paramount to unmount the SD card to ensure no processes are actively accessing it. The sudo umount /dev/sdX command serves this purpose, where /dev/sdX is replaced with the specific device name of your SD card. Unmounting is crucial as it detaches the file system from the SD card, allowing for safe manipulation without interference from active processes.

Before formatting, unmount the SD card to ensure no processes are accessing it.

Execute by replacing  /dev/sdX with your SD card's device name.

unmounting sd card

Step 3: Formatting with mkfs

The mkfs command, a powerful tool in the Linux arsenal, is used for creating file systems on devices. In this step, we employ mkfs.ext4 to format the SD card with the ext4 file system. The command sudo mkfs.ext4 /dev/sdX1 creates an ext4 file system on the specified partition, represented as /dev/sdX1. It's vital to point the command to the correct partition to avoid unintentional data loss.

To format the SD card to ext4, use the following command:

formatting with mkfs

Replace /dev/sdX1 with your SD card's partition name.

Step 4: Formatting via GUI Tools

For those preferring graphical interfaces, tools like GParted, Disk Utility, or the file manager offer a user-friendly approach.

1) Using GParted

For those who prefer a graphical interface, GParted is a powerful and user-friendly tool. GParted allows users to visualize and manage disk partitions. Before using GParted, it needs to be installed. This can be achieved through package managers like apt-get for Debian/Ubuntu or dnf for Fedora. Once installed, GParted can be launched, and users can select their SD card, unmount it, create a new ext4 partition, and apply the changes through a straightforward graphical interface. GParted is particularly advantageous for those less familiar with command-line operations or for users who prefer a visual representation of their disk configuration.

Install GParted if not already installed:

install gparted

Open GParted, select your SD card, unmount it, create a new ext4 partition, and apply the changes.

gparted show disks gparted unmount gparted format

2) Using Disk Utility

On Ubuntu and other GNOME-based Linux distributions, the Disk Utility, accessed through the gnome-disks command, provides a user-friendly interface for disk management. Users can select their SD card, navigate to the menu, and choose the 'Format Disk' option. Disk Utility simplifies the formatting process for those who prefer graphical tools.

On Ubuntu, the Disk Utility provides a straightforward way. Execute:

gnome disks

Select your SD card, navigate to the three-dots menu, and choose Format Disk.

gnome format

Troubleshooting Common Issues in SD Card Formatting on Linux

  • While the process of formatting an SD card on Linux is generally straightforward, users may encounter common issues that can impede a seamless experience. One prevalent challenge is misidentification of the SD card's device name, leading to unintended operations on the wrong device. To overcome this, users should exercise caution and double-check the output of commands like lsblk to accurately identify the correct device name.
  • Unmounting issues can also arise, especially if certain processes are still accessing the SD card. It's essential to ensure that the card is properly unmounted using the sudo umount /dev/sdX command before proceeding with any formatting operations. Failure to do so might result in errors or incomplete formatting.
  • In the realm of command-line operations, users may encounter challenges with tools like fdisk or mkfs. For instance, specifying an incorrect partition name or type during partitioning can lead to unexpected outcomes. To mitigate this, users should carefully follow the steps outlined in the guide, paying close attention to details such as partition names and types.
  • Issues related to graphical tools like GParted or Disk Utility may arise if the necessary packages are not installed or if there are compatibility issues with the desktop environment. Users facing such challenges should ensure that the relevant tools are installed using the appropriate package manager and that their desktop environment is supported.
  • Lastly, compatibility issues between file systems can pose challenges, especially when transferring SD cards between different operating systems. For instance, using a file system like ext4, which is native to Linux, may limit interoperability with Windows systems. Users should be mindful of the intended use case for the SD card and select a file system that aligns with the operating systems they plan to interact with.

In troubleshooting these issues, users can leverage online forums, community support, and documentation specific to their Linux distribution. Thoroughly understanding the intricacies of each step, cross-referencing commands, and seeking assistance from the vibrant Linux community can significantly enhance the troubleshooting process. As with any technical endeavor, patience and a methodical approach are key to resolving common issues and ensuring a successful SD card formatting experience on Linux.

Elevate Your Coding Skills with YoungWonks

Formatting an SD card in Linux can be a straightforward process when using the right tools and commands. If you're interested in expanding your knowledge in related areas, consider checking out Coding Classes for Kids offered by YoungWonks. Additionally, for those interested in specific programming languages, Python Coding Classes for Kids are available. YoungWonks also provides specialized training in Raspberry Pi, Arduino and Game Development Coding Classes. These resources can greatly enhance your coding skills and project development capabilities.


Mastering SD card formatting on Linux is an essential skill, ensuring optimal utilization of this versatile storage medium. Whether you opt for command-line finesse or embrace graphical interfaces, the key is understanding the nuances of file systems and partitioning. Armed with this knowledge, you can seamlessly format SD cards for diverse purposes, from Raspberry Pi projects to general data storage, enhancing your proficiency in Linux system management.

*Contributors: Written by Prasanna Gurumallapla; Edited by Rohit Budania; Lead image by Shivendra Singh

This blog is presented to you by YoungWonks. The leading coding program for kids and teens.

YoungWonks offers instructor led one-on-one online classes and in-person classes with 4:1 student teacher ratio.

Sign up for a free trial class by filling out the form below:

By clicking the "Submit" button above, you agree to the privacy policy
Share on Facebook Share on Facebook Share on Twitter Share on Twitter
Schedule a free trial class help