先使用fdisk -l 列出设备的分区。我这里的/dev/sdb 磁盘是我向运行在virtualbox中的虚拟机

添加的虚拟磁盘。顺便来说下往运行在virtualbox 中的系统添加虚拟磁盘的方法。首先在virtualbox

的用户界面中选中要添加虚拟磁盘的虚拟机(虚拟机应该是关停的),单击设置,进入选中虚拟机的

设置界面,选择存储,进入选中虚拟机的存储设置界面,然后选择添加虚拟磁盘(添加的是.vdi格式

的虚拟磁盘),后面根据向导设置就好。

[root@zeng ~]# fdisk -l

Disk /dev/sdb: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 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: 0x00000000

Disk /dev/sdb doesn't contain a valid partition

table

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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: 0x000a0d66

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26        2177    17280000   83  Linux

/dev/sda3            2177        2611     3481600   82  Linux swap / Solaris

那个/dev/sdb 就是我们需要分区,格式化,挂载的设备。

再来看下系统已经挂载的设备。

[root@zeng ~]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda2             17008476  15287828    856648  95% /

tmpfs                   603748         0    603748   0% /dev/shm

/dev/sda1               198337     24175    163922  13% /boot

使用fdisk 对设备/dev/sdb 进行分区。

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

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

//使用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: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 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: 0xd7ea6b16

Device Boot      Start         End      Blocks   Id  System

//因为我还没有对这个设备进行分区,所有没有分区信息。使用n 新增一个

分区。

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

e

//选择扩展分区(对应 e) 因为我的系统中已经存在3个主分区了。并把所有的

/dev/sdb 设备的所有的空间分给扩展分区。

Partition number (1-4): 1

First cylinder (1-1044, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044):

Using default value 1044

//再次打印该设备的分区表。

Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 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: 0xd7ea6b16

//已经有一个扩展分区存在。

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        1044     8385898+   5  Extended

把上面操作写入磁盘分区表,并退出。

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

再来查看下设备的分区是由有误。

[root@zeng ~]# fdisk -l

Disk /dev/sdb: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 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: 0xd7ea6b16

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        1044     8385898+   5  Extended

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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: 0x000a0d66

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26        2177    17280000   83  Linux

/dev/sda3            2177        2611     3481600   82  Linux swap / Solaris

到现在为止我们只是创建了一个扩展分区,但是扩展分区是不能用来格式化的,所以我们

需要继续进行磁盘分区,创建逻辑分区。

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

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 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: 0xd7ea6b16

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        1044     8385898+   5  Extended

Command (m for help): n

Command action

l   logical (5 or over)

p   primary partition (1-4)

//现在l 表示逻辑分区。

l

First cylinder (1-1044, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044):

Using default value 1044

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

现在再来查看 /dev/sdb 的设备分区表。

