Welcome: Hunan Intelligent Applications Tecgnology CO.,ltd.-HNIAT.com
Language: Chinese ∷  English

Basic knowledge

centos7 View unmounted disks and mount them

Part 1: Overview

To mount a disk that is not mounted by the system, it can be divided into the following steps
1. Check which disks are not mounted in the system
2. Partition the unmounted disk
3. Format the disk and write system files to the disk
4. Mount the disk
5. Set up automatic mount at startup

Part II: Brief Techniques

The following commands are available

1. View disk information: fdisk -l

2. Disk partition fdisk disk

3. Format the disk partition mkfs.disk format -f partition location

For example: mkfs.xfs /dev/sdb1

4, mount the partition mount partition location need to mount the directory

For example: mount /dev/sdb1 /opt/data

5. View the system disk format df -hT

Part 3: Operation

1. View hard disk information

fdisk -l
1.


 

 

 

 

 

 

 

 

 

 

 

 

With the above command, you can see that /dev/sda has been partitioned, and /dev/sdb has not been partitioned.
We can see that there are /dev/sda1 /dev/sda2 under /dev/sda, which have been partitioned
And there is no /dev/sdb, it is the target of our operation

2. Disk partition (partitions include primary partition, extended partition, and logical partition); the command is as follows:

fdisk /dev/sdb
1.


The above picture roughly means this:
n: add a partition
P: Primary partition
Two carriage returns refer to the start and end of the disk sector size;
w: write to disk

We look at the disk again and we can see the partition we just created
 

fdisk -l
1.


Can we see from the above figure that there is already a partition under /dev/sdb

Note: Although the disk has been partitioned, but there is no file system, the disk still cannot be used;

3. Format the disk and write to the file system

First, we can check the current system disk file format, the command is as follows

df -hT
1.


Format the disk We can choose the system format of ext3 or ext4

mkfs.ext4 /dev/vdb1
mkfs.ext3 /dev/vdb1
1.
2.
We can also choose the same disk file format as the root directory, here I choose the same format as the system root directory,

mkfs.xfs /dev/sdb1
1.
Fourth, mount the partition

1. Create a mount directory

mkdir /opt/data

mount /dev/sdb1 /opt/data

2. View the mount



It can be seen that the one just mounted already exists and can be used now

Five, set the boot to automatically mount

Edit the file /etc/fstab

vim /etc/fstab

Add the following code to the last line, note that xfs is replaced by your own formatted format

Partition location Mount directory Disk format defaults 0 1

/dev/sdb1 /opt/data xfs defaults 0 1
1.
 

6. Uninstall the mounted hard disk

umount /mount the directory

CONTACT US

Contact: Manager Xu

Phone: 13907330718

Tel: 0731-22222718

Email: hniatcom@163.com

Add: Room 603, 6th Floor, Shifting Room, No. 2, Orbit Zhigu, No. 79 Liancheng Road, Shifeng District, Zhuzhou City, Hunan Province

Scan the qr codeClose
the qr code