1.磁盘的分区主要分为基本分区(primary partion)和扩充分区(extension partion)两种,基本分区和扩充分区的数目之和不能大于四个。且基本分区可以马上被使用但不能再分区。扩充分区必须再进行分区后才能使用,也就是说它必须还要进行二次分区。那么由扩充分区再分下去的是什么呢?它就是逻辑分区(logical partion),况且逻辑分区没有数量上限制。

在 Linux 中,每一个硬件设备都映射到一个系统的文件,对于硬盘、光驱等 IDE 或 SCSI 设备也不例外。Linux把各种 IDE 设备分配了一个由 hd 前缀组成的文件;而对于各种 SCSI 设备,则分配了一个由 sd 前缀组成的文件。

对于ide硬盘,驱动器标识符为“hdx”,其中“hd”表明分区所在设备的类型,这里是指ide硬盘了。“x”为盘号(a为基本盘,b为基本从属盘,c为辅助主盘,d为辅助从属盘),“”代表分区,前四个分区用数字1到4表示,它们是主分区或扩展分区,从5开始就是逻辑分区。例,hda3表示为第一个ide硬盘上的第三个主分区或扩展分区,hdb2表示为第二个ide硬盘上的第二个主分区或扩展分区。对于scsi硬盘则标识为“sdx~”,scsi硬盘是用“sd”来表示分区所在设备的类型的,其余则和ide硬盘的表示方法一样,不在多说。

在 Linux 中规定,每一个硬盘设备最多能有 4个主分区(其中包含扩展分区)构成,任何一个扩展分区都要占用一个主分区号码,也就是在一个硬盘中,主分区和扩展分区一共最多是 4 个。

Linux 规定了主分区(或者扩展分区)占用 1 至 16 号码中的前 4 个号码。以第一个 IDE 硬盘为例说明,主分区(或者扩展分区)占用了 hda1、hda2、hda3、hda4,而逻辑分区占用了 hda5 到 hda16 等 12 个号码。
  因此,Linux 下面每一个硬盘总共最多有 16 个分区。

IDE硬盘最多有64个分区

1.fdisk -l 查看系统分区详细信息

