对于学习磁盘分区,通常学习的都是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. windows 安装mysql的时候最后执行一直停留在Write configuration file

    出现原因:MySQL安装路径出现中文,特殊字符.或是重新安装MySQL后经常遇到.前者是路径不允许出现中文名称,后者是由于卸载不干净. 我就是因为重新安装了MySQL,卸载不干净,才会导致之后这个错误 ...

  2. Web.xml配置详解之context-param(转)

    本文转自:http://blog.csdn.net/liaoxiaohua1981/article/details/6759206 格式定义: <context-param> <pa ...

  3. Mysql Not in有null值查询的问题

    今天发现Mysql的not in使用的一个问题,大致是: select * from A where id not in (select fid from B). 发现查询结果无论如何都是0条记录.后 ...

  4. javaweb学习总结(三十九)——数据库连接池

    一.应用程序直接获取数据库连接的缺点 用户每次请求都需要向数据库获得链接,而数据库创建连接通常需要消耗相对较大的资源,创建时间也较长.假设网站一天10万访问量,数据库服务器就需要创建10万次连接,极大 ...

  5. [LeetCode#272] Closest Binary Search Tree Value II

    Problem: Given a non-empty binary search tree and a target value, find k values in the BST that are ...

  6. POI导出数据内存溢出问题

    POI之前的版本不支持大数据量处理,如果数据过多则经常报OOM错误,有时候调整JVM大小效果也不是太好.3.8版本的POI新出来了SXSSFWorkbook,可以支持大数据量的操作,只是SXSSFWo ...

  7. cogs_14_搭配飞行员_(二分图匹配+最大流,网络流24题#01)

    描述 http://cojs.tk/cogs/problem/problem.php?pid=14 有一些正飞行员和副飞行员,给出每个正飞行员可以和哪些副飞行员一起飞.一架飞机上必须一正一副,求最多多 ...

  8. [转] POJ 题目分类

    转载来自http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html 初期:一.基本算法:     (1)枚举. (poj1753,p ...

  9. CSS clip:rect矩形剪裁功能及一些应用介绍

    CSS clip:rect矩形剪裁功能及一些应用介绍 by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.co ...

  10. CLR via C# 读书笔记 6-2 不同AppDomain之间的通信 z

    跨AppDomain通信有两种方式 1.Marshal By reference : 传递引用 2.Marshal By Value : 把需要传递的对象 通过序列化反序列化的方式传递过去(值拷贝) ...