Linux all format usb

How To Format USB Drive in Linux Command Line

USB formatting is the process of erasing all data from the disk and prepare it for use. Sometimes we are required to change the filesystem on our USB drive, In that case, we have to format the USB drive with the new filesystem type. Formatting a USB drive in Ubuntu using Terminal commands is much easier than formatting it in Windows systems.

This tutorial will help Ubuntu (Linux) users with the simple steps for format a USB flash drive using the command line.

Step 1 – Attach USB to System

Insert a USB drive into your system and identify your USB drive correctly. This is the step you need to take care, because you may format the wrong disk if not correctly identify your disk.

Filesystem Size Used Avail Use% Mounted on /dev/sda1 28G 24G 2.3G 92% / udev 1.4G 12K 1.4G 1% /dev tmpfs 277M 1.2M 276M 1% /run none 5.0M 0 5.0M 0% /run/lock none 1.4G 34M 1.4G 3% /run/shm /dev/sdc1 14.8G 1.4G 13.4G 10% /media/tecadmin 

Now, You can see that the USD drive is attached as /dev/sdc1 device. Which is mounted on /media/tecadmin.

Step 2 – Format USB Drive in Linux

Whenever we attach a USB drive in Ubuntu, it is automatically mounted to the system. We can not format any disk on Linux systems that are already mounted. So first un-mount /dev/sdc1 USB drive on your system.

Now, Use one of the following commands as per the file system you want. To format a USB drive, most of the users prefer VFAT and NTFS file systems because they can be easily used on the Windows operating system.

Similarly, you can format a USB Flash drive with any required file system.

Conclusion

In this tutorial, you have learned to format a USB drive on a Linux system via the command-line interface.

Источник

How to Format USB Drive on Linux

A USB is a handy appendage that offers numerous options in terms of customization and allocation. However, to harness its capabilities, one needs to know how it works. We often need to change a file system for improved adaptability to a system or erasing data for any given purpose.

In times like this, we need formatting. However, it is seen as a tedious task many don’t want to stumble upon. So in this article, we guide you step by step as to how you can format your USB drive. This can be done with the terminal or the “Disks” software. So, without further ado, let’s jump into it.

USB formatting is seen as a strenuous task for many users. In the case of windows, there are several things one needs to look out for. However, it is comparatively easier in Linux. So, worry not, after going through this article, you will surely be capable of formatting your drive without any issues whatsoever.

Читайте также:  Пароль администратора kali linux

Method 1: Format USB Drive through the Terminal

We can easily format our drive via the Terminal. Just log into your system and open the Terminal window through the Dash. You can alternatively use the “Ctrl + Alt + T ” shortcut to open it directly.

A new terminal window will open. Enter the following command.

The df command returns a list of the details of all the partitions mounted to your device, including the total space in each partition, the used space, and the available space.

From this list, locate your USB drive partition. You can do that by reading the path of your partition from the Linux file manager and then searching for that path in the list of partitions that came up in df.

As you can see, in the USB drive shown here, the partition is mounted on media/kausar/83F3-F8C7 , and the corresponding Filesystem name which comes up under df is /dev/sdc1.

Therefore, the next command to execute is as follows.

This command will unmount the USB drive partition from the device. Type your Linux password and press Enter.

The final step is to format the USB drive. This is done with the command:

Note: This command formats the drive with the FAT32 format file system.

All done! To check if the USB drive has been formatted correctly, head on to the file manager and open the USB drive. If it is empty, then it has been successfully formatted.

Method 2: Format USB Drive through the Disks Utility

To access the Disks utility, navigate to the Dash icon. The Ubuntu Dash holds all the Ubuntu software available and installed on your device.

Type “Disks” in the resulting search bar and click on the Disks application that comes up.

It will open up in a new window. Locate your USB drive in the list of which appear in the left panel and click on it.

Next, under “Volumes”, of the three icons you see, click on the third gear icon. A dropdown menu will appear. From the options displayed, click on “Format Partition”.

Set the name of your USB drive and select which type of file system format to format your USB too. Then select “Next”.

A warning will pop up asking you to confirm the deletion of all your data in the USB drive. Select “Format” displayed in red on the top right corner to proceed with the formatting.

And that’s it. You’re done. These are the two easiest ways to format your USB drive and make it 100% available in space.

There are other methods of formatting a USB drive on Linux as well. For example, you can download 3rd party software like “GParted” from Ubuntu Software or the CLI.

GParted is a software that manages partitions and their allocations, resizing, copying and redistribution. In case you experience trouble using the two methods described above, GParted offers a simple GUI to format USB drives and is an overall useful tool to have.

Advantages of Formatting Your USB Drive

Formatting your USB drive in time of need can bring several perks with it as it:

  • Debugs and fixes certain errors that were not repairable before. It also rids the USB drive of malignant files, which may harm the USB connects system.
  • Improves the overall adaptability and performance of the drive.
  • Results in storage conservation, allowing space for newer files in need.
  • Opens the way for installing new file systems that may go well with other systems you want to use or simply working with updated systems.
Читайте также:  Cptools криптопро 4 linux

Conclusion

By formatting your USB drive, you bring out the best performance for that particular drive while having more room for your utilities. Moreover, formatting can come a long way, whether it be cleaning up your device for top-notch performance or reformatting it for a newer system.

Источник

How To Format USB In Linux (5 Easy Ways)

format usb linux

Formatting a USB Drive in Linux is a straightforward process for the most part, but you may encounter a few roadblocks along the way.

