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 hard disk in linux

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

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to increase the hard disk in linux". In the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Linux add hard disk methods: 1, use the fdisk command to display the current hard disk partition, press the "n" key to add a new partition; 2, use the mkfs command to format the partition; 3, use the mount command to mount the partition; 4, use the "defaults 00" statement to set up automatic mount when starting permanently.

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to add hard disk to linux

A hard drive with 20GB capacity has been added and mounted to the / data partition.

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

# fdisk-l

This command lists the current partition and configuration.

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 / dev/xvdc

Commonly used fdisk commands

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 primary partition or an extended partition. By default, we can have up to 4 primary partitions.

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

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.

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.

Save your changes and exit.

How to add a new disk on a Linux system how to add a new disk on a Linux system

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

Add an entry in the / etc/fstab file to automatically mount on permanent startup.

/ dev/xvdc1 / data ext4 defaults 00 "how to add a hard disk in linux" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Servers

Wechat

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

12
Report