Get the App
SLTechnology News&Howtos  ›  Development  › 

How to add a New hard disk in Linux system

Shulou Source: shulou.com Published: 2022-06-01 20:29:53 10月14日 Update

This article mainly introduces the Linux system how to add a new hard disk, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

During the use of the Linux system, the server capacity will gradually increase, or sometimes the disk will be damaged and need to be replaced.

Configure new disks I use the fdisk tool to complete these configurations.

I have added a hard drive with 20GB capacity and mounted it to the / data partition.

Fdisk is a command line tool for displaying and managing hard drives and partitions on Linux systems.

The command # fdisk-l lists the current partition and configuration.

View Linux partition details

After adding the hard drive with 20GB capacity, the output of fdisk-l looks like this.

# fdisk-l

View new partition details

The newly added disk is displayed as / dev/xvdc. If we add a physical disk, it will appear similar to / dev/sda based on the disk type. I'm using a virtual disk here.

To partition on a specific hard drive, for example, / dev/xvdc.

# fdisk command commonly used in fdisk / dev/xvdc n-create Partition

P-print partition table

D-Delete a partition

Q-exit without saving changes

W-Save changes and exit

Since we are creating a partition here, we will use the n option.

Create a new partition on Linux

Create a primary partition or an extended partition. By default, we can have up to 4 primary partitions.

Create a primary partition

Enter the partition number as required. The default value of 1 is recommended.

Assign a partition number

Enter the size of the first sector. If it is a new disk, usually choose the default value. If you are creating a second partition on the same disk, we need to add 1 to the last sector of the previous partition.

Assign sectors to a partition

Enter a value for the last sector or partition size. It is generally recommended to enter the size of the partition. Always add a prefix + to prevent the value from going out of range.

Assign partition size

Save your changes and exit.

Save partition changes

Now use the mkfs command to format the disk.

# mkfs.ext4 / dev/xvdc1

Format the new partition

When the formatting is complete, mount the partition according to the following command.

# mount / dev/xvdc1 / data adds an entry in the / etc/fstab file for automatic mount on permanent startup.

/ dev/xvdc1 / data ext4 defaults 00 Thank you for reading this article carefully. I hope the article "how to add a new hard disk in Linux system" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Disk hard disk command system size article input capacity format allocation configuration tool details recommendation value interest prefix at the same time basic commonly used Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Apple Shulou Tech Info Redmi MySQL