centos7 disk mount and unloading

Description: The disk is full, add two disk space

Environment: centos7, VMware Workstation

Adding hard disk

Add two hard drives

 Into the system to see if the added successfully

fdisk –l |grep dev

disk partition

First, sdb operation

fdisk /dev/sdb

Commonly used commands Description: 

    the n-: create a new partition 

    d: Delete existing partitions 

    t: Modify the partition type 

    l: to see all types 

    p: shows the existing partition information 

    w: Save and exit 

    q: exit without saving 

    m: View help information

View existing partition, there is no data in the device the following line, indicating no saved partition

Create a new partition, enter n start

Description: Here, e is the extended partition, p is the primary partition, we enter p, or default is p, directly enter.

 Description: Sets a primary partition, primary partition number defaults to 1 ,. The default setting for the first sector number 2048, the last sector of the data disk number 41943039.20G a new primary partition.

View details of the new partition again

 w and enter the result is written to the partition table in the partition

 The partition into force and synchronized to the system

partprobe /dev/sdb

On / dev / sdb formatted

mkfs –t ext4 /dev/sdb

mount /dev/sdb /root/mountdata

Mount the partition

After formatting is complete Mounting partitions

First create a mount point

mkddir /root/mountdata 

Manually mount the disk mount point

mount /dev/sdb /root/mountdata

Set to boot automatically mount

vim /etc/fstab

Add the following information

/dev/sdb/ /root/mountdata/ ext4 defaults 0 0

Description: / dev / sdb: partition name; / root / mountdata /: Mount path; ext4: disk format; 00: Other default

或者使用UUID进行挂载,这里对/dev/sdc进行操作

如果使用/dev/sdb的方法,可能会出现找不到设备而加载失败的问题。uuid作为系统中存储设备提供的唯一标志字符串,使用UUID则不会出现这样的情况。

查看uuid的三种办法

blkid

lsblk -f

 

ll /dev/disk/by-uuid/

 

通过uuid添加自动挂载磁盘信息(vim /etc/fstab),格式与前面的类似

UUID=739cbb88-b375-4b56-8e1f-f1c31840bf3c /root/mountdata_sdc/ ext4 defaults 0 0

自动挂载/etc/fstab里面的东西

mount –a

如果在fstab里没有新增加设备,则没有输出,mount会自动忽略已经完成的操作。

查看挂载的情况,两块磁盘已经挂上去了,已经可以用了

df -h

重启服务器测试,发现可以自动挂载了

磁盘的卸载

umount /dev/sdc
永久卸载
vim /etc/fstab
把添加的磁盘信息删除
fdisk /dev/sdv
输入d,删除添加的磁盘,然后w保存

Guess you like

Origin www.cnblogs.com/maohai-kdg/p/12067101.html