CentOS7 挂载新硬盘

文件系统 centos7 运维 · ez · 于 4年前 发布 · 2347 次阅读

查看系统是否检测到新的硬盘设备

hd, sd, vd 都试试

ls /dev/ |grep sd

我的服务器的结果

# ls /dev/ |grep vd
vda
vda1
vdb

就是他vdb,没有分区

查看分区大小

fdisk -l

新的硬盘分区

fdisk /dev/vdb

开始

]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xf39a3343.


Command (m for help): m # 先输入个m看看菜单
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

一般新建一个分区的输入 n ,分区的类型选 p 然后选分区起始扇区和结尾扇区。 分配完成后,输入w 保存

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2097151999, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151999, default 2097151999): 
Using default value 2097151999
Partition 1 of type Linux and of size 1000 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

设置分区格式

给分区设置xfs格式,可能时间会久,不要慌张,等一下就好了

mkfs.xfs -f /dev/vdb1

挂载

临时挂载

先创建目录,再将分区挂载到目录上。临时挂载重启后需要重新挂载

mkdir /data1
mount -t xfs /dev/vdb1 /data1

或挂载已有目录中,我习惯用srv作为扩展,所以

mount -t xfs /dev/vdb1 /srv

永久挂载

修改系统挂载硬盘的文件,其中0 0 表示在在开机时不对分区进行检查

vim /etc/fstab
#添加以下配置
/dev/vdb1       /srv      xfs   defaults   0 0

补充命令

#查看已经挂载的分区和文件系统类型
df -T

#显示出所有挂载和未挂载的分区,但不显示文件系统类型
fdisk -l

#查看未挂载的文件系统类型,以及哪些分区尚未格式化
parted -l

#查看未挂载的文件系统类型
lsblk -f

本文由 ez 创作,采用 知识共享署名 3.0 中国大陆许可协议 进行许可。 可自由转载、引用,但需署名作者且注明文章出处。

共收到 0 条回复
没有找到数据。
添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册