前奏:先插上一块磁盘(做了RAID的磁盘才能分区)

查看磁盘连上服务器没有,或者说是可以进行分区前奏

  [root@PandaLi ~]# ll /dev/sd
  sda sda1 sda2 sda3 sdb sdc

第一步:创建分区命令

(这里说一下为什么要使用 -c 和 -u参数)

[root@PandaLi ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel        【下面三行是第一次进行分区它会自动提示的,我们不需要管】
Building a new DOS disklabel with disk identifier 0x7711a1b3.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to    【警告:dos兼容模式被弃用】
switch off the mode (command 'c') and change display units to            【强烈建议在分区的时候使用-c 和 -u 参数】
sectors (command 'u').

Command (m for help):

创建分区标准命令:fdisk -cu /dev/sdb    [对/dev/sdb进行分区]

[root@PandaLi ~]# fdisk -cu /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xa8d09c04.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help):

fdisk命令参数介绍

  m、获取帮助
     p、打印分区表。
     n、新建一个新分区。
     d、删除一个分区。
     q、退出不保存。
     w、把分区写进分区表,保存并退出。

Command (m for help): n    ####创建一个分区
Command action
e extended
p primary partition (1-4)
p   ####创建一个主分区
Partition number (1-4): 1    ####设置主分区编号
First sector (2048-2097151, default 2048):     ####主分区开始位置(默认是扇区)
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +200M      ####主分区结束位置 (可以使用K M G 单位) Command (m for help): p    ####查看当前分区信息 Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0xa8d09c04 Device Boot Start End Blocks Id System
/dev/sdb1 2048 411647 204800 83 Linux Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4):
Value out of range.
Partition number (1-4): 2
First sector (411648-2097151, default 411648):
Using default value 411648
Last sector, +sectors or +size{K,M,G} (411648-2097151, default 2097151): +300M Command (m for help): p Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0xa8d09c04 Device Boot Start End Blocks Id System
/dev/sdb1 2048 411647 204800 83 Linux
/dev/sdb2 411648 1026047 307200 83 Linux Command (m for help): n
Command action
e extended
p primary partition (1-4)
e    ####创建一个扩展分区
Partition number (1-4): 3
First sector (1026048-2097151, default 1026048):
Using default value 1026048
Last sector, +sectors or +size{K,M,G} (1026048-2097151, default 2097151):
Using default value 2097151 Command (m for help): p Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0xa8d09c04 Device Boot Start End Blocks Id System
/dev/sdb1 2048 411647 204800 83 Linux
/dev/sdb2 411648 1026047 307200 83 Linux
/dev/sdb3 1026048 2097151 535552 5 Extended Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l    ####创建一个逻辑分区(必须先要有扩展分区才能有逻辑分区)
First sector (1028096-2097151, default 1028096):
Using default value 1028096
Last sector, +sectors or +size{K,M,G} (1028096-2097151, default 2097151): +100M Command (m for help): p Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0xa8d09c04 Device Boot Start End Blocks Id System
/dev/sdb1 2048 411647 204800 83 Linux
/dev/sdb2 411648 1026047 307200 83 Linux
/dev/sdb3 1026048 2097151 535552 5 Extended
/dev/sdb5 1028096 1232895 102400 83 Linux

Command (m for help): t      ####修改分区的ID
Partition number (1-5): 5
Hex code (type L to list codes): l  ####查看全部编号(小写L)

0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx
5 Extended 42 SFS 86 NTFS volume set da Non-FS data
6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt
9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1
Hex code (type L to list codes): 82    ####把ID修改为82
Changed system type of partition 5 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0xa8d09c04

Device Boot Start End Blocks Id System
/dev/sdb1 2048 411647 204800 83 Linux
/dev/sdb2 411648 1026047 307200 83 Linux
/dev/sdb3 1026048 2097151 535552 5 Extended
/dev/sdb5 1028096 1232895 102400 82 Linux swap / Solaris

Command (m for help): d    ####删除一个分区

