对于学习磁盘分区,通常学习的都是fdisk命令
当然,对于小于2TB的磁盘,我们基本上是使用fdisk命令进行分区
下面就简单介绍一下fdisk操作磁盘的基本命令和场景模拟

常用命令介绍
  fdisk -l 查看所有磁盘信息
  fdisk /dev/sdb  使用fdisk命令工具操作/dev/sdb磁盘
  m   显示所有的命令信息、用法
  p   显示分区信息
  q   退出
  w   保存分区信息,只有执行了w命令后才会把分区信息写入到磁盘
  d 1  删除磁盘的第一个分区

场景模拟

有一个1G的磁盘/dev/sdb

分区为一个主分区,一个扩展分区,大小都为200M

其中在扩展分区上面建立一个100M的逻辑分区 /dev/sdb5

格式化文件系统为 mkfs.ext4

实现开机自动挂载到目录 /backup3

1 使用fdisk命令工具操作磁盘/dev/sdb
   fdisk /dev/sdb
2 创建一个主分区
        Command (m for help): n
 Command action
    e   extended
    p   primary partition (1-4)
 p
 Partition number (1-4): 1
 Using default value 1
 Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +400M

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes
 255 heads, 63 sectors/track, 130 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x0004a98a

Device Boot      Start         End      Blocks   Id  System
 /dev/sdb1               1          52      417658+  83  Linux

3 创建一个扩展分区
 Command (m for help): n
 Command action
    e   extended
    p   primary partition (1-4)
 e
 Partition number (1-4): 2
 First cylinder (53-130, default 53):
 Using default value 53
 Last cylinder, +cylinders or +size{K,M,G} (53-130, default 130): +400M

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes
 255 heads, 63 sectors/track, 130 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x0004a98a

Device Boot      Start         End      Blocks   Id  System
 /dev/sdb1               1          52      417658+  83  Linux
 /dev/sdb2              53         104      417690    5  Extended

4 创建一个逻辑分区
 Command (m for help): n
 Command action
    l   logical (5 or over)
    p   primary partition (1-4)
 l
 First cylinder (53-104, default 53):
 Using default value 53
 Last cylinder, +cylinders or +size{K,M,G} (53-104, default 104): +100M

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes
 255 heads, 63 sectors/track, 130 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x0004a98a

Device Boot      Start         End      Blocks   Id  System
 /dev/sdb1               1          52      417658+  83  Linux
 /dev/sdb2              53         104      417690    5  Extended
 /dev/sdb5              53          66      112423+  83  Linux

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

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

6 对磁盘进行分区
  [root@hsj2 ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
104448 inodes, 417656 blocks
20882 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
51 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@hsj2 ~]# mkfs.ext4 /dev/sdb5
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
28112 inodes, 112420 blocks
5621 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
14 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

ok,搞定

