Home  >  Article  >  Operation and Maintenance  >  Format the newly added hard disk in linux and mount it to the directory

Format the newly added hard disk in linux and mount it to the directory

巴扎黑
巴扎黑Original
2017-06-23 14:18:282706browse

Requirements: Add a new hard disk sdb, partition the sdb into only one partition, format it, and mount it to the directory /ssd.

1. Check the existing partition status

 # df –l

As shown in the picture, The sdb hard disk is not seen

2. Check the status of the hard disk installed on the server (including formatted and unformatted)

# fdisk –l

The picture shows that there is an sdb hard disk, but there are no partitions.

3. Add a new partition

 # fdisk /dev/sdb

Enter in the red box below

N Enter

P Enter

1 Enter

Enter twice

W Enter

Use the following command to view the partition

# fdisk –l

The red box in the picture shows that there is one more partition , but not formatted yet.

4. Format partition

# mkfs -t ext4 -c /dev/sdb1
-t Determine what type of disk you want to format the disk into
-c Create a file system Checking for bad sectors in the past may be time-consuming. New hard disks generally do not require

5. Mount a new hard disk

In the root directory, create a folder. The partition will be mounted on this folder later. If you want to save things to the new hard disk in the future, just save it in the new folder.

# mkdir /ssd

Mount the hard disk

# mount /dev/sdb1 /ssd

 

6. Let the system automatically mount this hard disk when it boots up

# echo "/dev/sda1 /data ext4 defaults 0 0">>/etc/fstaba

 

The above is the detailed content of Format the newly added hard disk in linux and mount it to the directory. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Using chmod in LinuxNext article:Using chmod in Linux