[root@test4 ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM

注释:这个硬盘的大小是21.4GB,有255个磁面,63个扇区,2610磁柱(cylinders)

每个cylinder(磁柱)的容量是 8225280 bytes=8225.280 K(约为)=8.225280M(约为);

Device Boot Start End Blocks Id System

/dev/sda1 * 1 13 104391 83 Linux

/dev/sda2 14 1305 10377990 8e Linux LVM

id和System 表示的是一个意思,id看起来不太直观,我们要在fdisk 一个分区时,通过指定id来确认分区类型;比如 7表示的就NTFS 分区;这个在fdisk 中要通过t功能来指定。83是linux。下面的部分会提到;

说明:硬盘分区的表示:在Linux 是通过hdx 或 sdx 表示的:

其中* 表示的是a、b、c … …

另外x 表示的数字 1、2、3 … …

hd大多是IDE硬盘;sd大多是SCSI或移动存储;引导(Boot):表示引导分区,在上面的例子中sda1 是引导分区;

Start (开始):表示的一个分区从Xcylinder(磁柱)开始;

End (结束):表示一个分区到 Ycylinder(磁柱)结束;

2.fdisk 对磁盘进行分区

[root@test4 ~]# fdisk /dev/sda  //对sda磁盘进行分区
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.The number of cylinders for this disk is set to 2597.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)Command (m for help): m          //输出帮助信息Command actiona   toggle a bootable flag    //设置启动分区b   edit bsd disklabel        //编辑分区标签c   toggle the dos compatibility flagd   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 //创建一个新的空白DOS分区表p   print the partition table    //打印分区表q   quit without saving changes  //退出不保存设置s   create a new empty Sun disklabelt   change a partition's system id  //改变分区的IDu   change display/entry units    //改变显示的单位v   verify the partition table    //检查验证分区表w   write table to disk and exit  //保存分区表x   extra functionality (experts only)
Command (m for help):n
Command actione   extended                 //e是扩展分区p   primary partition (1-4)  //p是主分区
p
Partition number (1-4): 1       //定义分区数量   --主分区最多只能有四个
First cylinder (1-2597, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-2597, default 2597): +100MCommand (m for help): w          //保存刚才的配置信息。
The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 22: 无效的参数.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@test6 ~]# fdisk /dev/sdaThe number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs(e.g., DOS FDISK, OS/2 FDISK)Command (m for help): n
First cylinder (1710-2610, default 1710):
Using default value 1710
Last cylinder or +size or +sizeM or +sizeK (1710-2610, default 2610): +100M     Command (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@test6 ~]# partprobe /dev/sda //对硬盘进行更新
[root@test6 ~]# fdisk -lDisk /dev/sda: 21.4 GB, 21474836480 bytes
heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         274     2096482+  82  Linux swap / Solaris
/dev/sda3             275         404     1044225   8e  Linux LVM
/dev/sda4             405        2610    17719695    5  Extended
/dev/sda5             405        1709    10482381   83  Linux
/dev/sda6            1710        1722      104391   83  Linux
[root@test6 ~]# mkfs.ext3 /dev/sda6  //需要先进行格式化,才能使用 。mkfs -t ext3 /dev/sda5 (mkfs.ext3 一样效果 -t 指定类型 -b 指定block大小·)
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
inodes, 104388 blocks
blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
block groups
blocks per group, 8192 fragments per group
inodes per group
Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 23 mounts or
days, whichever comes first.  Use tune2fs -c or -i to override.[root@test6 ~]# mount /dev/sda6 /mnt/sda7/  //进行挂载使用
anaconda-ks.cfg  install.log  install.log.syslog
[root@test6 ~]# df -h
文件系统              容量  已用 可用 已用% 挂载点
/dev/sda5             9.7G  1.1G  8.1G  12% /
/dev/sda1              99M   12M   83M  13% /boot
tmpfs                 252M     0  252M   0% /dev/shm
/dev/hdc              3.9G  3.9G     0 100% /mnt/cdrom
/dev/sda6              99M  5.6M   89M   6% /mnt/sda7

1.磁盘管理常用命令
1.1 ls -i 文件名 查看文件存储在哪个innode中

[root@test6 ~]# ls -i lstest 1179659 lstest

1.2 ls -id 文件夹名 查看文件夹存储在哪个innode中

[root@test6 ~]# ls -id lstest1
1179661 lstest1

1.3 filefrag -v 文件名 查看文件存储block具体位置

[root@test6 ~]# filefrag -v lstest
Checking lstest
Filesystem type is: ef53
Filesystem cylinder groups is approximately 78
Blocksize of file lstest is 4096
File size of lstest is 5 (1 blocks)
First block: 1183744
Last block: 1183744
lstest: 1 extent found

2.硬盘工具:

2.1 dumpe2fs /dev/sda1 查看分区superblock 和blockgroup等详细信息

