Mounting a Hard Drive on a CentOS Server

RonWang5 years ago (2021-05-26)电子编程 COD27

Centos服务器挂载硬盘

1. 查看服务器上未挂载的磁盘(磁盘有普通磁盘,高效磁盘,SSD磁盘

Bash
fdisk -l

Centos

Amount Disk

2. 磁盘分区(分区有主分区,扩展 分区,逻辑分区)

Bash
fdisk /dev/vdb

n->p->1->回车->回车->w 步骤含义:

n:添加一个分区

p:主分区

两个回车指是开始和结束的磁盘扇区大小;

w:写入磁盘

3. 格式化磁盘并写入文件系统

Bash
mkfs.ext4 /dev/vdb1

//这里可以用ext3,也可以用ext4;

4. 挂载新磁盘到操作系统的某个节点上

Bash
mkdir /mnt1

//系统根目录创建目录mnt1,名称可自定义 

Bash
mount /dev/vdb1 /mnt1

//将磁盘挂载到创建的目录节点

5. 查看磁盘信息,确认挂载新磁盘是否成功

Bash
df

以上已成功挂载新磁盘。

6. 查看磁盘所有信息

用fdisk -l 命令查看,多了一个主分区:

Bash
/dev/vdb1

7. 查看磁盘的UUID

Bash
blkid

8. 设置开机启动自动挂载


新创建的分区不能开机自动挂载,每次重启机器都要手动挂载、设置开机自动挂载需要修改/etc/fstab文件。

Bash
vim /etc/fstab

 //打开后,在最后一行加入以下代码:

Bash
 /dev/vdb1 /mnt1 ext4 defaults 0 1

//如果上面用的是ext3,这里也要用ext3;

保存退出,对vim不熟悉的可查阅其他文章内容。 

重启服务器,至此磁盘挂载顺利完成。


Share with Friends:

Related Articles

C05 |   C/C++ Develop Environment

C05 | C/C++ Develop Environment

C语言教程05: C/C++开发环境C 语言编译器可以分为 C 和 C++两大类,其中 C++是 C 的超集,也支持 C 语言编程。事实上,编译器的选择不是最重要的,它们都可以完成基本的 C 语言编译…

How to Understand and Select the Right Wire Specifications

How to Understand and Select the Right Wire Specifications

如何读懂和选用合适的电线的规格?初级电线标准和规格入门知识American Wire Gauge “AWG” Chart – Wire Size & Ampacity TableAmerica…

Guide to UL Wire Specifications & Standards

Guide to UL Wire Specifications & Standards

Who is UL ?The UL enterprise is a global private safety company headquartered in Northbrook, Illinoi…

CODE | IR Remote Control Light - Arduino Project 050

CODE | IR Remote Control Light - Arduino Project 050

An IR remote and receiver communicate with each other by transmitting and decoding a signal in the f…

CODE | Piezo Sounder Melody Player - Arduino Project 012

CODE | Piezo Sounder Melody Player - Arduino Project 012

Rather than using the piezo to make annoying alarm sounds, why not use it to play a melody? You are…

DIY T12 Soldering (Full-Assembled Kits)

DIY T12 Soldering (Full-Assembled Kits)

前两天我们刚做了一起T12焊台的半散件的DIY组装,但是很多小伙伴反应这个版本的不够过瘾,对T12焊台的结构还是一知半解的,所以今天我们在上一期的基础上做一期特别的,全散件T12零件包的DIY组装视频…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.