Partition number (1-5): 5

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0xa8d09c04

Device Boot Start End Blocks Id System
/dev/sdb1 2048 411647 204800 83 Linux
/dev/sdb2 411648 1026047 307200 83 Linux
/dev/sdb3 1026048 2097151 535552 5 Extended

Command (m for help):

Command (m for help): w    ####保存退出(q 是不保存退出)
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@PandaLi ~]#

第二步:查看内核是否已经识别分区命令
  cat /proc/partitions

第三步:通知内核重新读取磁盘分区表
  方法一:
    partprobe /dev/sdb    【推荐】
  方法二:
    partx [-a,-n] /dev/DEVICE

参数:
    -a:读取全部分区表
    -n:读取指定的分区表
  方法三:
    kpartx [-a,-f] /dev/DEVICE
    参数:
    -a:读取全部分区表
    -f:强制读取分区表 【注意:这种方法不建议使用,如果上面的读取方法不行的话,最后才使用这种方法】

第四步:格式化创建文件系统
  mkfs.ext4 /dev/sdb1

  注意:
    格式化文件系统的时候必须要指定格式化哪个分区
    格式化文件系统之后,系统会默认挂载25次或180天之后进行磁盘检查

第五步:让系统不对我们新创建的分区进行磁盘检查
  tune2fs -c 0 -i 0 /dev/sdb1

注意:这里也是必须要指定哪个分区

第六步:文件系统的临时挂载
  临时挂载:mount /dev/sdb1 /mnt/     【这里也是必须要指定哪个分区】

第七步:文件系统永久挂载
  方法一:设置开机自动运行
    把挂载命令放入到/etc/rc.local
  方法二:添加到开机自动挂载配置文件
    /etc/fstab      【设备文件 挂载点 设备文件类型 挂载参数 是否进行备份 是否进行磁盘检查】
    如果想以UUID挂载的话,可以使用命令查看分区的UUID编号:命令(blkid)

第八步:查看挂载情况
  mount
  cat /proc/mounts

备注:更多信息请查看本地资料:磁盘章节内容