[root@test6 ~]# dumpe2fs /dev/sda1
dumpe2fs 1.39 (29-May-2006)
Filesystem volume name:   /boot
Last mounted on:          <not available>
Filesystem UUID:          0c7f5306-fd13-4b13-819f-4b6cab126938
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              26104
Block count:              104388
Reserved block count:     5219
Free blocks:              89552
Free inodes:              26069
First block:              1
Block size:               1024
Fragment size:            1024
Reserved GDT blocks:      256
Blocks per group:         8192
Fragments per group:      8192
Inodes per group:         2008
Inode blocks per group:   251
Filesystem created:       Tue Mar 28 07:57:05 2017
Last mount time:          Tue Mar 28 08:29:57 2017
Last write time:          Tue Mar 28 08:29:57 2017
Mount count:              3
Maximum mount count:      -1
Last checked:             Tue Mar 28 07:57:05 2017
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal inode:            8  //ext3 日志inode位置
Default directory hash:   tea
Directory Hash Seed:      5e624e4a-049c-4cbf-a65f-8b8a7d08e398
Journal backup:           inode blocks
Journal size:             4114k  //日志文件大小Group 0: (Blocks 1-8192)Primary superblock at 1, Group descriptors at 2-2Reserved GDT blocks at 3-258Block bitmap at 259 (+258), Inode bitmap at 260 (+259)Inode table at 261-511 (+260)
free blocks, 1990 free inodes, 2 directoriesFree blocks: 4642-5664Free inodes: 19-2008
Group 1: (Blocks 8193-16384)Backup superblock at 8193, Group descriptors at 8194-8194Reserved GDT blocks at 8195-8450Block bitmap at 8451 (+258), Inode bitmap at 8452 (+259)Inode table at 8453-8703 (+260)
free blocks, 2008 free inodes, 0 directoriesFree blocks: 11802-16384Free inodes: 2009-4016
Group 2: (Blocks 16385-24576)Block bitmap at 16385 (+0), Inode bitmap at 16386 (+1)Inode table at 16387-16637 (+2)
free blocks, 2008 free inodes, 0 directoriesFree blocks: 16638-24576Free inodes: 4017-6024
Group 3: (Blocks 24577-32768)Backup superblock at 24577, Group descriptors at 24578-24578Reserved GDT blocks at 24579-24834Block bitmap at 24835 (+258), Inode bitmap at 24836 (+259)Inode table at 24837-25087 (+260)
free blocks, 1991 free inodes, 1 directoriesFree blocks: 25193-25600, 25609-26112, 26121-26624, 26632-27136, 27144-27648, 27657-28160, 28168-28672, 28683-29184, 29192-29696, 29704-30208, 30218-31744, 31804-32768Free inodes: 6042-8032
Group 4: (Blocks 32769-40960)Block bitmap at 32769 (+0), Inode bitmap at 32770 (+1)Inode table at 32771-33021 (+2)
free blocks, 2008 free inodes, 0 directoriesFree blocks: 33022-40960Free inodes: 8033-10040
Group 5: (Blocks 40961-49152)Backup superblock at 40961, Group descriptors at 40962-40962Reserved GDT blocks at 40963-41218Block bitmap at 41219 (+258), Inode bitmap at 41220 (+259)Inode table at 41221-41471 (+260)
free blocks, 2008 free inodes, 0 directoriesFree blocks: 41472-49152Free inodes: 10041-12048
Group 6: (Blocks 49153-57344)Block bitmap at 49153 (+0), Inode bitmap at 49154 (+1)Inode table at 49155-49405 (+2)
free blocks, 2008 free inodes, 0 directoriesFree blocks: 49406-57344Free inodes: 12049-14056
Group 7: (Blocks 57345-65536)Backup superblock at 57345, Group descriptors at 57346-57346Reserved GDT blocks at 57347-57602Block bitmap at 57603 (+258), Inode bitmap at 57604 (+259)Inode table at 57605-57855 (+260)
free blocks, 2008 free inodes, 0 directoriesFree blocks: 57856-65536Free inodes: 14057-16064
Group 8: (Blocks 65537-73728)Block bitmap at 65537 (+0), Inode bitmap at 65538 (+1)Inode table at 65539-65789 (+2)
free blocks, 2008 free inodes, 0 directoriesFree blocks: 65790-73728Free inodes: 16065-18072
Group 9: (Blocks 73729-81920)Backup superblock at 73729, Group descriptors at 73730-73730Reserved GDT blocks at 73731-73986Block bitmap at 73987 (+258), Inode bitmap at 73988 (+259)Inode table at 73989-74239 (+260)
free blocks, 2008 free inodes, 0 directoriesFree blocks: 74240-81920Free inodes: 18073-20080
Group 10: (Blocks 81921-90112)Block bitmap at 81921 (+0), Inode bitmap at 81922 (+1)Inode table at 81923-82173 (+2)
free blocks, 2008 free inodes, 0 directoriesFree blocks: 82174-90112Free inodes: 20081-22088
Group 11: (Blocks 90113-98304)Block bitmap at 90113 (+0), Inode bitmap at 90114 (+1)Inode table at 90115-90365 (+2)
free blocks, 2008 free inodes, 0 directoriesFree blocks: 90366-98304Free inodes: 22089-24096
Group 12: (Blocks 98305-104387)Block bitmap at 98305 (+0), Inode bitmap at 98306 (+1)Inode table at 98307-98557 (+2)
free blocks, 2008 free inodes, 0 directoriesFree blocks: 98558-104387Free inodes: 24097-26104

