Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add a New hard disk in Linux system

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report