CentOS8挂载新硬盘

参考 https://www.kiccleaf.com/?p=803

创建新硬盘分区命令参数:

fdisk可以用m命令来看fdisk命令的内部命令;
a:命令指定启动分区;
d:命令删除一个存在的分区;
l:命令显示分区ID号的列表;
m:查看fdisk命令帮助;
n:命令创建一个新分区;
p:命令显示分区列表;
t:命令修改分区的类型ID号;
w:命令是将对分区表的修改存盘让它发生作用

[root@VM-0-8-centos /]# fdisk -l
Disk /dev/vda: 50 GiB, 53687091200 bytes, 104857600 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
Disklabel type: dos
Disk identifier: 0x89ee0607
//已经挂载的 分区 /dev/vda1
Device     Boot Start       End   Sectors Size Id Type
/dev/vda1  *     2048 104857566 104855519  50G 83 Linux

//新的硬盘 分区是 /dev/vdb
Disk /dev/vdb: 100 GiB, 107374182400 bytes, 209715200 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

[root@VM-0-8-centos /]# fdisk /dev/vdb

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

The old ext4 signature will be removed by a write command.

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

Command (m for help): n
Partition type
   //输入p分为主分区
   p   primary (0 primary, 0 extended, 4 free)
   //输入e分为逻辑分区
   e   extended (container for logical partitions)
Select (default p): p
//输入该主分区为第几个主分区,由于是新盘我们输入1来分第一个主分区
Partition number (1-4, default 1): 1
 
//First sector 是选择该分区的起始扇区,直接回车
First sector (2048-209715199, default 2048):
//使用全部可用存储额,直接回车
Last sector, +sectors or +size{K,M,G,T,P} (2048-209715199, default 209715199):

Created a new partition 1 of type 'Linux' and of size 100 GiB.

//w保存
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
格式化并且挂载
//mkfs.xfs命令带-f强制格式化
[root@VM-0-8-centos /]# mkfs.xfs -f /dev/vdb
meta-data=/dev/vdb               isize=512    agcount=4, agsize=6553600 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=26214400, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=12800, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

//用命令blkid 查看一下已是xfs格式
[root@VM-0-8-centos /]# blkid /dev/vdb
/dev/vdb: UUID="7429945e-5e0d-418c-8ce6-35979d36abf3" BLOCK_SIZE="512" TYPE="xfs"


//创建挂载目录(/home 已经存在 直接挂载)
//mount直接挂载硬盘至data
[root@VM-0-8-centos /]# mount /dev/vdb /home

//查看一下挂载的硬盘home
[root@kiccleaf ~]# df -h
[root@VM-0-8-centos /]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           1.9G   28K  1.9G   1% /dev/shm
tmpfs           1.9G  484K  1.9G   1% /run
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/vda1        50G  8.7G   39G  19% /
tmpfs           374M     0  374M   0% /run/user/0
/dev/vdb        100G  746M  100G   1% /home

//系统重启自动挂载该分区对fstab进行编辑
[root@VM-0-8-centos /]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Nov 26 02:11:36 2019
#
# 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=659e6f89-71fa-463d-842e-ccdf2c06e0fe /                       ext4    defaults        1 1
/var/newswap swap swap defaults 0 0
/dev/vdb /home xfs defaults 0 0

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值