Format with terminal linux

How to Format Disk Partitions in Linux

A disk partition must be formatted and mounted before use. The formatting process can also be done for several other reasons, such as changing the file system, fixing errors, or deleting all data.

In this tutorial, you will learn how to format and mount disk partitions in Linux using ext4, FAT32, or NTFS file system.

How to Format Disk Partitions in Linux

  • A system running Linux
  • A user account with sudo or root privileges
  • Access to a terminal window / command line (Activities >Search >Terminal)

Checking the Partitions

Before formatting, locate a partition you wish to format. To do so, run the lsblk command that displays block devices. Block devices are files that represent devices such as hard drives, RAM disks, USB drives, and CD/ROM drives.

The terminal prints out a list of all block devices as well as information about them:

  • NAME – Device names
  • MAJ:MIN – Major or minor device numbers
  • RM – Whether the device is removable (1 if yes, 0 if no)
  • SIZE – The size of the device
  • RO – Whether the device is read-only
  • TYPE – The type of the device
  • MOUNTPOINT – Device’s mount point

We will use the /dev/sdb1 partition as an example.

Locating partitions with lsblk command.

The lsblk command without additional options does not display information about the devices’ file systems.

To display a list containing file system information, add the -f option:

The terminal prints out the list of all block devices. The partitions that do not contain information on the file system in use are non-formatted partitions.

Locating non-formatted partitions with lsblk -f command.

Note: Consider learning how to create partitions in Linux.

Formatting Disk Partition in Linux

There are three ways to format disk partitions using the mkfs command, depending on the file system type:

The general syntax for formatting disk partitions in Linux is:

mkfs [options] [-t type fs-options] device [size]

Formatting Disk Partition with ext4 File System

1. Format a disk partition with the ext4 file system using the following command:

Читайте также:  Настройка дисков в линукс

2. Next, verify the file system change using the command:

The terminal prints out a list of block devices.

3. Locate the preferred partition and confirm that it uses the ext4 file system.

The process of formatting disk partition using the ext4 file system in Linux.

Formatting Disk Partition with FAT32 File System

1. To format a disk with a FAT32 file system, use:

2. Again, run the lsblk command to verify the file system change and locate the preferred partition from the list.

Formatting disk partition using FAT32 file system in Linux.

Formatting Disk Partition with NTFS File System

1. Run the mkfs command and specify the NTFS file system to format a disk:

The terminal prints a confirmation message when the formatting process completes.

2. Next, verify the file system change using:

3. Locate the preferred partition and confirm that it uses the NFTS file system.

Formatting a partition with NTFS file system in Linux.

Mounting the Disk Partition in Linux

Before using the disk, create a mount point and mount the partition to it. A mount point is a directory used to access data stored in disks.

1. Create a mount point by entering:

2. After that, mount the partition by using the following command:

sudo mount -t auto /dev/sdb1 [mountpoint]

Note: Replace [mountpoint] with the preferred mount point (example: /usr/media ).

There is no output if the process completes successfully.

The process of creating mount point and mounting.

3. Verify if the partition is mounted using the following command:

Verifying formatting and mounting partition process.

Understanding the Linux File System

Choosing the right file system before formatting a storage disk is crucial. Each type of file system has different file size limitations or different operating system compatibility.

The most commonly used file systems are:

Their main features and differences are:

File System Supported File Size Compatibility Ideal Usage
FAT32 up to 4 GB Windows, Mac, Linux For maximum compatibility
NTFS 16 EiB – 1 KB Windows, Mac (read-only), most Linux distributions For internal drives and Windows system file
Ext4 16 GiB – 16 TiB Windows, Mac, Linux (requires extra drivers to access) For files larger than 4 GB

Note: Refer to our Introduction to Linux File System article to learn more about the evolution and features of different Linux file systems.

After following this tutorial, you should be able to format and mount a partition in Linux in various file systems. Partition manipulation is essential for efficient data management, and next, we recommend learning how to delete a partition in Linux.

Источник

What Is Ubuntu Format Disk Command Line? How to Use It [Your 2023 Fresh Guide]

