centos7创建普通的分区01

环境 使用的是vmware虚拟机的模拟
创建普通分区:
[root@localhost ~]# ll /dev/sdb //查看分区
brw-rw----. 1 root disk 8, 16 Dec 26 06:54 /dev/sdb
[root@localhost ~]# fdisk /dev/sdb //使用fdisk创建分区
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 0x195afcc9.

Command (m for help): p //查看有哪些分区

Disk /dev/sdb: 17.2 GB, 17179869184 bytes, 33554432 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: 0x195afcc9

Device Boot Start End Blocks Id System

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): 第一个分区采用默认的操作
First sector (2048-33554431, default 2048): 开始的扇区
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-33554431, default 33554431): +5G //结束的扇区
Partition 1 of type Linux and of size 5 GiB is set

Command (m for help): p /查看分区类型

Disk /dev/sdb: 17.2 GB, 17179869184 bytes, 33554432 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: 0x195afcc9

Device Boot Start End Blocks Id System
/dev/sdb1 2048 10487807 5242880 83 Linux

Command (m for help): w ///保存分区表
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partprobe //刷新分区表
[root@localhost ~]# mkfs.xfs /dev/sdb1 //格式化分区
meta-data=/dev/sdb1 isize=256 agcount=4, agsize=327680 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
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
[root@localhost ~]# mkdir /sdb1 //创建挂载分区的目录
[root@localhost ~]# mount /dev/sdb1 /sdb1/ 挂载分区
[root@localhost ~]# df -Th //查看是不是挂载上了
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 48G 1.1G 47G 3% /
devtmpfs devtmpfs 983M 0 983M 0% /dev
tmpfs tmpfs 993M 0 993M 0% /dev/shm
tmpfs tmpfs 993M 8.6M 985M 1% /run
tmpfs tmpfs 993M 0 993M 0% /sys/fs/cgroup
/dev/sda1 xfs 497M 108M 390M 22% /boot
tmpfs tmpfs 199M 0 199M 0% /run/user/0
/dev/sdb1 xfs 5.0G 33M 5.0G 1% /sdb1
[root@localhost ~]# echo "/dev/sdb1 /sdb1/ xfs defaults 0 0 " >> /etc/fstab //编写fstab实现开机挂载分区
[root@localhost ~]# mount -a //检查fstab
[root@localhost ~]# grep sdb1 /etc/fstab //检查 fstab
/dev/sdb1 /sdb1/ xfs defaults 0 0
[root@localhost ~]#

到这里创建新分区就创建完成了

谢谢大家的支持 !!!1

猜你喜欢

转载自blog.csdn.net/smileui/article/details/106737511