fdisk命令用于观察硬盘实体使用情况,也可对硬盘分区。它采用传统的问答式界面,而非类似DOS fdisk的cfdisk互动式操作界面,因此在使用上较为不便,但功能却丝毫不打折扣。

语法

fdisk(选项)(参数)

选项

-b:指定每个分区的大小;

-l:列出指定的外围设备的分区表状况;

-s:将指定的分区大小输出到标准输出上,单位为区块;

-u:搭配"-l"参数列表,会用分区数目取代柱面数目,来表示每个分区的起始地址;

-v:显示版本信息。

参数

设备文件:指定要进行分区或者显示分区的硬盘设备文件。

实例

首先选择要进行操作的磁盘:

[root@localhost ~]# fdisk /dev/sdb

输入m列出可以执行的命令:

command (m for help): m

Command action

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility flag

d delete a partition

l list known partition types

m print this menu

n add a new partition

o create a new empty DOS partition table

p print the partition table

q quit without saving changes

s create a new empty Sun disklabel

t change a partition's system id

u change display/entry units

v verify the partition table w write table to disk and exit

x extra functionality (experts only)

输入p列出磁盘目前的分区情况:

Command (m for help): p

Disk /dev/sdb: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 1 8001 8e Linux LVM

/dev/sdb2 2 26 200812+ 83 Linux

输入d然后选择分区,删除现有分区:

Command (m for help): d

Partition number (1-4): 1

Command (m for help): d

Selected partition 2

查看分区情况,确认分区已经删除:

Command (m for help): print

Disk /dev/sdb: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

Command (m for help):

输入n建立新的磁盘分区,首先建立两个主磁盘分区:

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

p    //建立主分区

Partition number (1-4): 1  //分区号

First cylinder (1-391, default 1):  //分区起始位置

Using default value 1

last cylinder or +size or +sizeM or +sizeK (1-391, default 391): 100  //分区结束位置,单位为扇区

Command (m for help): n  //再建立一个分区

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 2  //分区号为2

First cylinder (101-391, default 101):

Using default value 101

Last cylinder or +size or +sizeM or +sizeK (101-391, default 391): +200M  //分区结束位置,单位为M

确认分区建立成功:

Command (m for help): p

Disk /dev/sdb: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 100 803218+ 83 Linux

/dev/sdb2 101 125 200812+ 83 Linux

再建立一个逻辑分区:

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

e  //选择扩展分区

Partition number (1-4): 3

First cylinder (126-391, default 126):

Using default value 126

Last cylinder or +size or +sizeM or +sizeK (126-391, default 391):

Using default value 391

确认扩展分区建立成功:

Command (m for help): p

Disk /dev/sdb: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 100 803218+ 83 Linux

/dev/sdb2 101 125 200812+ 83 Linux

/dev/sdb3 126 391 2136645 5 Extended

在扩展分区上建立两个逻辑分区:

Command (m for help): n

Command action

l   logical (5 or over)

p   primary partition (1-4)

l //选择逻辑分区

First cylinder (126-391, default 126):

Using default value 126

Last cylinder or +size or +sizeM or +sizeK (126-391, default 391): +400M

Command (m for help): n

Command action

l   logical (5 or over)

p   primary partition (1-4)

l

First cylinder (176-391, default 176):

Using default value 176

Last cylinder or +size or +sizeM or +sizeK (176-391, default 391):

Using default value 391

确认逻辑分区建立成功:

Command (m for help): p

Disk /dev/sdb: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 100 803218+ 83 Linux

/dev/sdb2 101 125 200812+ 83 Linux

/dev/sdb3 126 391 2136645 5 Extended

/dev/sdb5 126 175 401593+ 83 Linux

/dev/sdb6 176 391 1734988+ 83 Linux

Command (m for help):

从上面的结果我们可以看到,在硬盘sdb我们建立了2个主分区(sdb1,sdb2),1个扩展分区(sdb3),2个逻辑分区(sdb5,sdb6)

注意:主分区和扩展分区的磁盘号位1-4,也就是说最多有4个主分区或者扩展分区,逻辑分区开始的磁盘号为5,因此在这个实验中试没有sdb4的。

最后对分区操作进行保存:

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

建立好分区之后我们还需要对分区进行格式化才能在系统中使用磁盘。

在sdb1上建立ext2分区:

[root@localhost ~]# mkfs.ext2 /dev/sdb1

mke2fs 1.39 (29-May-2017)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

100576 inodes, 200804 blocks

10040 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=209715200

7 block groups

32768 blocks per group, 32768 fragments per group

14368 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840

Writing inode tables: done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

在sdb6上建立ext3分区:

[root@localhost ~]# mkfs.ext3 /dev/sdb6

mke2fs 1.39 (29-May-2017)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

217280 inodes, 433747 blocks

21687 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=444596224

14 block groups

32768 blocks per group, 32768 fragments per group

15520 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912

Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@localhost ~]#

建立两个目录/oracle和/web,将新建好的两个分区挂载到系统:

[root@localhost ~]# mkdir /oracle

[root@localhost ~]# mkdir /web

[root@localhost ~]# mount /dev/sdb1 /oracle

[root@localhost ~]# mount /dev/sdb6 /web

查看分区挂载情况:

[root@localhost ~]# df -h

文件系统 容量 已用 可用 已用% 挂载点

/dev/mapper/VolGroup00-LogVol00

6.7G 2.8G 3.6G 44% /

/dev/sda1 99M 12M 82M 13% /boot

tmpfs 125M 0 125M 0% /dev/shm

/dev/sdb1 773M 808K 733M 1% /oracle

/dev/sdb6 1.7G 35M 1.6G 3% /web

