Linux format disk fat32

How to format a usb drive with FAT32 file system on Linux

For all Linux users, work with usb drives, is really easy, and share data with Windows users through it, is also easy.

At least before you need to format the usb drive for any reason, if you format it using Linux ext3 or any other Linux mode, you will not be able (at least not easily) to share data with Windows users. What you need is to format the usb drive using FAT32 file system.

Install dosfstools package

The package you need to install in your Linux PC to be able to format disk using FAT32 file system is: dosfstools

Install dosfstools in Debian / Ubuntu

 apt-get install dosfstools 

Install dosfstools in Arch Linux

Install dosfstools in Slackware

 slackpkg install dosfstools 

Format usb drive with FAT32

Now that you have the right tools installed, it is time to use it, so to format a usb drive using FAT32 first insert your usb drive in the usb slot of your computer, and check with

You will see something like this:

Disk /dev/sda: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xed1f86f7 Device Boot Start End Blocks Id System /dev/sda1 * 1 1135 9116856 7 HPFS/NTFS /dev/sda2 1136 9141 64308195 5 Extended Partition 2 does not end on cylinder boundary. /dev/sda3 9142 9729 4717440 12 Compaq diagnostics Partition 3 does not end on cylinder boundary. /dev/sda5 1136 3047 15358108+ 83 Linux /dev/sda6 3048 3493 3580101 7 HPFS/NTFS /dev/sda7 3494 8809 42700738+ 83 Linux /dev/sda8 8810 9141 2666758+ 82 Linux swap Disk /dev/sdc: 8075 MB, 8075120640 bytes 154 heads, 36 sectors/track, 2844 cylinders Units = cylinders of 5544 * 512 = 2838528 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xb0bcd68e Device Boot Start End Blocks Id System /dev/sdc1 1 2845 7884836 83 Linux 

As you can see /dev/sdc is where my usb thumb drive was connected.

WARNING: Be really careful before formating a disk, you will not be able to recover your data, double check that you are applying the command to the right device before you hit ENTER

Note: You are supposed to have a partition created on the disk, before you format it.

If you enjoyed the article, please share it

You can also subscribe in different ways

Источник

How to Format Your USB Drive as FAT32 in Linux

Linux is an extremely stable and powerful operating system that has become quite popular among the community. With it being open-source and free to use, Linux has rapidly grown and has garnered a large audience in its user base. The beauty of Linux is that it offers a variety of tools having the same kind of functionality and this is the same case with formatting your USB drive.

Читайте также:  Многопоточное программирование на c linux

There are several excellent tools out there that allow Linux users to easily format their USB drives, which can be divided into either the command line category or the graphical interface category.

In addition to this, there are several file systems in which your USB drive can be formatted and for our USB device to have maximum compatibility with other devices, FAT32 is the way to go.

Therefore, in this tutorial, we will be discussing how one can format their USB drives as the FAT32 file system in Linux.

Formatting your USB Drive

Before we move onto the process of formatting our USB device, we first need to locate it. This can simply be done by entering the following command into the terminal:

In my case, it will be the device found inside the rectangular region (/dev/sdb/):

After locating your device, we can now move onto the main process where, from the large collection of tools that Linux offers, we will be looking at two ways how users can format their USB drives in Linux.

Formatting your USB Drive using GParted

GParted is a partition editor that is responsible for creating and managing disk partitions which may include reorganizing as well as deleting partitions.

a) Installing GParted
First, we need to install GParted on our Linux systems which can be done by entering the following command into the terminal:

To verify if it has been installed, you can simply do so by running the following command:

b) Wiping your Data by Adding Zeros (Optional)
The next step is to completely wipe out all data present on your USB device so that it cannot be recovered later by using any recovery tool. This, however, is an optional step and you can choose to skip this if you like. However, for security reasons, it is highly recommended that you go ahead with this. This process can be done by simply running the following command into the terminal:

Over here, you need to replace the /dev/sdb part that comes after of= with the target location of your USB device which you discovered previously.

c) Creating and Formatting your USB Device
Now, we finally arrive at the crux of the process. Over here, firstly, we have to the unmount /dev/sdb1 (use the location you found above) USB device on your system as we cannot format a mounted device. This can be done by using the following command:

Next, we will create a new partition table where we also have to mention the type of partition table that we want. In our case, this will be msdos. To do this, simply run the following command in the terminal:

Now, we have to create the partition where we will be specifying the partition type, the file system that we want our USB Device to be as well as the size that our partition will cover. In our case, we want our USB device to be of the FAT32 file system, primary partition type, and want the whole USB size for our partition. This can be done by using the following command:

Читайте также:  Общая папка vmware astra linux

Once this is done, we can finally format our USB device to FAT32 using the mkfs command which is the following:

Note, over here, we used the /dev/sdb1 location rather than the /dev/sdb location which we were using before. This is because over here we do not want the disk part of our device to be formatted.

To check if your device has been partitioned correctly, run the following command to print the partition table:

And voila, that completes the entire process. You will now find your USB device completely formatted.

Formatting your USB Drive using Disks

For users more comfortable with the Graphical User Interface, Disks is a disk management tool that comes preinstalled with Ubuntu and almost every other Linux system. To open this, simply search for it in the Dash and click on it once its name appears.

After the Disk utility opens, first choose your device which you want to format from the available ones shown in the Disks application. In my case, it will be the following:

Over here, click on the gear icon present below the Volumes section and then select Format Partition from the choices given.

After selecting this option, this will open a window, asking you to enter your new partition name as well as the type of your file system. Since we want our device to be of the FAT file system, we will select the following:

Next, confirm your details and once you’re sure everything is okay, click on the Format button on the top right-hand side as pointed by the arrow shown in the image below.

And voila, that completes the entire process. You will now find your USB device completely formatted.

Conclusion

As seen from the methods above, formatting USB drives on Linux is an extremely easy process. You just need to connect your device, choose the type of file system you want, and simply run the commands on the terminal or use the Disks utility to format your device. Of course, there are several other tools that you can use for formatting your USB devices but those shall be left for future tutorials.

Источник

Как в Linux отформатировать диск в FAT32

Несмотря на многообразие современных fs, FAT32 все еще актуальна — подключается без проблем в Linux, Mac, Windows. Допустим, есть диск, на котором мы хотим создать FAT32 раздел (чтобы использовать его как флешку, на Win/Mac/Linux). На нем могут быть какие-то разделы, а может их там нет, неважно. Делается все старой доброй утилитой fdisk, а потом mkfs -t vfat.

Важно правильно определить нужный диск (и не отформатировать диск с данными!):

# dmesg # ls -al /dev/disk/by-id/ # lsblk

Например, считаем, что наш новый диск: /dev/sde.

На диске уже могут быть разделы. Проверим, что там:

# fdisk /dev/sde Command (m for help): p Disk /dev/sde: 160.0 GB, 160041885696 bytes, 312581808 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xf15af15a Device Boot Start End Blocks Id System /dev/sde1 * 2048 312581807 156289880 b W95 FAT32

Ок, в моем случае на диске уже есть раздел FAT32, но мне он не нужен и для начала удалю его:

Command (m for help): d Selected partition 1 Partition 1 is deleted
# fdisk /dev/sde Command (m for help): p Disk /dev/sde: 160.0 GB, 160041885696 bytes, 312581808 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xf15af15a Device Boot Start End Blocks Id System

Все, старый раздел FAT32 стерт, теперь надо создать новый:

Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-312581807, default 2048): Using default value 2048 Last sector, +sectors or +size (2048-312581807, default 312581807): Using default value 312581807 Partition 1 of type Linux and of size 149.1 GiB is set

Новый раздел создан. Проверим:

Command (m for help): p Disk /dev/sde: 160.0 GB, 160041885696 bytes, 312581808 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xf15af15a Device Boot Start End Blocks Id System /dev/sde1 2048 312581807 156289880 83 Linux

Ок, создан новый раздел, с типом по-умолчанию Linux (id 83). Нам нужен FAT32:

Command (m for help): t Selected partition 1 Hex code (type L to list all codes): b WARNING: If you have created or modified any DOS 6.xpartitions, please see the fdisk manual page for additionalinformation. Changed type of partition 'Linux' to 'W95 FAT32' Command (m for help): p Disk /dev/sde: 160.0 GB, 160041885696 bytes, 312581808 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xf15af15a Device Boot Start End Blocks Id System /dev/sde1 2048 312581807 156289880 b W95 FAT32
Command (m for help): a Selected partition 1 Command (m for help): p Disk /dev/sde: 160.0 GB, 160041885696 bytes, 312581808 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xf15af15a Device Boot Start End Blocks Id System /dev/sde1 * 2048 312581807 156289880 b W95 FAT32

Все отлично, вносим изменения!

Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
# mkfs -t vfat /dev/sde1 mkfs.fat 3.0.20 (12 Jun 2013)

Проверяем (в выводе команды lsblk я убрал остальные диски, котоые не относятся к нашему):

# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT . sde 8:64 0 149.1G 0 disk L-sde1 8:65 0 149.1G 0 part

Точка монтирования не установлена. Примонтируем новый диск:

# mount -t vfat /dev/sde1 /mnt/usb/ # lsblk . sde 8:64 0 149.1G 0 disk L-sde1 8:65 0 149.1G 0 part /mnt/usb

Авторизуйтесь для добавления комментариев!

Читайте также:  Vmware esxi for linux

Источник

Оцените статью
Adblock
detector