linux 系统磁盘分区之fdisk的更多相关文章

  1. Linux系统磁盘分区、删除分区、格式化、挂载、卸载、开机自动挂载的方法总结

    Linux系统按照MBR(Master Boot Record)传统分区模式: 注意:传统的MBR(Master Boot Record)分区方式最大只能分2T容量的硬盘,超过2T的硬盘一般采用GPT ...

  2. [转]linux系统磁盘分区之parted

    转自:http://blog.csdn.net/h249059945/article/details/12668793 对于linux的分区通常可以使用fdisk命令工具和parted工具对于分区表通 ...

  3. linux系统磁盘分区之parted

    对于linux的分区通常可以使用fdisk命令工具和parted工具 对于分区表通常有MBR分区表和GPT分区表 对于磁盘大小小于2T的磁盘,我们可以使用fdisk和parted命令工具进行分区 对于 ...

  4. 3. Linux系统磁盘分区介绍

    1. 磁盘分区基本知识 1)磁盘在使用前一般要先分区(相当于建房子要分房间一样). 2)磁盘分区一般有主分区.扩展分区和逻辑分区之分.一块磁盘最多可以有4个主分区,其中一个主分区的位置可以用一个扩展分 ...

  5. Linux系统磁盘与分区管理(7)

    Linux最传统的磁盘文件系统(filesystem)使用的是EXT4格式,所以要了解文件系统就得要由认识EXT4开始,而文件系统是创建在硬盘上面的,因此我们得了解硬盘的物理组成才行,下面我们回来详细 ...

  6. Linux学习笔记(4)磁盘分区(fdisk)、挂载与文件系统命令

    Linux学习笔记(4)磁盘分区(fdisk).挂载与文件系统命令 1.磁盘分区是怎么表示的? 1.1 对于IDE接口,第一主盘为hda,第1从盘为hdb,第1从盘的第1个分区为hdb1 1.2 对于 ...

  7. linux 系统磁盘管理(主分区和逻辑分区)

    摘要:linux系统磁盘管理主分区和逻辑分区 1.linux系统分区应了解的常识 硬盘分区实质上是对硬盘的一种格式化,然后才能使用硬盘保存各种信息,在创建分区时,就已经设置好了硬盘的各项物理参数,指定 ...

  8. Linux下磁盘分区挂载

    一般你去买vps都会看到介绍说硬盘多少G  比如 80G 但是你进入系统df -h的时候发现怎么只有10G呢, 其实这10G是用来装系统的和一些常用服务软件的  不是给你放网站数据的 那50G硬盘在哪 ...

  9. Linux中磁盘分区——理论篇

    Linux中磁盘分区——理论篇 现在主流的分区的方式有两种——MBR分区和GPT分区,本文将着重介绍MBR分区底层原理,及用相关命令验证相关原理 Linux中磁盘分区理论篇 为什么要对磁盘进行分区 M ...

随机推荐

  1. UVA 825 Walkiing on the safe side

    根据地图,要求固定两点间最短路径的条数 . 这题的输入数据就是个坑,题目有没有说明数据之间有多个空格,结尾换行符之前也不止一个空格,WA了好几遍,以后这种情况看来都要默认按照多空格的情况处理了. 可以 ...

  2. Sass占位符选择器`%`

    摘录自Understanding placeholder selectors. @extend @extend让你能够在多个选择器中通过继承的方式共享一段样式: .icon { transition: ...

  3. SSH框架应用中常用Jar包用途介绍

    struts2需要的几个jar包:1)xwork-core-2.1.62)struts2-core-2.1.83)ognl-2.7.34)freemarker-2.3.155)commons-io-1 ...

  4. poj3140Contestants Division

    链接 这叫树形DP吗..?断开某条边 求剩下两颗树数权值和的差最小 dfs一遍 枚举边 查了n久 wa n次  dp数组没初始化.. 在poj上1A感觉应该挺爽 #include <iostre ...

  5. visual studio 2012更换皮肤、功能添加

    首先在vs2012的菜单:工具->扩展和更新,打开扩展和更新窗口,点击左侧“联机”,搜索栏里面输入Theme Editor.然后点击按钮,安装之后,在工具->选项->环境常规 面板上 ...

  6. 基于.NET平台的分布式应用程序的研究

    摘 要:.NET框架是Microsoft用于生成分布式Web应用程序和Web服务的下一代平台.概述了用于生成分布式应用程序的.NET框架的基本原理.重点讲述了.NET框架的基础:公共语言运行时(CLR ...

  7. c程序设计语言_习题8-4_重新实现c语言的库函数fseek(FILE*fp,longoffset,intorigin)

      fseek库函数 #include <stdio.h> int fseek(FILE *stream, long int offset, int origin); 返回:成功为0,出错 ...

  8. 一行代码搞定Adapter

    15年Google I/O大会发不了三个重要支持库 >Material design (Android Support Design) >百分比布局:Percent support lib ...

  9. dataframe 数据统计可视化---spark scala 应用

    统计效果: 代码部分: import org.apache.spark.sql.hive.HiveContext import org.apache.spark.{Logging, SparkConf ...

  10. Mealy和moore型状态机

    Moore型状态机:下一状态只由当前状态决定,即次态=f(现状,输入),输出=f(现状): Mealy型状态机:下一状态不但与当前状态有关,还与当前输入值有关,即次态=f(现状,输入),输出=f(现状 ...