查看硬盘的挂载情况
[root@localhost /]# fdisk -l | grep 'dev'
Disk /dev/sda: 479.6 GB, 479559942144 bytes, 936640512 sectors
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 936640511 467807232 8e Linux LVM
Disk /dev/sdb: 479.6 GB, 479559942144 bytes, 936640512 sectors
/dev/sdb1 2048 936640511 468319232 83 Linux
Disk /dev/sdc: 899.6 GB, 899627876352 bytes, 1757085696 sectors
/dev/sdc1 2048 1757085695 878541824 83 Linux
Disk /dev/sdd: 899.6 GB, 899627876352 bytes, 1757085696 sectors
/dev/sdd1 2048 1757085695 878541824 83 Linux
Disk /dev/sde: 899.6 GB, 899627876352 bytes, 1757085696 sectors
/dev/sde1 2048 1757085695 878541824 83 Linux
Disk /dev/sdf: 899.6 GB, 899627876352 bytes, 1757085696 sectors
/dev/sdf1 2048 1757085695 878541824 83 Linux
Disk /dev/mapper/centos-root: 107.4 GB, 107374182400 bytes, 209715200 sectors
Disk /dev/mapper/centos-swap: 8589 MB, 8589934592 bytes, 16777216 sectors
Disk /dev/mapper/centos-home: 363.1 GB, 363063148544 bytes, 709107712 sectors
[root@localhost data01]# fdisk -l
Disk /dev/sda: 479.6 GB, 479559942144 bytes, 936640512 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x00013b88
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 936640511 467807232 8e Linux LVM
Disk /dev/sdb: 479.6 GB, 479559942144 bytes, 936640512 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x000621fc
Device Boot Start End Blocks Id System
/dev/sdb1 2048 936640511 468319232 83 Linux
Disk /dev/sdc: 899.6 GB, 899627876352 bytes, 1757085696 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006e378
Device Boot Start End Blocks Id System
/dev/sdc1 2048 1757085695 878541824 83 Linux
Disk /dev/sdd: 899.6 GB, 899627876352 bytes, 1757085696 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bac6b
Device Boot Start End Blocks Id System
/dev/sdd1 2048 1757085695 878541824 83 Linux
Disk /dev/sde: 899.6 GB, 899627876352 bytes, 1757085696 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00049828
Device Boot Start End Blocks Id System
/dev/sde1 2048 1757085695 878541824 83 Linux
Disk /dev/sdf: 899.6 GB, 899627876352 bytes, 1757085696 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00030fe3
Device Boot Start End Blocks Id System
/dev/sdf1 2048 1757085695 878541824 83 Linux
Disk /dev/mapper/centos-root: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/centos-swap: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/centos-home: 363.1 GB, 363063148544 bytes, 709107712 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
我目前使用的主机挂载了sda,sdb,sdc,sdd,sde,sdf 总共6块硬盘
第一步:对硬盘进行分区:
--执行命令 fdisk 硬盘路径
[root@localhost ~]# fdisk /dev/sde
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.
--输入m,查看分区参数
Command (m for help): 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)
--增加新的分区
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-1757085695, default 2048):
Using default value 2048
--分区结束点
Last sector, +sectors or +size{K,M,G} (2048-1757085695, default 1757085695):
Using default value 1757085695
Partition 1 of type Linux and of size 837.9 GiB is set
--选择w开始写入分区并退出
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
第二步:格式化分区:
[root@localhost /]# mkfs.ext4 /dev/sdf1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
54910976 inodes, 219635456 blocks
10981772 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2367684608
6703 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
第三步:挂载分区,查看磁盘使用情况:
[root@localhost /]# mount /dev/sdf1 /data05
[root@localhost /]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 95G 0 95G 0% /dev
tmpfs 95G 0 95G 0% /dev/shm
tmpfs 95G 9.6M 95G 1% /run
tmpfs 95G 0 95G 0% /sys/fs/cgroup
/dev/mapper/centos-root 100G 1.2G 99G 2% /
/dev/sda1 494M 143M 352M 29% /boot
/dev/mapper/centos-swap 8.0G 33M 8.0G 1% /swap
/dev/mapper/centos-home 338G 33M 338G 1% /home
tmpfs 19G 0 19G 0% /run/user/0
/dev/sdb1 440G 73M 418G 1% /data01
/dev/sdc1 825G 77M 783G 1% /data02
/dev/sdd1 825G 77M 783G 1% /data03
/dev/sde1 825G 77M 783G 1% /data04
/dev/sdf1 825G 77M 783G 1% /data05
第四步:配置服务器重启自动挂载:
配置自动挂载的两种方式:
第一种查看磁盘UUID,然后修改/etc/fstab 文件
##查看磁盘UUID
[root@dipc1 ~]# blkid
/dev/sdf1: UUID="d53e2cfb-8de4-40c6-a49d-5e3e9e11ad09" TYPE="ext4"
/dev/sdd1: UUID="0a518ca9-9140-48db-a6ff-eddff2f41dc1" TYPE="ext4"
/dev/sde1: UUID="cd000552-0819-45ce-9038-a6fb0be8a340" TYPE="ext4"
/dev/sdc1: UUID="5903a42d-eb33-49c9-a128-8940d0b2d3ff" TYPE="ext4"
/dev/sda1: UUID="a3dfda98-d3e5-47ef-9bfb-b782c4af1ac0" TYPE="xfs"
/dev/sda2: UUID="ab9e5ea4-036c-4364-9705-7b0e41a32aa4" TYPE="xfs"
/dev/sda3: UUID="c54a6060-c8dd-4d0e-9872-640189204bc9" TYPE="xfs"
/dev/sda5: UUID="adae1ef1-c6a4-4874-a5a7-2abe5db1f27b" TYPE="xfs"
/dev/sdb1: UUID="494f9631-8eb6-49d0-928b-fd6c82f179b9" TYPE="ext4"
##配置自动挂载
[root@dipc1 ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu May 7 14:55:22 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=ab9e5ea4-036c-4364-9705-7b0e41a32aa4 / xfs defaults 0 0
UUID=a3dfda98-d3e5-47ef-9bfb-b782c4af1ac0 /boot xfs defaults 0 0
UUID=adae1ef1-c6a4-4874-a5a7-2abe5db1f27b /home xfs defaults 0 0
UUID=c54a6060-c8dd-4d0e-9872-640189204bc9 /swap xfs defaults 0 0
第二种方式:直接指定分区到某路径下:
[root@localhost data01]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Apr 14 07:12:18 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=5b4f0cdc-92f2-4190-bacc-498684ed6640 /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap /swap xfs defaults 0 0
/dev/sdb1 /data01 ext4 defaults 1 2
/dev/sdc1 /data02 ext4 defaults 1 2
/dev/sdd1 /data03 ext4 defaults 1 2
/dev/sde1 /data04 ext4 defaults 1 2
/dev/sdf1 /data05 ext4 defaults 1 2
fstab文件参数详解见:https://blog.csdn.net/richerg85/article/details/17917129