Return to site

Format Flash Drive Mac Command Line

broken image


Formatting USB drives in Linux from the command line (terminal) is very easy.

In this note i will show how to format an external HDD, SSD or USB flash drive in Linux from the command line using mkfs utility.

I will provide the examples of disk formatting to the most popular file system types: FAT32, exFAT, NTFS, EXT4, XFS and will show how to list the all supported file systems.

How to Format USB Flash Drive from Command Prompt. For your information, any form of disk formatting will completely erase data, so backup as many as important files before the start. Altogether, you'll walk through the whole formatting process in eight steps, and the time spent will depend on the USB flash drive capacity and used space on it. How to Repair a Disk on Mac OS X from Command Line. Mac OS X comes with an easy-to-use application, called Disk Utility, that allows users to verify and repair hard disks using a graphical user interface and it is recommended for most Mac users that are not comfortable using the terminal. However, this can also be performed using the command-line.

Format Flash Drive Mac Command Line

Cool Tip: Check the real actual size of USB flash drive or SD card! Read More →

Format USB Drive in Linux

Execute the lsblk command to identify the name of the partition on the USB drive you want to format:

In the example above, the USB drive is recognized by the operating system as a disk named /dev/sdb with a single partition /dev/sdb1 mounted on /media/user/usb0.

Unmount the USB drive if it is mounted:

Warning: Formatting the USB drive will cause the loose of data on it!

Format a USB drive to the desired format and create a label (optionally):

Format ToCommand
FAT32
exFAT
NTFS
EXT4
XFS

List all supported filesystem types:

Cool Tip: Test performance of HDD, SSD, USB Flash Drive, SD card! Read more →

These days, CDs and DVDs are becoming more and more obsolete every day. Being able to write a Linux distro ISO to a USB drive is usually both faster and better than using a Linux CD or DVD. While there are many Graphical User Interface (GUI) tools to write an ISO to a flash drive, this article will discuss how to write an ISO file to a USB flash drive by command line in Linux.

Maybe it is because people prefer to use GUI's, and some are scared of using the command line, but, interestingly, writing an ISO to a USB flash drive is extremely easy once you understand the commands.

This article is a tutorial, and I will give you step-by-step information about how to write an ISO file to a USB flash drive by command line.

Step 1: Insert Your USB Drive And Find Out Where The USB Drive Is Put By The OS

First, insert your USB drive. And, next, we need to find out exactly exactly where the USB drive is placed by the OS. Do this command to find out where the flash drive is place:
sudo fdisk -l
Once you do the aforementioned command you should get output like:

Since I know that my USB drive is 16GB in size, the one I am looking for is the last /dev/sdb1.

Step 2: Unmount Our USB Flash Drive

Next, before we do anything more, we should unmount our USB flash drive for peace of mind to make sure there are no data loss problems, but don't remove it from your computer. Since my drive is located at /dev/sdb1 I will do:

sudo umount /dev/sdb1

Step 3: Download the Linux ISO And Then CD Into That Directory

I downloaded the latest version of Linux Mint 32 bit edition and am using it in this example. We need to go into the folder into wherever your iso file is. I am going to assume my file is located at ~/Downloads/

Do:
cd ~/Downloads/

Step 4: Actually Write The ISO To Your USB Drive

