Centos 7初始化硬盘分区、挂载和开机自动挂载---fdisk 和parted工具

参考这篇博客:储存结构和磁盘划分

fdisk工具只能处理最大2T的磁盘(超过2T的磁盘,它也只能识别到2T),超过2T的磁盘使用parted工具。

简单介绍磁盘分区、格式化和挂载。

1.lsblk命令查看磁盘情况,第二块硬盘sdb还没有分区

2.fdisk /dev/sdb 开始分区,分别输入相关的命令,给这个盘分区557GB

3.lsblk命令查看,分区成功

4. mkfs -t ext4 /dev/sdb1    创建文件系统,即对分区进行格式化,这里是格式化成ext4文件系统。

也可以格式化成xfs格式,ext4 与 xfs的区别?可以找资料看一下。格式化之后,这个分区就有UUID了。

5. mkdir /gee   创建目录

6. mount /dev/sdb1 /gee   把这个分区挂载在这个目录下。

7.设置开机自动挂载

blkid命令查看 sdb1分区的UUID

编辑/etc/fstab,在最后一行添加:

UUID=f640ca5f-b37d-45dc-ae67-ed99fe4b1b50 /gee ext4 defaults 0 2

重启服务器 reboot,可以看到开机自动挂载了。

 

又增加了一个3T的sdc,下面是分区的过程:

 

问题处理,经过反复修改分区之后,物理磁盘空间与文件系统的容量可能不一致:

比如:

官方的解释是:

The block device is now bigger, but the filesystem still has its old size. You need to resize it, e.g. using resize2fs - increasing size can be done online.

The steps are these (assuming this is the last partition on the block device):

  1. First use fdisk or friends to extend the partition,
  2. then use the resize tool for your file system (resize2fs for 
    ext{2,3,4}) to resize the file system.

You don’t need to stop your processes, if you use a file system, that can grow online (such as ext{2,3,4} or ocfs2)

那就需要对文件系统进行扩展,ext{2,3,4}文件系统用命令:resize2fs  ; xfs 文件系统用命令:xfs_growfs

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值