How to format SD card from Linux?

An SD card is a tool that allows you to store information and content such as photos or videos on a device and is a removable material to transport wherever you need it.

It is possible to format the SD cards with a portable device to erase all the information contained therein in case of selling or giving it away. Regardless of the reason for formatting the SD card, or if it is damaged, apart from being able to recover what is on it , you will learn how to format one from a Linux computer, since for each operating system the procedure is different.

Index( )

  1. What do I need to do before formatting an SD card in Linux?
    1. back up information
    2. It is recommended to delete the data before formatting
  2. How can I format an SD card within Linux?
    1. Via the parted command
    2. With the fdisk command
    3. Using the graphical tool GParted
  3. How do you partition and format an SD card in Linux?

What do I need to do before formatting an SD card in Linux?

Before completely deleting the information contained in an SD card in Linux, it is best to back up the data and information before formatting said card, that is, make a backup copy of the data to avoid a future inconvenience, since There is a possibility of losing information.

back up information

To back up the information and make a backup on an SD card it is necessary to use commands, you just have to follow this procedure for optimal results:

  1. On the main screen of the Linux computer, go to the menu iconand in the search bar type ‘Terminal’, when loading the results click on the program.
  2. Another way to open a terminal in Linux is to simultaneously press the ‘Ctrl’, ‘Alt’ and ‘T’ keys and it will automatically display the Linux terminal tab.
  3. When opening the terminal in Linux you must type the following command: ‘sudo dd if = / dev / mmcblk0 de = / image-of-sd-card.img’ and press the Enter key. Doing this will immediately create the backup of the SD card.

It is recommended to delete the data before formatting

As said before, it is best that you back up the information on the SD card before doing any formatting, and before such a process, it is recommended that you delete the stored data. However, always remember to back up your files as a precaution.

How can I format an SD card within Linux?

To format an SD card using a Linux device , it will be done through commands and partitions, there are several useful commands for this procedure such as parted and fdisk, the GParted program is also useful for this type of work, here you will see each of them.

Via the parted command

The ‘parted’ command is very useful when formatting an SD card from a Linux terminal, to do so follow these steps:

  1. When connecting the SD card you will have to open a Linux terminal by pressing the ‘Ctrl’, ‘Alt’ and ‘T’ keys at the same time or from the device menu.
  2. Then, in the new box type the command ‘lsblk’to locate the device that corresponds to the desired SD card.
  3. Then type the word ‘parted’ and the name of the drive to format, the command should be written as follows: ‘sudo dd / dev / (removable drive name)’.
  4. Then provide the information requested below and create a partitionand format the newly created partition.

With the fdisk command

By obtaining the Linux operating system , you will be able to use the well-known fdisk command and thus format the SD card completely, to use this command follow these instructions:

  1. On the Linux main screen, open a new terminal from the menuor by applying keyboard shortcut combinations.
  2. You will see a black box that corresponds to the terminal where you must type ‘sudo fdisk -l’ now you will see all the Linux partitions, including the SD card.
  3. The next step will be to type ‘ sudo umount /dev/sd (SD card name)’and hit Enter.
  4. To finish, you must write the following command ‘sudo mkdosfs -F 32 -I /sd/dev + (name of the SD card)’ when you finish writing, press the Enter key and you will have finished formatting the SD card.

Using the graphical tool GParted

The GParted tool is very useful when editing partitions , that is, both internal and external storage units in Linux, with these instructions you will be able to do it correctly:

  1. Once the SD card is connected, enter the GParted program and in the upper menu of the tab, go to the section called ‘GParted’ that you will see as the first option.
  2. In the small panel that will be displayed, click on ‘Devices’and then click on the option that corresponds to the SD card.
  3. In the new tab choose the ‘Fat32’ option and then select ‘Unmount’. Once unmounted, click on ‘Fat32’ again and click on ‘Format as’.
  4. In the small options panel tap on ‘Fat32’ and then on the screen press on the arrow pointing to the left.
  5. Finally, in the confirmation notice that you will see on the screen, click on ‘Apply’ and then on ‘Close’ with this procedure you will have already formatted the SD drive.

How do you partition and format an SD card in Linux?

A very popular way to create a partition in Linux is using the fdisk command , from where you can create and control a partition from this operating system with the following steps:

  1. Enter a new terminal and type the command ‘fdisk /dev/sd’ then type the letter ‘m’ to display the available options.
  2. Here you will see a list of letters that execute different options, type ‘n’ to add a new partition.
  3. When it asks to set a value in the partition number press Enter to set the default value (1), in the sector do the same and then write the size of the SD card.
  4. By pressing the Enter key you will have created the new partition, if you type the letter ‘p’  you will be able to see said partition, and by placing ‘w’ you can save and exit.
  5. Now to format the partition type ‘mkfs –t ext4 + (path of created partition)’ and click Enter, this way you have created a partition to format your SD card


Leave a Comment