如何在Ubuntu18.04系统挂载磁盘
如何在Ubuntu18.04系统挂载磁盘
在Ubuntu18.04系统中,如何进行磁盘分区和挂载?本文将针对此问题进行详细说明。
如果新机器的需要挂载数据盘的话,需要对数据盘进行分区和格式化后才能够挂载。
1.首先查看当前所有的磁盘信息
fdisk -l

可以看到有sda 和sdb两个盘,其中sda是系统盘,sdb是我们要挂载的数据盘,还没有分区存在。
2.执行sudo fdisk /dev/sdb对sdb创建分区。

按m可以获得帮助:

3.我们选择输入n 创建一个新的分区
然后其他全部默认

这里p代表创建主分区,e代表创建扩展分区
说明:一块磁盘最多只能有4个主分区,要创建更多的磁盘只能选择创建扩展分区。无论创建了几个主分区,扩展分区的序号必定从5开始。
分区设置完之后输入w,保存磁盘分区设置
这样一个新的分区就建立好了
4.接下来对分区进行格式化
sudo mkfs -t ext3 /dev/sdb1

5.格式化完成可以对分区进行挂载了
mkdir /data #创建挂载点
mount /dev/sdb1 /data #将磁盘文件挂载到/data上

6.查看磁盘uuid

7.将分区信息写入 /etc/fstab 文件开机启动后自动挂载:
sudo vim /etc/fstab
在最后一行加入
UUID=磁盘uuid /data xfs defaults 0 0
说明:格式为[磁盘文件 或 uuid] [挂载点] [挂载磁盘类型linux为xfs windows为ntfs] [挂载参数默认defaults即可] [磁盘检查默认0即可] [磁盘检查默认0即可]

8.修改完/etc/fstab文件后,运行
sudo mount -a
配置完成