2.2 fsck /dev/sda 检查硬盘情况 -C 显示检查过程 -f 强制检查
  2.3 badblocks /dev/sda5 检查硬盘坏道 -sv 显示进度和结果
df 查看文件系统(-h 以合适的单位示系统大小 -T 显示系统类型)
du 查看文件夹大小,包含文件夹里面文件
du -s 仅仅查看文件夹大小
du -h 以M方式显示大小,方便查看

fuser -mv /mnt 当显示 设备正在忙的时候,可以使用这个命令查看使用进程
tune2fs -l /dev/sda 查看磁盘参数(-h 查看可选选项,进行选项更改)

[root@test6 ~]# tune2fs -l /dev/sda5
tune2fs 1.39 (29-May-2006)
Filesystem volume name:   /     //卷标
Last mounted on:          <not available>
Filesystem UUID:          4b64bcce-0acc-40f2-85e6-07e198152c20
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super large_file
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              2621440
Block count:              2620595
Reserved block count:     131029
Free blocks:              2257390
Free inodes:              2582833
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      639
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         32768
Inode blocks per group:   1024
Filesystem created:       Tue Mar 28 07:57:02 2017
Last mount time:          Tue Mar 28 08:29:56 2017
Last write time:          Tue Mar 28 08:29:56 2017
Mount count:              3
Maximum mount count:      -1    //超过最大次数,则需要对分区进行自检
Last checked:             Tue Mar 28 07:57:02 2017
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal inode:            8
First orphan inode:       163883
Default directory hash:   tea
Directory Hash Seed:      8633f5c3-e870-428e-8ce3-7d636f0ef80a
Journal backup:           inode blocks

e21able /dev/sda7 aa 卷标的另一种改法