Here is the command that will ultimately write the ISO to your USB drive (Don't actually do it yet, because I need to explain a few things to make sure you do it correctly)

Format Flash Drive Mac Command Line

Cool Tip: Check the real actual size of USB flash drive or SD card! Read More →

Format USB Drive in Linux

Execute the lsblk command to identify the name of the partition on the USB drive you want to format:

In the example above, the USB drive is recognized by the operating system as a disk named /dev/sdb with a single partition /dev/sdb1 mounted on /media/user/usb0.

Unmount the USB drive if it is mounted:

Warning: Formatting the USB drive will cause the loose of data on it!

Format a USB drive to the desired format and create a label (optionally):

Format ToCommand
FAT32
exFAT
NTFS
EXT4
XFS

List all supported filesystem types:

Cool Tip: Test performance of HDD, SSD, USB Flash Drive, SD card! Read more →

These days, CDs and DVDs are becoming more and more obsolete every day. Being able to write a Linux distro ISO to a USB drive is usually both faster and better than using a Linux CD or DVD. While there are many Graphical User Interface (GUI) tools to write an ISO to a flash drive, this article will discuss how to write an ISO file to a USB flash drive by command line in Linux.

Maybe it is because people prefer to use GUI's, and some are scared of using the command line, but, interestingly, writing an ISO to a USB flash drive is extremely easy once you understand the commands.

This article is a tutorial, and I will give you step-by-step information about how to write an ISO file to a USB flash drive by command line.

Step 1: Insert Your USB Drive And Find Out Where The USB Drive Is Put By The OS

First, insert your USB drive. And, next, we need to find out exactly exactly where the USB drive is placed by the OS. Do this command to find out where the flash drive is place:
sudo fdisk -l
Once you do the aforementioned command you should get output like:

Since I know that my USB drive is 16GB in size, the one I am looking for is the last /dev/sdb1.

Step 2: Unmount Our USB Flash Drive

Next, before we do anything more, we should unmount our USB flash drive for peace of mind to make sure there are no data loss problems, but don't remove it from your computer. Since my drive is located at /dev/sdb1 I will do:

sudo umount /dev/sdb1

Step 3: Download the Linux ISO And Then CD Into That Directory

I downloaded the latest version of Linux Mint 32 bit edition and am using it in this example. We need to go into the folder into wherever your iso file is. I am going to assume my file is located at ~/Downloads/

Do:
cd ~/Downloads/

Step 4: Actually Write The ISO To Your USB Drive

Here is the command that will ultimately write the ISO to your USB drive (Don't actually do it yet, because I need to explain a few things to make sure you do it correctly)

#sudo dd if=linuxmint-18.1-mate-32bit.iso of=/dev/sdb

While this command may seem cryptic, actually, it is easy to understand. dd is a command we can use to write an iso to a usb flash drive in Linux by command line. Nearly every modern Linux distro should have dd installed by default.

From the manual for dd, here are the various options we use in the dd command:

if=FILE means read from FILE instead of stdin
of=FILE mean write to FILE instead of stdout

So in our case for the command:
#sudo dd if=linuxmint-18.1-mate-32bit.iso of=/dev/sdb
linuxmint-18.1-mate-32bit.iso is the file we are reading from (i.e. the iso file we are reading from), and of is where we are writing to, which in our case is /dev/sdb

And as a side note, we need to write to the entire device, /dev/sdb/ instead of /dev/sdb1. As Qubes describes, 'Make sure to write to the entire device (e.g., /dev/sda) rather than just a single partition (e.g., /dev/sda1).' So, even though when I did sudo fdisk -l, and found out that my usb drive is located at /dev/sdb1, I still need to use the dd command at /dev/sdb1

OK. Now that you have that background information, we will actually do the command to write the ISO file to your USB flash drive. (make sure to remove the # in the following command once you are ready. I put the # there to prevent accidental problems if you didn't intend to do the command or didn't understand the command.)

#sudo dd if=linuxmint-18.1-mate-32bit.iso of=/dev/sdb

Mac Command Line Tutorial

After this, the program will 'hang' for a little bit. Maybe it will take more than 2 minutes. But eventually, you will see some output such as:

And then you will see a command prompt when the computer has finished writing the ISO to the USB flash drive. Those things tell you that the ISO was successfully written to your USB flash drive.

Reformat Flash Drive Mac

Final Steps And Comments

Lastly, turn off your computer. Now your USB flash drive should have a Linux distro on it and you can install your new Linux distro from your USB drive. ☺

You may need to configure your motherboard to have USB drives boot first before your hard drive.

There shouldn't be a need to format your USB drive before writing the ISO to your flash drive(if you are just writing a Linux ISO) before all of these steps in the tutorial it since dd will write over everything on the USB drive. But, just to be safe, you can format it to NTFS or FAT32 with gparted if you want.

Mac Command Line

What did you think of this article? Did you learn anything interesting? Do you have anything to add? Let's discuss it in the comments below.





broken image