[root@zeng ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 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: 0xd7ea6b16

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        1044     8385898+   5  Extended

/dev/sdb5               1        1044     8385867   83  Linux

已经多出一个/dev/sdb5了。逻辑分区是从5开始编号的。下面对新创建的

逻辑分区/dev/sdb5 进行格式化,我这里现在ext3 文件系统。

[root@zeng ~]# mkfs -t ext3 /dev/sdb5

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

//该文件系统的块大小是4KB。

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

524288 inodes, 2096466 blocks

104823 blocks (5.00%) reserved for the super user

First

data block=0

Maximum filesystem blocks=2147483648

64 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or

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

块大小的设置还是比较关键的参数,设置的大些有利于提高文件系统的

读写性能,但是如果系统存储的大多是很小的文件,存储空间的浪费将会比较

严重。比如如果操作系统中存储了很多容量比4KB小的多的文件,比如1KB,2KB

那么将会严重浪费系统的存储空间。所有在格式分区选择块大小的时候,先要

分析下将来设备(分区)用途(用来存放什么样的文件)。当然block size 的

大小影响不限以此。

分区分好了,也格式化好了,但是系统是不会把该文件系统自动挂载起来的。

[root@zeng ~]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda2             17008476  15295336    849140  95% /

tmpfs                   603748         0    603748   0% /dev/shm

/dev/sda1               198337     24175    163922  13% /boot

先创建一个挂载点。

[root@zeng ~]# mkdir /mnt/sdb5

进行挂载。

[root@zeng ~]# mount /dev/sdb5 /mnt/sdb5

再来设备的挂载情况。

[root@zeng ~]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda2             17008476  15295340    849136  95% /

tmpfs                   603748         0    603748   0% /dev/shm

/dev/sda1               198337     24175    163922  13% /boot

/dev/sdb5              8254208    149624   7685292   2% /mnt/sdb5

linux中怎么格式化磁盘分区,Linux 磁盘分区及格式化相关推荐

  1. linux中_Linux基础知识(Linux系统、Linux中的链表)

    Linux系统简介 Linux系统的结构及特点 Linux系统的结构图如下图所示: 从上图可以看出,Linux是一个典型的宏内核(一体化内核)结构.硬件系统上面时硬件抽象层,在硬件抽象层上面时内核服务 ...

  2. 19. linux中权限详解,Linux权限位,读写执行权限真正含义,chmod详解

    linux中权限详解,Linux权限位,读写执行权限真正含义,chmod详解 文章目录 Linux权限位 读写执行 三种权限真正含义和作用 权限对文件的作用 权限对目录的作用 示例 chmod 使用数 ...

  3. centos sudo不能运行_如何在 Linux 中配置 sudo 访问权限 | Linux 中国

    Linux 系统中 root 用户拥有 Linux 中全部控制权力.Linux 系统中 root 是拥有最高权力的用户,可以在系统中实施任意的行为.-- Magesh Maruthamuthu Lin ...

  4. linux取证教程,Linux中的取证(Forensics in Linux)

    Linux中的取证(Forensics in Linux) 数字调查的主要问题是通过加密或任何其他格式保护重要证据或数据. 基本示例是存储密码. 因此,有必要了解Linux操作系统在数字取证实施中的使 ...

  5. linux中Gy模式什么意思,Linux必学的60个命令 -其他

    其它命令:tar.unzip.gunzip.unarj.mtools.man.unendcode.uudecode. 在前面几讲中,我们把Linux命令按照在系统中的作用分成几个部分分别予以介绍.但是 ...

  6. linux中的改变bin级别,Linux常用命令

    关机命令:shutdown -h now / shutdown -r now / reboot 切换图形化界面:startx      切换到命令行:注销即可 添加用户:useradd xiaomin ...

  7. Linux中存储相关的命令,Linux存储管理命令与HAB相关命令

    首先了解Linux中的设备命名规则:在安装和使用Linux的过程中,您必然会接触到不少像hda1.ttyS0.eth0这样的设备名称.在Linux中,每个设备必须在它的驱动程序控制下运行,驱动程序则与 ...

  8. linux中df和ls区别,linux系统文件大小ls、df、du命令的区别

    发现一台用户的电脑,df检查出来的/磁盘空间占用了16G,比用du查看得到的磁盘空间大的多,du查看/下所有程序目录加起来还不到5G.这是什么原因呢? 即便是有隐藏文件,查了也很小啊. 一.df和du ...

  9. linux中which命令详解,Linux下which命令使用详解(转)

    我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索: which 查看可执行文件的位置. whereis 查看文件的位置. locate 配合数据库查看文件位置. f ...

  10. linux中dd命令详解,Linux dd命令详解

    Linux 操作系统管理员的最主要的工作就是保证 Linux 系统在工作期间能够正常的运行.但是要做到这样,并不是那么容易,因为 Linux 系统的运行环境十分复杂,会有很多因素导致 Linux 系统 ...

最新文章

  1. 端云一体人工智能开发平台整体架构
  2. 软件工程概论——课堂测试1
  3. android开发之动画的详解 整理资料 Android开发程序小冰整理
  4. JavaScript的DOM操作-重点部分-第一部分
  5. 聊城高级财经计算机应用升学,聊城高级财经职业学校成功承办省级职业技能大赛赛项...
  6. 三个案例带你看懂LayoutInflater中inflate方法两个参数和三个参数的区别
  7. 编写彩色空间转换程序:YUVtoRGB
  8. scipy.ndimage.zoom上采样与下采样
  9. 使用标准库函数对象的例子
  10. IPV6 IPV4双栈互通与静态路由
  11. csrss.exe系统进程介绍
  12. [Microsoft][ODBC SQL Server Driver][SQL Server]String or binary data would be truncated.
  13. Win11如何开启聚焦功能?Win11开启聚焦功能的方法
  14. android地图偏移谷歌中国地图偏移校正补丁,关于谷歌地图GPS偏移问题的解决办法...
  15. 啊哈C语言 第四章 【代码】【习题答案】
  16. CentOS7中安装PostgreSQL客户端
  17. 小白文件管理器android,小白文件管理器手机版
  18. c语言简单程序设计思维导图,用来梳理c编程核心知识思维导图
  19. 我转行程序员的那一年(八)
  20. hive窗口函数(over)详解

热门文章

  1. 爱家Aijiacms红色高端大型房产门户系统V9网站源码 带手机版
  2. 《英雄联盟》开发商因性别歧视被罚1亿美元
  3. 懒人精灵实现第一个基础框架
  4. 利用Java编写简单的猜拳游戏
  5. WEB网站常见受攻击方式及解决办法
  6. JS高级----面向对象
  7. Android要ios王者,IOS端的王者荣耀怎么添加android端的好友?
  8. Laravel5.5 搭建简单的社区(十)--发表评论
  9. Oracle数据库,批量插入数据
  10. 基于springboot的在线电子商城系统设计与实现