For instance, users are often unsure as to what file system they should format the USB with. Generally, you should stick to ext4 for the best performance and stability. But if cross-platform compatibility is a concern, you can instead go with exFAT or FAT32.

Users have also reported facing issues with the USB not being usable after formatting. We’ve detailed how you can format the USB properly and resolve all such issues in this article.

How to Format USB in Linux

We’ll use ext4 as an example, but you can choose your preferred file system when formatting the USB. Remember to backup any important data beforehand. Also, make sure you specify the correct device to format when performing the command-line methods, as it’s easy to mess this up and format the wrong drive.

Using GParted

GParted is a GUI-based partition manager. Using GParted is generally the easiest way to format USB drives on most distros, so if you’re new to Linux, this should be your go-to option. Here are the necessary steps for this:

  1. First, you’ll have to install GParted. On Debian-based distros, you can do so with the following command:
    sudo apt install gparted
  2. Open GParted and enter your password to authenticate.
  3. Select the USB from the top right.
    gparted-select-device
  4. Right-click the USB and select Unmount.
  5. Next, right-click the data partition and select Format To > ext4.
    gparted-format-to-ext4
  6. Click on Apply all operations.
  7. Afterward, right-click it once more and select Mount.
  8. If the Mount option is greyed out, execute the following commands in the terminal:
    sudo mkdir /mnt/usb
    sudo mount /mnt/usb
    sudo mount device

GNOME Disks

GNOME Disks is the default partition manager for GNOME desktop environments. It’s pre-installed in most of the popular Linux distros, including Ubuntu. Here are the steps to format your USB using this utility:

  1. Open the Disks utility and select the USB.
  2. Select the partition you want to format and click on the settings cog.
  3. Select Format partition and rename the volume if you want.
    gnome disks format partition
  4. You can enable Erase to overwrite the existing data, and you can also select the filesystem. Afterward, press Next > Format.
    gnome disks format volume
  5. If you want to format the entire drive at once instead, click on the triple-dot button and select Format Disk > Format.
    gnome disks format disk
  6. Press the + button to create a partition in the unallocated space.
  7. Adjust the partition size and other values as before and create the partition.
  8. Now, mount the USB to make it accessible again.

Make File System (mkfs)

GParted performs the disk operations through the mkfs utility. So, you can think of this method as using GParted but via the command line, although their origins are actually the other way around. In any case, here are the steps to format your USB using mkfs:

  1. Use df -h to check the USB’s device path.
  2. Unmount the USB using sudo umount .
    sudo umount device
  3. Type sudo mkfs -t .
  4. Replace with your preferred filesystem (ext4, vfat, nfts, etc.) and execute the command.
    sudo-mkfs-ext4-device
  5. Afterward, mount the USB with the following commands:
    sudo mkdir /mnt/usb
    sudo mount /mnt/usb
Читайте также:  Mts модем linux mint

Using dd

You can use dd to either zero-fill or write random data to your USB drive, essentially formatting it and making the data unrecoverable. This is a good idea if you plan to lend the USB or sell it to someone.

Using dd is very simple; the base syntax is as follows:
dd if=source of=

For instance, if you wanted to write random data instead of zeroes to a USB mounted at /dev/sdb1 , you would use the following command:
dd if=/dev/urandom of=/dev/sdb1 bs=16M

sudo-dd-format-usb

Using Shred

Shred is essentially dd but more secure. Its overwriting patterns are optimized to destroy as much residual data as possible, so this is your best bet if you’re trying to wipe the USB completely.

The base syntax for Shred is shred . In our example, we’ll use the -f option to force write, -n to specify the number of times to overwrite, and -v to display the ongoing operation. But for the full list of options, you can check the shred man page.

sudo-shred-vf-device

Problems When Formatting USB

A commonly reported issue regarding USBs is that users installed Linux onto the USB, and now it’s not usable for data transfer. Reverting a bootable USB to a non-bootable state is very simple; all you have to do is format it.

The USB not being mountable after formatting is another common problem. This time, it usually happens because the formatting tools in Linux are capable of removing everything from the drive, including the filesystem signatures. As there are no partitions to mount, you’ll have to create one first.

If sudo mount doesn’t let you auto-mount, you should create a mount point first and then mount the device manually as such:
sudo mkdir /mnt/usb
sudo mount /mnt/usb

Finally, another problem worth mentioning is that the formatting process gets interrupted, and the USB doesn’t get detected afterward. Users generally use lsusb , and when they find that the system isn’t detecting the USB at all, they assume they bricked the device.

While this is certainly a possibility, we’ve found that simple fixes like restarting the PC and reseating the USB a few times are surprisingly effective at resolving this issue.

Anup Thapa primarily covers Windows systems, networking, and computer hardware at TechNewsToday. Anup has been writing professionally for almost 5 years, and tinkering with PCs for much longer. His love for all things tech started when he got his first PC over 15 years ago. It was a Pentium IV system running Windows XP on a single 256 MB stick. He spent his formative years glued to this PC, troubleshooting any hardware or software problems he encountered by himself. Professionally, Anup has had brief forays into a variety of fields from coding and hardware installation to writing. In doing so, he’s worked with people of different backgrounds and skill levels, from average joes to industry leaders and experts. This has given him not just a versatile skill set, but also a unique perspective for writing that enables him to concisely communicate complex information and solve his reader’s problems efficiently. You can reach out to him at anup@technewstoday.com.

Источник

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