Ubuntu is a Debian-based Linux distribution. It is appropriate for internet of things (IoT) gadgets, servers, workstations, and cloud computing. The primary distinction between Ubuntu and Linux is that the latter is a Linux distribution, whereas Linux is a family of operating systems built on Unix.

Читайте также:  Where is linux source

ubuntu disk format command line

The Ubuntu format disk command line can read and write files on partitions using Windows formatting. These partitions are often formatted with NTFS, but FAT32 can also be used occasionally. On other devices, FAT16 will also be shown.

You can format your drives using the Disks program that is bundled with Ubuntu. GParted can be used to format if the Disks tool is giving you issues or if your partition is corrupted. Additionally, GParted allows you to resize existing partitions, which enables you to use the free space on your drive to create a second partition. Let’s read why we need the ubuntu format disk command line.

Why You Might Need Ubuntu Format Disk Command Line

To carry out various activities on the OS, Ubuntu provides both the Command Line Interface (CLI) and Graphical User Interface (GUI). CLI is the fundamental method for interacting with the processor and memory of a system; it allows you to carry out all of the operations that a GUI can.

One of the most typical hardware operations is formatting a hard drive. If you add a new drive or partition to your Linux system, the drive must be formatted. Ubuntu Linux makes it simple with the GParted program, a graphical partition, and a format manager. Anyone may format a disc for usage in Linux, Windows, or both using GParted’s simple interface.

In most cases, Ubuntu correctly recognizes your hard discs and «mounts» them so that you may access them from the file manager. Additionally, it typically recognizes and mounts any additional USB-connected devices you could plug in, such as a flash drive, a digital camera, an audio player, and an external hard drive.

There are, however, hiccups that arise from time to time that must resolve. To fix the issue, you’ll need to open a command-line terminal and enter commands, potentially with the help of knowledgeable folks on the Ubuntu forums.

Ubuntu can read and write files on partitions using Windows formatting. These partitions are often formatted with NTFS, but FAT32 can also be used occasionally. You can format your USB drive using a number of the programs included with Ubuntu Linux, and you can use the Terminal or the Disk Utility included with Ubuntu. In either scenario, formatting your USB device takes a few minutes.

Читайте также:  Минималистичные браузеры для линукс

Ubuntu uses ZFS as its default file system when handling containers. Additionally, it contains the sophisticated Raid-Z feature, which is better for recovering from a disc failure and more reliably distributes data. On ZFS, Ext4, BtrFS, or Reiser, this capability is not available.

How Do I Format a Drive with Ubuntu Format Disk Command Line

Fitting a USB device is relatively simple via the command line. Using the commands listed here, anyone may format a USB disc.

1. To prevent accidentally formatting another device, the USB drive must be accurately identified. Use Dash or the Ctrl+Alt+T keyboard shortcut to launch the Terminal application, then enter the following command:

output line

Our USB drive is identified as /dev/sdb1 in the output’s final line.

2. To format the USB using the VFAT file system, use the following command:

sudo mkfs.vfat /dev/sdb1

You will use the location indicated by the df -h command’s output.

3. Only unmounted USB drives can be formatted; otherwise, the following message will appear:

error

Because of this, kindly unmount the drive using the following command:

sudo umount /dev/sdb1

Your USB device will be correctly formatted when you execute the formatting command as a root user.

Conclusion

In this article, the Ubuntu format disk command line has been explained. You can format your drives using the Ubuntu-bundled Disks application. If you’re having trouble using the Disks tool or your partition is damaged, you can format using GParted. If you like the post, share it and if you have any queries, comment below.

FAQs

If you still have some doubts, you can read the following answers to the questions.

1. How do I format a Drive in Ubuntu?

  • Gather details about your new hard disc.
  • Partition Editor, commonly referred to as «GNOME Partition Editor,» can be found by clicking «System,» selecting «Administration,» and like.
  • The disk’s settings should be checked.
  • Based on the usage you anticipate, choose the drive format.
  • Press «Apply.»

2. Can you format a disk from CMD in Ubuntu?

Windows has a tool called Diskpart that can be used from the command line to format a disc. Windows has a built-in tool called Diskpart.

3. What is the best Format for a disk in Ubuntu?

FAT32 is frequently advised for sharing between Ubuntu and Windows. However, NTFS also performs admirably.

Источник

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