【磁盘/文件系统】第二篇:标准磁盘分区流程针对fdisk(硬盘容量小于2T且分区数不能大于15个分区)的更多相关文章

  1. 【磁盘/文件系统】第三篇:标准磁盘分区流程针对parted(一般硬盘容量大于2T(但是小于2T也可以进行分区);分区数最大是支持100多个分区)

    说明: 在 Linux 上可以采用 parted 来对磁盘进行分区 1.通过 fdisk -l 可以查看磁盘是否存在, 由于使用的是大磁盘(大于2T),fdisk 不能用来作为分区工具了,而应该使用 ...

  2. CentOS7搭建FastDFS V5.11分布式文件系统-第二篇

    1.CentOS7 FastDFS搭建 前面已下载好了要用到的工具集,下面就可以开始安装了: 如果安装过程中出现问题,可以下载我提供的,当前测试可以通过的工具包: 点这里点这里 1.1 安装libfa ...

  3. 第二篇:git创建流程

    1.创建组织 2.创建 3.点击项目 创建完: 4.选择管理——>选择公钥——>添加个人公钥: 5.怎样生成公钥 5.1.如何生成ssh公钥 你可以按如下命令来生成 sshkey: ssh ...

  4. (转)硬盘分区备忘(主分区,扩展分区和逻辑分区)以及Linux硬盘分区工具parted 介绍

    场景:最近在学习Linux的基础知识,不可避免的设计到Linux的磁盘分区,以前做过总结,但是那种总结就是复制别人的文章,总结完就不想看第二遍,所以很容易就遗忘了!清楚明白的理解分区后,我就可以在自己 ...

  5. Linux性能优化从入门到实战:15 文件系统篇:磁盘 I/O

    磁盘   磁盘是可以持久化存储的设备,按照存储介质来分类:   (1)机械磁盘(硬盘驱动器,Hard Disk Driver,HDD),主要由盘片和读写磁头组成,数据就存储在盘片的环状磁道中.在读写数 ...

  6. Linux文件系统简介一(磁盘分区、开机过程、目录结构、文件权限、文件扩展名、目录管理)

    Linux:就是一组软件,一套操作系统=核心+系统呼叫接口层. 1.操作系统 操作系统 = 核心(内核) + 系统呼叫(接口) 操作系统其实也是一组程序,重点在于管理计算机的所有活动以及驱动系统中的所 ...

  7. SQL Server 服务器磁盘测试之SQLIO篇

    原文:SQL Server 服务器磁盘测试之SQLIO篇 数据库调优工作中,有一部分是需要排查IO问题的,例如IO的速度或者RAID级别无法响应高并发下的快速请求.最常见的就是查看磁盘每次读写的响应速 ...

  8. SQL Server 服务器磁盘测试之SQLIO篇(一)

    数据库调优工作中,有一部分是需要排查IO问题的,例如IO的速度或者RAID级别无法响应高并发下的快速请求.最常见的就是查看磁盘每次读写的响应速度,通过性能计数器Avg.Disk sec/Read(Wr ...

  9. 磁盘文件系统Fat、Fat32、NTFS、exFAT的优缺点

    我们在Windows系统里格式化磁盘的时候,文件系统的选项里可以看到有“FAT”.“FAT32”.“NTFS”等选项,在对U盘或其他移动存储设备 格式化的时候还会出现“exFAT”选项,那么这四种磁盘 ...

随机推荐

  1. 2020.7.19 区间dp阶段测试

    打崩了-- 事先说明,今天没有很在状态,所以题解就直接写在代码注释里的,非常抱歉 T1 颜色联通块 此题有争议,建议跳过 题目描述 N 个方块排成一排,第 i 个颜色为 Ci .定义一个颜色联通块 [ ...

  2. 【P4211 LNOI2014】LCA——树链剖分 +询问离线

    (7.16晚)更完先在B站颓一会儿-- --------------------------------------------------------------- (以下为luogu题面) 题目描 ...

  3. LeetCode 042 Trapping Rain Water

    题目要求:Trapping Rain Water Given n non-negative integers representing an elevation map where the width ...

  4. 安装seafile记录文档

    安装yum-cron.iptables .关闭selinux yum -y install cronie yum -y install yum-cron systemctl start yu,-cro ...

  5. AndroidStudio新导入项目,无法编译,rebuild、clean都无效

    此按钮,可以用gradle重新编译

  6. JZOJ2020年8月11日提高组T4 景点中心

    JZOJ2020年8月11日提高组T4 景点中心 题目 Description 话说宁波市的中小学生在镇海中学参加计算机程序设计比赛,比赛之余,他们在镇海中学的各个景点参观.镇海中学共有n个景点,每个 ...

  7. js创世纪--刨根问底原型和原型链

    原型和原型链 看图说话: 1.对象内部具有[[Prototype]]属性,该属性不可直接访问,浏览器通过__proto__(两条'_')可以让用户读写该内部属性,最重要的是,该属性指向创建本对象的原型 ...

  8. 第8.33节 Python中__getattr__以及__getattr__与__ getattribute__的关系深入剖析

    一. 引言 前面几节分别介绍了Python中属性操作捕获的三剑客:__ getattribute__方法.__setattr__方法.__delattr__方法,为什么__ getattribute_ ...

  9. 【开发工具】 使用 Postman 进行接口测试 (配置全局 token,JWT可用)

    在前后端分离开发的项目中,使用postman来做接口测试会方便很多,然而因为JWT的鉴权,导致每半小时token都要更新一下,使测试变的很麻烦. 如果把token设置为全局变量,方便做测试,每次自动获 ...

  10. Flask+MySQL+Redis的Docker配置

    Docker配置了好多天,昨天晚上终于把碎遮项目的Docker打包完成了,后面会继续完善项目代码,把稳定版本打包后推送到DockerHub上. 网上关于Docker配置的文章很多,但大部分都是复制粘贴 ...