如果需要每次开机自动挂载则需要修改/etc/fstab文件,加入两行配置:

[root@localhost ~]# vim /etc/fstab

/dev/VolGroup00/LogVol00 / ext3 defaults 1 1

LABEL=/boot /boot ext3 defaults 1 2

tmpfs /dev/shm tmpfs defaults 0 0

devpts /dev/pts devpts gid=5,mode=620 0 0

sysfs /sys sysfs defaults 0 0

proc /proc proc defaults 0 0

/dev/VolGroup00/LogVol01 swap swap defaults 0 0

/dev/sdb1 /oracle ext2 defaults 0 0

/dev/sdb6 /web ext3 defaults 0 0

oracle linux查看磁盘,fdisk命令_Linux fdisk命令使用详解:查看磁盘使用情况与磁盘分区...相关推荐

  1. linux命令ps -aux|grep xxx详解

    linux命令ps -aux|grep xxx详解 要对进程进行监测和控制,首先必须要了解当前进程的情况,也就是需要查看当前进程, 而ps命令(Process Status)就是最基本同时也是非常强大 ...

  2. linux xxx命令,linux命令ps aux|grep xxx详解

    对进程进行监测和控制,首先必须要了解当前进程的情况,也就是需要查看当前进程, 而ps命令(Process Status)就是最基本同时也是非常强大的进程查看命令. 使用该命令 可以确定有哪些进程正在运 ...

  3. 编程实现linux中的who命令功能,Linux who命令简介及使用方法详解

    玩蛇网推荐图文教程:python 列表 本文是关于Linux who命令简介及使用方法详解一文.如果你是一名系统管理员,可能需要需要在一个特定的时间点都有谁活跃在系统上.以便必须严密监视我们的服务器. ...

  4. linux添加目录命令权限,linux chmod命令设置目录/文件权限详解

    首页 > Linux教程 > 常用命令 > chmod 文件权限 linux chmod命令设置目录/文件权限详解 linux中chmod命令用于改变系统文件或目录的访问权限,用数字 ...

  5. linux cp -r 参数,Linux系统中cp命令的参数及用法详解

    Linux系统中cp命令主要是用来复制文件或者目录.下面由学习啦小编为大家整理了Linux系统中cp命令的参数及用法详解的相关知识,希望对大家有帮助! Linux系统中cp命令的参数及用法详解:参数说 ...

  6. linux dig命令的安装和使用详解

    linux dig命令的安装和使用详解 什么是dig命令 Dig是Domain Information Gopher的缩写,是一种DNS查找实用程序,用于探测DNS服务器并解决与DNS服务器相关的问题 ...

  7. linux中替换命令详解,linux中sed命令字符串替换的用法详解

    Linux系统中sed命令可以将字符串批量替换,省去了很多麻烦,下面由学习啦小编为大家整理了linux系统中sed命令字符串替换的用法详解,希望对大家有帮助! linux中sed命令字符串替换的用法详 ...

  8. linux Shell(脚本)编程入门实例讲解详解

    linux Shell(脚本)编程入门实例讲解详解 为什么要进行shell编程 在Linux系统中,虽然有各种各样的图形化接口工具,但是sell仍然是一个非常灵活的工具.Shell不仅仅是命令的收集, ...

  9. python调用adb shell命令_Python之使用adb shell命令启动应用的方法详解

    Python之使用adb shell命令启动应用的方法详解 一直有一个心愿希望可以用Python做安卓自动化功能测试,在一步步摸索中,之前是用monkeyrunner,但是发现对于控件ID的使用非常具 ...

  10. linux系统四个组成部分,Linux系统由哪几部分组成?系统详解(干货)

    原标题:Linux系统由哪几部分组成?系统详解(干货) 我们常说的Linux一般指的是系统内核,基于Linux系统内核的操作系统叫Linux发行版操作系统,像redhat.centos.ubuntu和 ...

最新文章

  1. centos7grub配置文件及排错
  2. codeforces水题100道 第五题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas (math)
  3. 通过Java字节码发现有趣的内幕之String篇(上)(转)
  4. excel 打开csv中文乱码
  5. Prthon编码和解码/is 和 ==
  6. python header头部请求_python3爬虫怎样构建请求header
  7. Python 爬虫进阶必备——某体育网站登录令牌加密分析,赶紧收藏哦!
  8. linux top 命令各参数详解
  9. python terminal_在PyCharm的 Terminal(终端)切换Python版本的方法
  10. python time
  11. Spring Cloud Gateway替代zuul作为API网关(一)
  12. gis怎么提取水系_利用ArcGIS水文分析工具提取河网
  13. myeclipse中tomcat热部署设置
  14. 使用Mapper代理开发解决硬编码问题
  15. 计算机学校宣传片创意和构思,【差一步就会02】用PPT做影视宣传片
  16. 学生评教系统--教师评教
  17. debounce与throttle区别
  18. 去掉Holo主题下Dialog的蓝色线
  19. 菜鸟的Unity自学日志10 音频
  20. Datax及Datax-web 下载使用

热门文章

  1. ubantu自带防火墙的相关使用
  2. ensp静态路由的配置及分析
  3. linux终端默认密码是多少,linux基础懂多少?两个小问题考考你
  4. mysql limit括号_采坑笔记——mysql的order by和limit排序问题
  5. python模块下载连接清华镜像的具体步骤_如何下载Pycharm开源版以及设置国内镜像源-百度经验...
  6. android滚轮实现时间年月日选择
  7. Androd开发之通过ComponentName和setComponent以及scheme打开外部应用 | 打开任意页面 | 打开指定页面
  8. python报数组越界_python数组越界
  9. 人工智能应用上的九大障碍
  10. logstash的使用教程