Centos7.6分区、格式化、自动挂载磁盘

个人名片:
对人间的热爱与歌颂,可抵岁月冗长
Github‍:念舒_C.ying
CSDN主页✏️:念舒_C.ying
个人博客 :念舒_C.ying

Centos7.6分区、格式化、自动挂载磁盘

    • 1. 添加硬盘
    • 2. 执行fdisk -l 查看新添加的硬盘
    • 3. 对新加硬盘进行分区
    • 4. 格式化分区
    • 5. 创建挂载点
    • 6. 挂载磁盘
    • 7. 配置自动挂载

1. 添加硬盘

Centos7.6分区、格式化、自动挂载磁盘_第1张图片

2. 执行fdisk -l 查看新添加的硬盘

Centos7.6分区、格式化、自动挂载磁盘_第2张图片

3. 对新加硬盘进行分区

[root@zhaojie ~]# fdisk /dev/sdb
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 0xf48b9e25.

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-209715199, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): +10G
Partition 1 of type Linux and of size 10 GiB is set

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

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

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): e
Selected partition 4
First sector (73402368-209715199, default 73402368): 
Using default value 73402368
Last sector, +sectors or +size{K,M,G} (73402368-209715199, default 209715199): 
Using default value 209715199
Partition 4 of type Extended and of size 65 GiB is set

Command (m for help): n
All primary partitions are in use
Adding logical partition 5
First sector (73404416-209715199, default 73404416): 
Using default value 73404416
Last sector, +sectors or +size{K,M,G} (73404416-209715199, default 209715199): +10G
Partition 5 of type Linux and of size 10 GiB is set

Command (m for help): n
All primary partitions are in use
Adding logical partition 6
First sector (94377984-209715199, default 94377984): 
Using default value 94377984
Last sector, +sectors or +size{K,M,G} (94377984-209715199, default 209715199): +15G
Partition 6 of type Linux and of size 15 GiB is set

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

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

Centos7.6分区、格式化、自动挂载磁盘_第3张图片

4. 格式化分区

[root@zhaojie ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=655360 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=2621440, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

mkfs.ext4 /dev/sdb2
mkfs.ext4 /dev/sdb3
mkfs.ext4 /dev/sdb5
mkfs.ext4 /dev/sdb6

5. 创建挂载点

cd /opt/
mkdir sdb1 sdb2 sdb3 sdb5 sdb6

Centos7.6分区、格式化、自动挂载磁盘_第4张图片

6. 挂载磁盘

[root@zhaojie opt]# mount /dev/sdb1 /opt/sdb1
[root@zhaojie opt]# mount /dev/sdb2 /opt/sdb2
[root@zhaojie opt]# mount /dev/sdb3 /opt/sdb3
[root@zhaojie opt]# mount /dev/sdb5 /opt/sdb5
[root@zhaojie opt]# mount /dev/sdb6 /opt/sdb6
[root@zhaojie opt]# df -hT

Centos7.6分区、格式化、自动挂载磁盘_第5张图片

7. 配置自动挂载

vi /etc/fstab

/dev/sdb1               /opt/sdb1               xfs     defaults        0 0
/dev/sdb2               /opt/sdb2               ext4    defaults        0 0
/dev/sdb3               /opt/sdb3               ext4    defaults        0 0
/dev/sdb5               /opt/sdb5               ext4    defaults        0 0
/dev/sdb6               /opt/sdb6               ext4    defaults        0 0

Centos7.6分区、格式化、自动挂载磁盘_第6张图片

期待下次的分享,别忘了三连支持博主呀~
我是 念舒_C.ying ,期待你的关注~

你可能感兴趣的:(Linux,运维,centos,linux)