linux磁盘分区详解相关推荐

  1. linux磁盘分区什么意思,linux 磁盘分区详解

    <linux 磁盘分区详解>由会员分享,可在线阅读,更多相关<linux 磁盘分区详解(31页珍藏版)>请在人人文库网上搜索. 1.系统引导过程和硬盘分区结构讨论作者:章节来源 ...

  2. Linux磁盘分区详解(parted)

    一.什么是分区以及分区的作用 分区是将一个硬盘驱动器分成若干个逻辑驱动器,能够把硬盘连续的区块当作一个独立的磁盘分开使用. ◇ 防止数据丢失:如果系统只有一个分区,那么假如这个分区损坏,用户将会丢失所 ...

  3. Linux磁盘分区详解(fdisk)

    一.什么是分区? 分区是将一个硬盘驱动器分成若干个逻辑驱动器,能够把硬盘连续的区块当作一个独立的磁盘分开使用. 二.为什么要有多个分区? ◇ 防止数据丢失:如果系统只有一个分区,那么假如这个分区损坏, ...

  4. Linux磁盘分区详解(新建分区,现有分区扩容,分区减容)

    目录 一.Linux文件系统简介 1.磁盘概念 2.分区的概念 3.LVM 管理命令 4. 基本术语 二.给虚拟机增加磁盘 1.虚拟机添加新磁盘 2.查看新加的磁盘 三.服务器新建磁盘空间 1.新建分 ...

  5. Windows7旗舰版磁盘分区详解—附分区步骤截图

    最近工作中配置使用联想的Thinkpad TL系列本本.当然原装的系统时刚发布的Windows RTM旗舰版.在考虑买之前也参考了戴尔 苹果的等等, 但个人私下也是一直在用Tinkpad系列, 相比其 ...

  6. centos7盘符 linux_linux操作系统centos7新加磁盘分区详解

    磁盘分区与磁盘挂载 查看磁盘情况:lsblk -f [root@localhost ~]# lsblk -f NAME FSTYPE LABEL UUID MOUNTPOINT sda ├─sda1 ...

  7. Linux系统分区详解

    安装linux系统时 一般会分配三个区 分区 作用 /boot 系统的启动分区 /swap 交换分区 / 系统文件根目录,Linux顶级目录 简单介绍一下三个分区 /boot 引导分区,存放引导文件和 ...

  8. Linux磁盘扩容详解

    公司项目服务器是买的阿里的,原来的项目是外包出去别人做的,用户图片上传保存到了服务器上,500G的磁盘空间硬生生给用完了,怎么搞?扩容呗,大概思路就是从阿里那再买一块磁盘,添加到ESC实例上,然后挂载 ...

  9. linux中fdisk的参数,Linux fdisk命令参数及用法详解--Linux磁盘分区管理命令fdisk

    fdisk 命令 linux磁盘分区管理 用途:观察硬盘之实体使用情形与分割硬盘用. 使用方法: 一.在 console 上输入 fdisk -l /dev/sda ,观察硬盘之实体使用情形. 二.在 ...

  10. Linux常用基本命令详解(二)-------磁盘分区和磁盘管理类命令

    Linux常用基本命令详解(一) Linux常用基本命令详解(二)-------磁盘分区和磁盘管理类命令 Linux常用基本命令详解(三) 1.磁盘分区 磁盘分区(系统分区)是使用分区编辑器(part ...

最新文章

  1. Bridge Pattern
  2. 决策树算法(四)——选取最佳特征划分数据集
  3. sql 精读(四) 标准 SQL 中聚合分析功能示例
  4. ArrayList笔记
  5. java并发编程之美-阅读记录6
  6. Python 编码规范 PEP 8
  7. STM32——时钟系统
  8. Android O 获取APK文件权限 Demo案例
  9. 两年内,我要成为国内优秀的前端技术人员!
  10. 社交网站 分享 +button
  11. Java8新特性之Lambda
  12. Runner站立会议06
  13. Overpass Turbo下载OSM数据
  14. 【小白向教程】从零开始为你的手机安装Win11系统
  15. php百度网盘登录,php百度网盘同步_http200_mmdb
  16. c#Word模板转PDF,c#word模板生成新的word
  17. 三个问答告诉你aside标签的作用
  18. FPGA的学习:基于ROM的VGA图像显示(弹跳特效)
  19. Java生鲜电商平台-商品中心的架构设计与源码解析
  20. 人工智能物联网开发的目录

热门文章

  1. 程序员为什么多数秃头?看完这15个瞬间,终于懂了
  2. php处理头像,(头像处理)PHP把图片转换成圆形png
  3. excel 如何批量删除必表中的空白行
  4. 服务实例是否宕机的后台检查线程任务
  5. 计算机桌面比例怎么调,如何调整计算机显示器的比例
  6. SpringBoot静态资源处理(九)
  7. 安装打印机提示未能添加服务器,打印机未能链接到服务器
  8. IDEA 修改主题设置修改主题字体,编辑区字体
  9. 统计学中的有效性和可靠性的概念
  10. MFC API 设置Excel单元格格式