参考这篇博客:储存结构和磁盘划分
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):
- First use fdisk or friends to extend the partition,
- 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