前奏:先插上一块磁盘(做了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. Spring Framework 5.0简述

    从Spring框架5.0开始,Spring需要JDK 8+ (Java SE 8+),并且已经为JDK 9提供了现成的支持. Spring框架还支持依赖注入(JSR 330)和通用注释(JSR 250 ...

  2. matlab中实现 IEEE754浮点数 与 一般十进制数之间 互相转换的方法

    ------------恢复内容开始------------ %2020/12/2 11:42:31clcformat long % IEEE754 to deca = '40800000'a = d ...

  3. Java 虚拟机垃圾收集机制详解

    本文摘自深入理解 Java 虚拟机第三版 垃圾收集发生的区域 之前我们介绍过 Java 内存运行时区域的各个部分,其中程序计数器.虚拟机栈.本地方法栈三个区域随线程共存亡.栈中的每一个栈帧分配多少内存 ...

  4. java并发编程实战《八》管程

    管程:并发编程的万能钥匙 为什么 Java 在 1.5 之前仅仅提供了 synchronized 关键字及 wait().notify().notifyAll() 这三个看似从天而降的方法? Java ...

  5. moviepy音视频剪辑:颜色相关变换函数blackwhite、colorx、fadein/out、gamma_corr、invert_colors、lum_contrast、mask_color介绍

    ☞ ░ 前往老猿Python博文目录 ░ 一.引言 在<moviepy音视频剪辑:moviepy中的剪辑基类Clip详解>介绍了剪辑基类的fl.fl_time.fx方法,在<movi ...

  6. 【开发工具】 使用阿里的 Teambition 跟踪BUG修复及需求管理

    刚入公司几个月,公司新项目一直没有用协作工具进行BUG管理,公司也没有专业的测试工程师. 第一阶段开发到了尾声,工作效率实在太低,随决定使用一个比较现代一点的管理工具. 在众多在线项目协作软件中,我选 ...

  7. 学习tcp和udp

    tcp和udp的差别 tcp和udp是不一样的 tcp是一个可靠的连接,如果发出一个tcp请求,那么就一定要回复一个请求 而udp是不需要回复的,就像QQ一样,只要发过来就可以了,不管别人在不在线,发 ...

  8. vue中监视对象内部变化的三种方法

    一,对整个对象监视 watch:{ obj:{ handler(newV,oldV){ console.log('obj changed') }, deep: true,//深度遍历 immediat ...

  9. 学习笔记:Prufer 编码

    Prufer 编码可以将无根树与序列之间进行转化. 一个 \(n\) 个点.区分编号的无向图 和 Prufer 序列一定是一一对应的,下面会给出映射方式. 借此可以证明 Cayley 定理: \(n\ ...

  10. CF1373F Network Coverage

    题目链接 对于每一个 \(i\) 可以看作一个管道.赋予三个信息: \(\text{minIn}_i\) 表示至少要从上一家 \(i - 1\) 得到连接数,才能正常供给 \(i\) 城市 \(\te ...