高级Linux运维工程师必备技能(扫盲篇)

                      高级Linux运维工程师必备技能(扫盲篇)

                                            作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

 

  在了解文件系统之前,我们要学习一下磁盘存储数据的方式,大家都知道文件从内存若要持久化存储的话就得把它存到硬盘上,想毕都知道文件存入磁盘都是二进制存取的。那么硬盘是如何存储的呢?我们现在标配基本上都是1T呢,现在都是2017了,500G的硬盘都已经遭嫌弃了。
                      
1.生活小知识。
  上面是一幅图可以看到,有磁头,而且这个磁头是悬浮在盘面上的,如果这个盘面有震动,很可能直接滑到盘面,导致上面写的数据被划掉,造成数据丢失,因此,我们在购买硬盘的时候都写着不能强剧烈震动。硬盘在工作的时候,这个盘面一直在转,如果访问里面的数据,需要一定时间,我们称之为“平均寻道时间”。把不同盘面上的相同磁道(可以理解就是盘面上的一个圈,整个盘面有好多个这个样的打圈小圈形成的)划分成同一个分区内部。那么这些维护不同盘面的相同编号的磁道我们成为柱面(cylinder).磁盘划分实际上是按照柱面划分的,那么很显然在最外层的柱面划分出来的分区的性能是最好的,你可能会问为什么?原因很简单,就是在相同的角速度中,最外层的周长是最大(也就意味着它存储的数据将越多)。因此我们在划分分区的时候依次划分C,D,E硬盘,最先划分的是C盘(分区软件默认把C盘划分到最外层),因此大家都用C盘做系统盘是有原因的哟!
 
2.MBR分区
在整块硬盘的最外侧磁道上,在第零("0")个扇区上,这个扇区是不能用来划分区的,因为这个扇区上存放着整块磁盘的分区信息。这个分区通常被称作为MBR(Master Boot Record,主引导记录 )分区(现在都流行GPT分区了),这个扇区仅仅占用了512个字节(bytes),你可别小看这512bytes,
a>.它保函了引导加载器(bootloader,其占用了446bytes);
b>.fat,即分区表,其占用了64bytes,每16bytes一个分区,总共只能分区4个[据说比尔盖茨层发表过言论:“硬盘这么小,有谁能用到多余4个分区呢?)【当时的硬盘都很小而且特别贵,只有几百兆(M)大小】”;
c>.5A,其为十六进制的“5A”,占用最后2个字节,用来标记这个MBR分区是否是有效数据的(2个字节被填充了2个5A,MBR有效性标记)。
硬盘内部都是真空的,为什么呢?因为它要旋转,有的硬盘的转速高达1.5w/m,如果不坐车真空的这么高的转速很容易和真空中的微粒发生碰撞,导致温度过高!所以不要轻易拆开硬盘,基本上你拆开就不是真空了,即使拆开后能用,也用不了多长时间就会坏掉的。
 
3.扩展分区与逻辑分区
随着硬盘的存储数据进一步的增长,我们分区4个是远远够用的,因此需要从4个主分区中拿出一个分区单独,用来存放其他的分区信息我们叫它为“扩展分区”,如果这个扩展分区足够大,就可以对其进行划分多个分区让不同用户使用。因此这个扩展分区(引用额外的分区表)是不能被格式化的,这样它就不能被使用,需要额外划分出一个或多个逻辑分区才能被使用。
 
4.MBR分区方法
a>.4个主分区
b>.3个主分区和一个扩展分区。
注意:MBR最大支持2T的硬盘。大于2TB就得使用GPT分区格式!
 
5.硬盘接口
DMA:Direct Memory Access (直接内存访问机制)
磁盘设备存放于/dev/文件夹下,
IDE接口的磁盘:/dev/hda、/dev/hdb、/dev/hdc、/dev/hdd
SCSI接口的磁盘:/dev/sda、/dev/sdb、/dev/sdc、/dev/sdd
/dev/XdYZ
/dev/ 表示的是一个设备目录
X h IDE硬盘
s SATA、SISC、U盘
Y a 第一块硬盘
b 第二块硬盘
c 第三块硬盘
。。。。。。。。。。
 
Z 1-3表示主分区,4一般为扩展分区
5是逻辑分区第一个分区
6是逻辑分区第二个分区
。。。。。。。。。。
a>.IDE(ATA):并口,每个控制器可接两个硬盘,master/slave,133MB/S(这个速率就是被淘汰的根部原因)
/dev/hd[a-z](注意:在Centos6.x版本以后,所有的硬盘即便是IDE接口的都被识别为sd,早起的设备被设置为hd)
/dev//hda[1-4](标识4个主分区)
/dev/hda[5+](逻辑分区5开始)
b>.SCSI:Small Computer System Interface (小型计算机接口,在读取数据上效率很高,因为它有单独的SCSI控制器,容错能力强且抗衰老【但是价格贵啊,相同存储空间是机械硬盘的8倍价格呢!】) 速率:320mb/s 也是并口的 (有的人为了省钱用IDE做raid阵列)
c>.SATA(Serial):300Mbps,600Mbps,6Gbps
d>.SAS:6Gbps
e>.USB:2.0接口: 3.0接口:

 

6.查看系统是如何识别磁盘分区的
 1 [root@yinzhengjie ~]# cat /proc/partitions  #查看系统识别的分区
 2 major minor  #blocks  name
 3 
 4    8        0  292968750 sda
 5    8       16  292968750 sdb
 6    9      127  278290432 md127
 7  259        0     512000 md127p1
 8  259        1  277777408 md127p2
 9  253        0   52428800 dm-0
10  253        1   33038336 dm-1
11  253        2  192307200 dm-2
12 [root@yinzhengjie ~]# 
  注意:如果你对你的硬盘剩余的空间进行分区后,新加的分区信息内核是不能识别的,需要内核去重读硬件的分区表,重启是不顶事的!我在生产环境中就遇到过这么一个坑。
 
7.根在内核
  根做为访问文件的入口,那么这个根到底在硬盘上呢?还是在操作系统上呢?根实际上是在内核中,我们访问数据都是操作系统将这个硬盘挂在到了根下,然后我们去访问它而已。那你又会问了,那内核在哪啊?答案是在磁盘上。
实际上,在装载内核之前,先启动的是bootloader(内核未启动就还没有文件系统存在),bootloader区磁盘上找到内核并启动,内核启动后会自动生成一个“/”(根),并将磁盘的文件都挂在到“/”下,这就形成了文件系统。
 
8.linux目录
 1 /bin,/sbin                         #存放系统自身完成自己的启动和基本运行机制索要提供的程序;。
 2 /usr/bin,/usr/sbin                  #存放完成操作系统基本功能的所提供的二进制程序;
 3 /usr/local/bin,/usr/local/sbin      #存放第三方程序;
 4 /lib,/lib64,/usr/lib,/usr/lib64     #存放库文件的;
 5 /etc/                             #存放配置文件的;
 6 /media,/mnt                      #用于挂在的目录,当然你也可以自定义的;
 7 /dev                             #存放各种设备文件;
 8 /proc,/sys                         #存放运行中的内存映射数据;
 9 /home,/root                      #存放各普通用户的家目录,比如 /home/yinzhengjie;
10 /var                               #存放日志的目录;
11 /opt,/misc                         #触发挂在目录;
12 /srv                             #存放服务相关数据的;
13 /tmp                             #存放各种临时文件,每次关机时自动清理;
14 /boot                           #存放内核、引导菜单等启动文件;
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 /:根目录,一般根目录下只存放目录,不要存放文件,/etc、/bin、/dev、/lib、/sbin应该和根目录放置在一个分区中
 9 
10 /bin:/usr/bin:可执行二进制文件的目录,如常用的命令ls、tar、mv、cat等。
11 
12 /boot:放置linux系统启动时用到的一些文件。/boot/vmlinuz为linux的内核文件,以及/boot/gurb。建议单独分区,分区大小200M即可
13 
14 /dev:存放linux系统下的设备文件,访问该目录下某个文件,相当于访问某个设备,常用的是挂载光驱mount /dev/cdrom /mnt。
15 
16 /etc:系统配置文件存放的目录,不建议在此目录下存放可执行文件,重要的配置文件有/etc/inittab、/etc/fstab、/etc/init.d、/etc/X11、/etc/sysconfig、/etc/xinetd.d修改配置文件之前记得备份。
17 
18 注:/etc/X11存放与x windows有关的设置。
19 
20 /home:系统默认的用户家目录,新增用户账号时,用户的家目录都存放在此目录下,~表示当前用户的家目录,~test表示用户test的家目录。建议单独分区,并设置较大的磁盘空间,方便用户存放数据
21 
22 /lib:/usr/lib:/usr/local/lib:系统使用的函数库的目录,程序在执行过程中,需要调用一些额外的参数时需要函数库的协助,比较重要的目录为/lib/modules。
23 
24 /lost+fount:系统异常产生错误时,会将一些遗失的片段放置于此目录下,通常这个目录会自动出现在装置目录下。如加载硬盘于/disk 中,此目录下就会自动产生目录/disk/lost+found
25 
26 /mnt:/media:光盘默认挂载点,通常光盘挂载于/mnt/cdrom下,也不一定,可以选择任意位置进行挂载。
27 
28 /opt:给主机额外安装软件所摆放的目录。如:FC4使用的Fedora 社群开发软件,如果想要自行安装新的KDE 桌面软件,可以将该软件安装在该目录下。以前的 Linux 系统中,习惯放置在 /usr/local 目录下
29 
30 /proc:此目录的数据都在内存中,如系统核心,外部设备,网络状态,由于数据都存放于内存中,所以不占用磁盘空间,比较重要的目录有/proc/cpuinfo、/proc/interrupts、/proc/dma、/proc/ioports、/proc/net/*等
31 
32 /root:系统管理员root的家目录,系统第一个启动的分区为/,所以最好将/root和/放置在一个分区下。
33 
34 /sbin:/usr/sbin:/usr/local/sbin:放置系统管理员使用的可执行命令,如fdisk、shutdown、mount等。与/bin不同的是,这几个目录是给系统管理员root使用的命令,一般用户只能"查看"而不能设置和使用。
35 
36 /tmp:一般用户或正在执行的程序临时存放文件的目录,任何人都可以访问,重要数据不可放置在此目录下
37 
38 /srv:服务启动之后需要访问的数据目录,如www服务需要访问的网页数据存放在/srv/www内
39 
40 /usr:应用程序存放目录,/usr/bin存放应用程序,/usr/share存放共享数据,/usr/lib存放不能直接运行的,却是许多程序运行所必需的一些函数库文件。/usr/local:存放软件升级包。/usr/share/doc:系统说明文件存放目录。/usr/share/man: 程序说明文件存放目录,使用 man ls时会查询/usr/share/man/man1/ls.1.gz的内容建议单独分区,设置较大的磁盘空间
41 
42 /var:放置系统执行过程中经常变化的文件,如随时更改的日志文件/var/log,/var/log/message:所有的登录文件存放目录,/var/spool/mail:邮件存放的目录,/var/run:程序或服务启动后,其PID存放在该目录下。建议单独分区,设置较大的磁盘空间
43 '''
Linux目录详细版本,猛戳这里!!
 
9.用来对设备进行分区的命令
用于分区的管理工具:fdisk,sfdisk,parted
a>.查看分区信息
 1 [root@yinzhengjie ~]# fdisk -l /dev/[sh]d[a-z]  #使用文件名通配过滤掉没有用的信息(不是正则表达式哟),可以看出下面只有2个硬盘
 2 
 3 Disk /dev/sda: 21.5 GB, 21474836480 bytes
 4 255 heads, 63 sectors/track, 2610 cylinders
 5 Units = cylinders of 16065 * 512 = 8225280 bytes
 6 Sector size (logical/physical): 512 bytes / 512 bytes
 7 I/O size (minimum/optimal): 512 bytes / 512 bytes
 8 Disk identifier: 0x00059922
 9 
10    Device Boot(是否可引导)      Start         End      Blocks   Id(对应文件系统的ID)  System
11 /dev/sda1   *(*表示可以引导)           1          39      307200   83  Linux
12 Partition 1 does not end on cylinder boundary.
13 /dev/sda2              39        2358    18631680   83  Linux
14 /dev/sda3            2358        2611     2031616   82  Linux swap / Solaris
15 
16 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
17 255 heads, 63 sectors/track, 1305 cylinders
18 Units = cylinders of 16065 * 512 = 8225280 bytes
19 Sector size (logical/physical): 512 bytes / 512 bytes
20 I/O size (minimum/optimal): 512 bytes / 512 bytes
21 Disk identifier: 0x00000000
22 
23 [root@yinzhengjie ~]# 
b>虚拟文件系统
              
 
VFS:(Virtual File System)#虚拟文件系统
基本文件系统:Ext3,Ext3,Ext4,Reiserfs(早起的suse用的就是该文件系统哟),xfs(支持单个巨大的文件),JFS(日志文件系统,IBM开发的),vfat,NTFS
交换分区:swap
集群文件系统:GFS2(红帽系统研发,谷歌都再用呢),OCFS2(甲骨文公司研发,用的人不多)
网络文件系统:NFS,smbfs(window是CIFS)
光盘:iso9660
c>.对磁盘进行分区
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 fdisk:
 9     d 删除分区
10     n:新建一个分区
11     p:列出已有分区
12     t:调至分区ID
13     l:列出内核支持的分区id
14     w:保存退出
15     q:不保存退出 
16     m:帮助
17 '''
  1 #!/usr/bin/env python
  2 #_*_coding:utf-8_*_
  3 #@author :yinzhengjie
  4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
  5 #EMAIL:y1053419035@qq.com
  6 
  7 '''
  8 [root@yinzhengjie ~]# fdisk /dev/sdb  #对第二块硬盘进行分区
  9 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
 10 Building a new DOS disklabel with disk identifier 0x8614a108.
 11 Changes will remain in memory only, until you decide to write them.
 12 After that, of course, the previous content won't be recoverable.
 13 
 14 Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 15 
 16 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
 17          switch off the mode (command 'c') and change display units to
 18          sectors (command 'u').
 19 
 20 Command (m for help): m  #查看帮助
 21 Command action
 22    a   toggle a bootable flag
 23    b   edit bsd disklabel
 24    c   toggle the dos compatibility flag
 25    d   delete a partition
 26    l   list known partition types
 27    m   print this menu
 28    n   add a new partition
 29    o   create a new empty DOS partition table
 30    p   print the partition table
 31    q   quit without saving changes
 32    s   create a new empty Sun disklabel
 33    t   change a partition's system id
 34    u   change display/entry units
 35    v   verify the partition table
 36    w   write table to disk and exit
 37    x   extra functionality (experts only)
 38 
 39 Command (m for help): p  #列出已有分区
 40 
 41 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 42 255 heads, 63 sectors/track, 1305 cylinders
 43 Units = cylinders of 16065 * 512 = 8225280 bytes
 44 Sector size (logical/physical): 512 bytes / 512 bytes
 45 I/O size (minimum/optimal): 512 bytes / 512 bytes
 46 Disk identifier: 0x8614a108
 47 
 48    Device Boot      Start         End      Blocks   Id  System
 49 
 50 Command (m for help): n   #新建一个分区
 51 Command action
 52    e   extended   #扩展分区
 53    p   primary partition (1-4)  #主分区
 54 p  #选择主分区
 55 Partition number (1-4): 1  #选择编号
 56 First cylinder (1-1305, default 1):  #选择分区的起始点,默认为1
 57 Using default value 1
 58 Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): +1G  #创建一个1G的主分区
 59 
 60 Command (m for help): n  #再新建一个分区
 61 Command action
 62    e   extended
 63    p   primary partition (1-4)
 64 p   #选择类型为主分区
 65 Partition number (1-4): 2  #设置编号为2
 66 First cylinder (133-1305, default 133):
 67 Using default value 133
 68 Last cylinder, +cylinders or +size{K,M,G} (133-1305, default 1305): +1G  #创建一个1G的分区
 69 
 70 Command (m for help): n   #再新建一个分区
 71 Command action
 72    e   extended
 73    p   primary partition (1-4)
 74 p #选择类型为主分区
 75 Partition number (1-4): 3  #这只编号为3
 76 First cylinder (265-1305, default 265):
 77 Using default value 265
 78 Last cylinder, +cylinders or +size{K,M,G} (265-1305, default 1305): +2G  #创建一个2G的分区
 79 
 80 Command (m for help): n  #再新建一个分区
 81 Command action
 82    e   extended
 83    p   primary partition (1-4)
 84 e  #由于已经设置了3个主分区了,所以我将第四个分区设置为扩展分区,便于我创建更多的逻辑分区
 85 Selected partition 4
 86 First cylinder (527-1305, default 527):
 87 Using default value 527
 88 Last cylinder, +cylinders or +size{K,M,G} (527-1305, default 1305):
 89 Using default value 1305
 90 
 91 Command (m for help): p  #列出已有分区
 92 
 93 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 94 255 heads, 63 sectors/track, 1305 cylinders
 95 Units = cylinders of 16065 * 512 = 8225280 bytes
 96 Sector size (logical/physical): 512 bytes / 512 bytes
 97 I/O size (minimum/optimal): 512 bytes / 512 bytes
 98 Disk identifier: 0x8614a108
 99 
100    Device Boot      Start         End      Blocks   Id  System
101 /dev/sdb1               1         132     1060258+  83  Linux   #这就是主分区,ID为83
102 /dev/sdb2             133         264     1060290   83  Linux
103 /dev/sdb3             265         526     2104515   83  Linux
104 /dev/sdb4             527        1305     6257317+   5  Extended  #折就是扩展分区,ID为5
105 
106 Command (m for help): n  #新建一个分区
107 First cylinder (527-1305, default 527):
108 Using default value 527
109 Last cylinder, +cylinders or +size{K,M,G} (527-1305, default 1305): +5G  #创建一个5G的逻辑分区。
110 
111 Command (m for help): P   #列出已有分区
112 
113 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
114 255 heads, 63 sectors/track, 1305 cylinders
115 Units = cylinders of 16065 * 512 = 8225280 bytes
116 Sector size (logical/physical): 512 bytes / 512 bytes
117 I/O size (minimum/optimal): 512 bytes / 512 bytes
118 Disk identifier: 0x8614a108
119 
120    Device Boot      Start         End      Blocks   Id  System
121 /dev/sdb1               1         132     1060258+  83  Linux   #主分区
122 /dev/sdb2             133         264     1060290   83  Linux
123 /dev/sdb3             265         526     2104515   83  Linux
124 /dev/sdb4             527        1305     6257317+   5  Extended  #扩展分区
125 /dev/sdb5             527        1180     5253223+  83  Linux   #这就是新建的逻辑分区
126 
127 Command (m for help): W  #保存退出
128 
129 验证是否分区成功:
130 [root@yinzhengjie ~]# fdisk /dev/sdb
131 
132 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
133          switch off the mode (command 'c') and change display units to
134          sectors (command 'u').
135 
136 Command (m for help): p
137 
138 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
139 255 heads, 63 sectors/track, 1305 cylinders
140 Units = cylinders of 16065 * 512 = 8225280 bytes
141 Sector size (logical/physical): 512 bytes / 512 bytes
142 I/O size (minimum/optimal): 512 bytes / 512 bytes
143 Disk identifier: 0x8614a108
144 
145    Device Boot      Start         End      Blocks   Id  System
146 /dev/sdb1               1         132     1060258+  83  Linux
147 /dev/sdb2             133         264     1060290   83  Linux
148 /dev/sdb3             265         526     2104515   83  Linux
149 /dev/sdb4             527        1305     6257317+   5  Extended
150 /dev/sdb5             527        1180     5253223+  83  Linux
151 
152 Command (m for help): q
153 
154 [root@yinzhengjie ~]#
155 '''
用fdisk 工具对磁盘进行分区过程
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 #让操作系统重读分区表,获取最新的分区信息。
 8 '''
 9 [root@yinzhengjie ~]# cat /proc/partitions  #查看系统识别的分区,发现没有我们的分区
10 major minor  #blocks  name
11 
12    8        0  292968750 sda
13    8       16  292968750 sdb
14    9      127  278290432 md127
15  259        0     512000 md127p1
16  259        1  277777408 md127p2
17  253        0   52428800 dm-0
18  253        1   33038336 dm-1
19  253        2  192307200 dm-2
20 [root@yinzhengjie ~]#
21 [root@yinzhengjie ~]# kpartx -l /dev/sdb  #列出已添加的所有分区信息
22 sdb1 : 0 2120517 /dev/sdb 63
23 sdb2 : 0 2120580 /dev/sdb 2120580
24 sdb3 : 0 4209030 /dev/sdb 4241160
25 sdb4 : 0 2 /dev/sdb 8450190
26 sdb5 : 0 10506447 /dev/sdb 8450253
27 [root@yinzhengjie ~]# kpartx -af /dev/sdb   #强行添加分区信息
28 [root@yinzhengjie ~]# kpartx -a /dev/sdb    #重读分区表信息
29 [root@yinzhengjie ~]#
30 [root@yinzhengjie ~]# ls /dev/sdb*          #发现系统以及识别了这几个分区
31 /dev/sdb  /dev/sdb1  /dev/sdb2  /dev/sdb3  /dev/sdb4  /dev/sdb5
32 [root@yinzhengjie ~]#
33 [root@yinzhengjie ~]# cat /proc/partitions  #查看分区表
34 major minor  #blocks  name
35 
36    8        0   20971520 sda
37    8        1     307200 sda1
38    8        2   18631680 sda2
39    8        3    2031616 sda3
40    8       16   10485760 sdb
41    8       17    1060258 sdb1
42    8       18    1060290 sdb2
43    8       19    2104515 sdb3
44    8       20          1 sdb4
45    8       21    5253223 sdb5
46  253        0    1060258 dm-0
47  253        1    1060290 dm-1
48  253        2    2104515 dm-2
49  253        3          1 dm-3
50  253        4    5253223 dm-4
51 [root@yinzhengjie ~]#
52 
53 '''
54 
55 
56 #提示,如果你的操作系统是Centos5的话执行以下命令就好使了
57 [root@yinzhengjie ~]# partprobe   #但是这个条命令不适合CentOs6!
用kpartx 让系统重读分区表
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# fdisk /dev/sdb
 9 
10 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
11          switch off the mode (command 'c') and change display units to
12          sectors (command 'u').
13 
14 Command (m for help): p  #查看当前分区
15 
16 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
17 255 heads, 63 sectors/track, 1305 cylinders
18 Units = cylinders of 16065 * 512 = 8225280 bytes
19 Sector size (logical/physical): 512 bytes / 512 bytes
20 I/O size (minimum/optimal): 512 bytes / 512 bytes
21 Disk identifier: 0x8614a108
22 
23    Device Boot      Start         End      Blocks   Id  System
24 /dev/sdb1               1         132     1060258+  83  Linux
25 /dev/sdb2             133         264     1060290   83  Linux
26 /dev/sdb3             265         526     2104515   83  Linux
27 /dev/sdb4             527        1305     6257317+   5  Extended
28 /dev/sdb5             527        1180     5253223+  83  Linux
29 
30 Command (m for help): d  #删除分区
31 Partition number (1-5): 5  #选择相应的编号,在她给定的数值内选取哟
32 
33 Command (m for help): p #发现已经删除成功了
34 
35 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
36 255 heads, 63 sectors/track, 1305 cylinders
37 Units = cylinders of 16065 * 512 = 8225280 bytes
38 Sector size (logical/physical): 512 bytes / 512 bytes
39 I/O size (minimum/optimal): 512 bytes / 512 bytes
40 Disk identifier: 0x8614a108
41 
42    Device Boot      Start         End      Blocks   Id  System
43 /dev/sdb1               1         132     1060258+  83  Linux
44 /dev/sdb2             133         264     1060290   83  Linux
45 /dev/sdb3             265         526     2104515   83  Linux
46 /dev/sdb4             527        1305     6257317+   5  Extended
47 
48 Command (m for help): w   #保存配置并退出
49 The partition table has been altered!
50 
51 Calling ioctl() to re-read partition table.
52 Syncing disks.
53 [root@yinzhengjie ~]#
54 
55 
56 '''
用fdisk删除分区信息
  1 #!/usr/bin/env python
  2 #_*_coding:utf-8_*_
  3 #@author :yinzhengjie
  4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
  5 #EMAIL:y1053419035@qq.com
  6 
  7 '''
  8 [root@yinzhengjie ~]# fdisk /dev/sdb
  9 
 10 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
 11          switch off the mode (command 'c') and change display units to
 12          sectors (command 'u').
 13 
 14 Command (m for help): p #查看当前分区信息
 15 
 16 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 17 255 heads, 63 sectors/track, 1305 cylinders
 18 Units = cylinders of 16065 * 512 = 8225280 bytes
 19 Sector size (logical/physical): 512 bytes / 512 bytes
 20 I/O size (minimum/optimal): 512 bytes / 512 bytes
 21 Disk identifier: 0x8614a108
 22 
 23    Device Boot      Start         End      Blocks   Id  System
 24 /dev/sdb1               1         132     1060258+  83  Linux
 25 /dev/sdb2             133         264     1060290   83  Linux
 26 /dev/sdb3             265         526     2104515   83  Linux   #主分区
 27 /dev/sdb4             527        1305     6257317+   5  Extended
 28 
 29 Command (m for help): t  #调整分区ID
 30 Partition number (1-5): 3  #选择分区标号
 31 Hex code (type L to list codes): L  #查看ID对应的文件系统类型。
 32 
 33  0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 34  1  FAT12           39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-
 35  2  XENIX root      3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
 36  3  XENIX usr       40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 37  4  FAT16 <32M      41  PPC PReP Boot   85  Linux extended  c7  Syrinx
 38  5  Extended        42  SFS             86  NTFS volume set da  Non-FS data
 39  6  FAT16           4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .
 40  7  HPFS/NTFS       4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility
 41  8  AIX             4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt
 42  9  AIX bootable    50  OnTrack DM      93  Amoeba          e1  DOS access
 43  a  OS/2 Boot Manag 51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O
 44  b  W95 FAT32       52  CP/M            9f  BSD/OS          e4  SpeedStor
 45  c  W95 FAT32 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs
 46  e  W95 FAT16 (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  GPT
 47  f  W95 Ext'd (LBA) 55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
 48 10  OPUS            56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
 49 11  Hidden FAT12    5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor
 50 12  Compaq diagnost 61  SpeedStor       a9  NetBSD          f4  SpeedStor
 51 14  Hidden FAT16 <3 63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary
 52 16  Hidden FAT16    64  Novell Netware  af  HFS / HFS+      fb  VMware VMFS
 53 17  Hidden HPFS/NTF 65  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
 54 18  AST SmartSleep  70  DiskSecure Mult b8  BSDI swap       fd  Linux raid auto
 55 1b  Hidden W95 FAT3 75  PC/IX           bb  Boot Wizard hid fe  LANstep
 56 1c  Hidden W95 FAT3 80  Old Minix       be  Solaris boot    ff  BBT
 57 1e  Hidden W95 FAT1
 58 Hex code (type L to list codes): 82  #选择 Linux swap / So分区类型
 59 Changed system type of partition 3 to 82 (Linux swap / Solaris)
 60 
 61 Command (m for help): P #查看当前类型
 62 
 63 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 64 255 heads, 63 sectors/track, 1305 cylinders
 65 Units = cylinders of 16065 * 512 = 8225280 bytes
 66 Sector size (logical/physical): 512 bytes / 512 bytes
 67 I/O size (minimum/optimal): 512 bytes / 512 bytes
 68 Disk identifier: 0x8614a108
 69 
 70    Device Boot      Start         End      Blocks   Id  System
 71 /dev/sdb1               1         132     1060258+  83  Linux
 72 /dev/sdb2             133         264     1060290   83  Linux
 73 /dev/sdb3             265         526     2104515   82  Linux swap / Solaris  #果真已经变成了交换分区
 74 /dev/sdb4             527        1305     6257317+   5  Extended
 75 
 76 Command (m for help): t  #修改分区类型
 77 Partition number (1-5): 3  #还是选择之前修改的分区
 78 Hex code (type L to list codes): 83  #修改会之前的分区类型
 79 Changed system type of partition 3 to 83 (Linux)
 80 
 81 Command (m for help): p  #查看分区情况
 82 
 83 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 84 255 heads, 63 sectors/track, 1305 cylinders
 85 Units = cylinders of 16065 * 512 = 8225280 bytes
 86 Sector size (logical/physical): 512 bytes / 512 bytes
 87 I/O size (minimum/optimal): 512 bytes / 512 bytes
 88 Disk identifier: 0x8614a108
 89 
 90    Device Boot      Start         End      Blocks   Id  System
 91 /dev/sdb1               1         132     1060258+  83  Linux
 92 /dev/sdb2             133         264     1060290   83  Linux
 93 /dev/sdb3             265         526     2104515   83  Linux
 94 /dev/sdb4             527        1305     6257317+   5  Extended
 95 
 96 Command (m for help): w  #保存当前配置
 97 The partition table has been altered!
 98 
 99 Calling ioctl() to re-read partition table.
100 Syncing disks.
101 [root@yinzhengjie ~]#
102 '''
用fdisk修改分区类型
 
10.创建文件系统
                        

 

  你可以使用2个扇区(512字节)为一个块(block),那么这个一个快的大小就是1kb,4个扇区就是2kb,8个扇区就是4kb.那么问题来了,这个每个单位的块导师是1kb好呢?还是2kb或是4kb好呢?这就要看你存储的数据的大小了,如果你存储的数据是大文件的话,当然block越大越好,这样block存储相同的数据block越大,用的块数就越少,如果你存储的是小文件的话,当然block越小越好,因为block过大,存进去的数据却很小就造成了浪费!(因为一个block只能存储一个数据源)。
  注意,在存储数据的时候,一个block只能属于一个文件,不能同时属于2个文件。硬连接除外,其实硬链接指的还是一同一个文件。也就是说,不同的文件不能使用相同的磁盘块。这些磁盘块都有其编号的,是为了方便数据源(主要是inode)只想存储数据的块(block)
  磁盘碎片,就是不是连续的块(block)存储着属于同一个文件的数据,这样就导致了在存取的时候特别麻烦,大大的降低了磁盘的工作效率。如下图:
                            

 

  日志文件系统是可以将源数据(indoe)和块数据都写入日志区,等都写入成功了在把数据分别写入到源数据区和块数据区,假如你才写文档的时候,如果突然断电,恰巧你刚刚好写完数据,那么他回将数据分别写入indoe和block区域中,如果你没有写完,他就会对比在日志区的inode和block对应的是否完整,如果不完整,日志区会自动将Inode删除,清除掉不完整的block,就完成了一次自检模式。
                              
#!/usr/bin/env python
#_*_coding:utf-8_*_
#@author :yinzhengjie
#blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
#EMAIL:y1053419035@qq.com

'''

mke2fs:
   配置文件:/etc/mke2fs.conf
   -t:指定文件类型{ext2|ext3|ext4}
   -j:用于创建Ext3文件系统,相当于-t ext3
   -L label: 指定卷标,
   -b{1024|2028|4096}:指定块大小
   -i # :#个字节给指定一个indone
   -N # : 直接指定预留多少个indone
   -I # : 指定Inode大小
   -m # :预留给管理员的空间百分比,默认为5
   -O :指定分区特性
e2label /dev/SOMEDEVICE 查看卷标,

e2label /dev/SOMEDEVICE  Label 直接更改卷标

e2label /dev/SOMEDEVICE “”   删除卷标

blkid 查看UUID和TYPE 

dumpe2fs 查看超级块和是否有碎片 
    -h:仅显示超级块中保存的信息 


tune2fs:调整mke2fs的信息 
     -l:查看超级块中的信息 
    -L: 设定卷标 
    -m:预留管理员的空间百分比 
     -j:如果原来的文件系统为ext2,-j能够将其提升为ext3 
     -o:[^]mount-options[,...] 指定默认挂载选项 
     -O:[^]feature[,...] 调整分区特性 
    tune2fs -o 挂载选项 设备 
    tune2fs -o ^设备选项 取消 


fsck:文件系统检测 
      -t 文件类型 设备 
      -f 强行检测 
      -a 自动修复错误 
      -r 交互式修复错误
      
e2fsck 
      -t 指定时间 
      -y 自动回答为yes 
      -f 强行检测 
'
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mke2fs /dev/sdb3   #格式化该分区,默认为ext2文件系统
 9 mke2fs 1.41.12 (17-May-2010)
10 Filesystem label=     #卷标
11 OS type: Linux
12 Block size=4096 (log=2)  #块大小是4K
13 Fragment size=4096 (log=2)
14 Stride=0 blocks, Stripe width=0 blocks
15 131648 inodes, 526128 blocks  #节点书和块数。
16 26306 blocks (5.00%) reserved for the super user   #有5.00%的block给管理用,这个比例是可以调整的
17 First data block=0
18 Maximum filesystem blocks=541065216   #最大块数
19 17 block groups  #有17个块组
20 32768 blocks per group, 32768 fragments per group    #
21 7744 inodes per group
22 Superblock backups stored on blocks:
23         32768, 98304, 163840, 229376, 294912
24 
25 Writing inode tables: done
26 Writing superblocks and filesystem accounting information: done
27 
28 This filesystem will be automatically checked every 39 mounts or
29 180 days, whichever comes first.  Use tune2fs -c or -i to override    #表示每39次挂载或者180天(半年)文件系统会自动检测一次。.
30 [root@yinzhengjie ~]#
31 [root@yinzhengjie ~]#
32 [root@yinzhengjie ~]# mke2fs -j /dev/sdb3  #格式化该分区,指定格式为ext3文件系统
33 mke2fs 1.41.12 (17-May-2010)
34 Filesystem label=
35 OS type: Linux
36 Block size=4096 (log=2)
37 Fragment size=4096 (log=2)
38 Stride=0 blocks, Stripe width=0 blocks
39 131648 inodes, 526128 blocks
40 26306 blocks (5.00%) reserved for the super user
41 First data block=0
42 Maximum filesystem blocks=541065216
43 17 block groups
44 32768 blocks per group, 32768 fragments per group
45 7744 inodes per group
46 Superblock backups stored on blocks:
47         32768, 98304, 163840, 229376, 294912
48 
49 Writing inode tables: done
50 Creating journal (16384 blocks): done   #与ext2相比多出来的项目,存放日志的区域。
51 Writing superblocks and filesystem accounting information: done
52 
53 This filesystem will be automatically checked every 38 mounts or
54 180 days, whichever comes first.  Use tune2fs -c or -i to override.  #这里的是38次挂载或者6个月进行一次挂载,和ext2的区别。
55 [root@yinzhengjie ~]# 
56 '''
用mke2fs的-j参数格式化分区
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mke2fs -L Data -t ext4 /dev/sdb3  #指定卷标和文件系统格式
 9 mke2fs 1.41.12 (17-May-2010)
10 Filesystem label=Data  #这就是卷标
11 OS type: Linux
12 Block size=4096 (log=2)
13 Fragment size=4096 (log=2)
14 Stride=0 blocks, Stripe width=0 blocks
15 131648 inodes, 526128 blocks
16 26306 blocks (5.00%) reserved for the super user
17 First data block=0
18 Maximum filesystem blocks=541065216
19 17 block groups
20 32768 blocks per group, 32768 fragments per group
21 7744 inodes per group
22 Superblock backups stored on blocks: 
23         32768, 98304, 163840, 229376, 294912
24 
25 Writing inode tables: done                            
26 Creating journal (16384 blocks): done
27 Writing superblocks and filesystem accounting information: done
28 
29 This filesystem will be automatically checked every 38 mounts or
30 180 days, whichever comes first.  Use tune2fs -c or -i to override.
31 [root@yinzhengjie ~]# 
32 '''
用mke2fs的-L用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# e2label /dev/sdb3   #查看卷标名
 9 Data
10 [root@yinzhengjie ~]# e2label /dev/sdb3  MYDATA  #修改卷标名
11 [root@yinzhengjie ~]# e2label /dev/sdb3
12 MYDATA
13 [root@yinzhengjie ~]# 
14 '''
用e2label查看或修改卷标名
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mke2fs -b 2048 -m 3 -t ext4 /dev/sdb3
 9 mke2fs 1.41.12 (17-May-2010)
10 Filesystem label=
11 OS type: Linux
12 Block size=2048 (log=1)  #被修改的块大小为2048
13 Fragment size=2048 (log=1)  
14 Stride=0 blocks, Stripe width=0 blocks
15 131560 inodes, 1052256 blocks
16 31567 blocks (3.00%) reserved for the super user   #给管理员预留的block,这个就是通过上面的“-m”参数实现的。
17 First data block=0
18 Maximum filesystem blocks=538968064
19 65 block groups
20 16384 blocks per group, 16384 fragments per group
21 2024 inodes per group
22 Superblock backups stored on blocks:
23         16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
24 
25 Writing inode tables: done
26 Creating journal (32768 blocks): done
27 Writing superblocks and filesystem accounting information: done
28 
29 This filesystem will be automatically checked every 29 mounts or
30 180 days, whichever comes first.  Use tune2fs -c or -i to override.
31 [root@yinzhengjie ~]#
32 '''
mke2fs的-b与-m参数的用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# blkid /dev/sdb3   #查看分区的UUID和TYPE,我们可以用uuid来进行挂载
 9 /dev/sdb3: UUID="87f7686e-09bd-4a1e-a567-4939c6a4dcab" TYPE="ext4"
10 [root@yinzhengjie ~]#
11 '''
blkid 查看UUID和TYPE
  1 #!/usr/bin/env python
  2 #_*_coding:utf-8_*_
  3 #@author :yinzhengjie
  4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
  5 #EMAIL:y1053419035@qq.com
  6 
  7 '''
  8 [root@yinzhengjie ~]# dumpe2fs /dev/sdb3  
  9 dumpe2fs 1.41.12 (17-May-2010)
 10 Filesystem volume name:   <none>
 11 Last mounted on:          <not available>
 12 Filesystem UUID:          87f7686e-09bd-4a1e-a567-4939c6a4dcab
 13 Filesystem magic number:  0xEF53
 14 Filesystem revision #:    1 (dynamic)
 15 Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
 16 Filesystem flags:         signed_directory_hash
 17 Default mount options:    (none)
 18 Filesystem state:         clean
 19 Errors behavior:          Continue
 20 Filesystem OS type:       Linux
 21 Inode count:              131560
 22 Block count:              1052256
 23 Reserved block count:     31567
 24 Free blocks:              998268
 25 Free inodes:              131549
 26 First block:              0
 27 Block size:               2048
 28 Fragment size:            2048
 29 Reserved GDT blocks:      512
 30 Blocks per group:         16384
 31 Fragments per group:      16384
 32 Inodes per group:         2024
 33 Inode blocks per group:   253
 34 Flex block group size:    16
 35 Filesystem created:       Thu May 11 12:42:49 2017
 36 Last mount time:          n/a
 37 Last write time:          Thu May 11 12:42:49 2017
 38 Mount count:              0
 39 Maximum mount count:      29
 40 Last checked:             Thu May 11 12:42:49 2017
 41 Check interval:           15552000 (6 months)
 42 Next check after:         Tue Nov  7 11:42:49 2017
 43 Lifetime writes:          97 MB
 44 Reserved blocks uid:      0 (user root)
 45 Reserved blocks gid:      0 (group root)
 46 First inode:              11
 47 Inode size:               256
 48 Required extra isize:     28
 49 Desired extra isize:      28
 50 Journal inode:            8
 51 Default directory hash:   half_md4
 52 Directory Hash Seed:      ff3c9e24-63aa-462a-9d6d-863f99c556d0
 53 Journal backup:           inode blocks
 54 Journal features:         (none)
 55 Journal size:             64M
 56 Journal length:           32768
 57 Journal sequence:         0x00000001
 58 Journal start:            0
 59 
 60 
 61 Group 0: (Blocks 0-16383) [ITABLE_ZEROED]  #显示组名,存储数据的block编号,如果你的Bolck和上个组没有连接上就说明存在磁盘碎片
 62   Checksum 0x8fce, unused inodes 2013  #没有用的inode有多少个
 63   Primary superblock at 0, Group descriptors at 1-2
 64   Reserved GDT blocks at 3-514
 65   Block bitmap at 515 (+515), Inode bitmap at 531 (+531)
 66   Inode table at 547-799 (+547)
 67   11779 free blocks, 2013 free inodes, 2 directories, 2013 unused inodes
 68   Free blocks: 4605-16383
 69   Free inodes: 12-2024
 70 Group 1: (Blocks 16384-32767) [INODE_UNINIT, ITABLE_ZEROED]
 71   Checksum 0xd2d4, unused inodes 2024
 72   Backup superblock at 16384, Group descriptors at 16385-16386
 73   Reserved GDT blocks at 16387-16898
 74   Block bitmap at 516 (+4294951428), Inode bitmap at 532 (+4294951444)
 75   Inode table at 800-1052 (+4294951712)
 76   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
 77   Free blocks: 16899-32767
 78   Free inodes: 2025-4048
 79 Group 2: (Blocks 32768-49151) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
 80   Checksum 0x209d, unused inodes 2024
 81   Block bitmap at 517 (+4294935045), Inode bitmap at 533 (+4294935061)
 82   Inode table at 1053-1305 (+4294935581)
 83   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
 84   Free blocks: 32768-49151
 85   Free inodes: 4049-6072
 86 Group 3: (Blocks 49152-65535) [INODE_UNINIT, ITABLE_ZEROED]
 87   Checksum 0x595b, unused inodes 2024
 88   Backup superblock at 49152, Group descriptors at 49153-49154
 89   Reserved GDT blocks at 49155-49666
 90   Block bitmap at 518 (+4294918662), Inode bitmap at 534 (+4294918678)
 91   Inode table at 1306-1558 (+4294919450)
 92   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
 93   Free blocks: 49667-65535
 94   Free inodes: 6073-8096
 95 Group 4: (Blocks 65536-81919) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
 96   Checksum 0x4c65, unused inodes 2024
 97   Block bitmap at 519 (+4294902279), Inode bitmap at 535 (+4294902295)
 98   Inode table at 1559-1811 (+4294903319)
 99   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
100   Free blocks: 65536-81919
101   Free inodes: 8097-10120
102 Group 5: (Blocks 81920-98303) [INODE_UNINIT, ITABLE_ZEROED]
103   Checksum 0x86c0, unused inodes 2024
104   Backup superblock at 81920, Group descriptors at 81921-81922
105   Reserved GDT blocks at 81923-82434
106   Block bitmap at 520 (+4294885896), Inode bitmap at 536 (+4294885912)
107   Inode table at 1812-2064 (+4294887188)
108   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
109   Free blocks: 82435-98303
110   Free inodes: 10121-12144
111 Group 6: (Blocks 98304-114687) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
112   Checksum 0x8dba, unused inodes 2024
113   Block bitmap at 521 (+4294869513), Inode bitmap at 537 (+4294869529)
114   Inode table at 2065-2317 (+4294871057)
115   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
116   Free blocks: 98304-114687
117   Free inodes: 12145-14168
118 Group 7: (Blocks 114688-131071) [INODE_UNINIT, ITABLE_ZEROED]
119   Checksum 0x5fe4, unused inodes 2024
120   Backup superblock at 114688, Group descriptors at 114689-114690
121   Reserved GDT blocks at 114691-115202
122   Block bitmap at 522 (+4294853130), Inode bitmap at 538 (+4294853146)
123   Inode table at 2318-2570 (+4294854926)
124   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
125   Free blocks: 115203-131071
126   Free inodes: 14169-16192
127 Group 8: (Blocks 131072-147455) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
128   Checksum 0x0451, unused inodes 2024
129   Block bitmap at 523 (+4294836747), Inode bitmap at 539 (+4294836763)
130   Inode table at 2571-2823 (+4294838795)
131   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
132   Free blocks: 131072-147455
133   Free inodes: 16193-18216
134 Group 9: (Blocks 147456-163839) [INODE_UNINIT, ITABLE_ZEROED]
135   Checksum 0xb130, unused inodes 2024
136   Backup superblock at 147456, Group descriptors at 147457-147458
137   Reserved GDT blocks at 147459-147970
138   Block bitmap at 524 (+4294820364), Inode bitmap at 540 (+4294820380)
139   Inode table at 2824-3076 (+4294822664)
140   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
141   Free blocks: 147971-163839
142   Free inodes: 18217-20240
143 Group 10: (Blocks 163840-180223) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
144   Checksum 0x544a, unused inodes 2024
145   Block bitmap at 525 (+4294803981), Inode bitmap at 541 (+4294803997)
146   Inode table at 3077-3329 (+4294806533)
147   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
148   Free blocks: 163840-180223
149   Free inodes: 20241-22264
150 Group 11: (Blocks 180224-196607) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
151   Checksum 0x3e65, unused inodes 2024
152   Block bitmap at 526 (+4294787598), Inode bitmap at 542 (+4294787614)
153   Inode table at 3330-3582 (+4294790402)
154   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
155   Free blocks: 180224-196607
156   Free inodes: 22265-24288
157 Group 12: (Blocks 196608-212991) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
158   Checksum 0x407e, unused inodes 2024
159   Block bitmap at 527 (+4294771215), Inode bitmap at 543 (+4294771231)
160   Inode table at 3583-3835 (+4294774271)
161   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
162   Free blocks: 196608-212991
163   Free inodes: 24289-26312
164 Group 13: (Blocks 212992-229375) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
165   Checksum 0x3bb2, unused inodes 2024
166   Block bitmap at 528 (+4294754832), Inode bitmap at 544 (+4294754848)
167   Inode table at 3836-4088 (+4294758140)
168   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
169   Free blocks: 212992-229375
170   Free inodes: 26313-28336
171 Group 14: (Blocks 229376-245759) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
172   Checksum 0x0dce, unused inodes 2024
173   Block bitmap at 529 (+4294738449), Inode bitmap at 545 (+4294738465)
174   Inode table at 4089-4341 (+4294742009)
175   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
176   Free blocks: 229376-245759
177   Free inodes: 28337-30360
178 Group 15: (Blocks 245760-262143) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
179   Checksum 0x7e95, unused inodes 2024
180   Block bitmap at 530 (+4294722066), Inode bitmap at 546 (+4294722082)
181   Inode table at 4342-4594 (+4294725878)
182   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
183   Free blocks: 245760-262143
184   Free inodes: 30361-32384
185 Group 16: (Blocks 262144-278527) [INODE_UNINIT, ITABLE_ZEROED]
186   Checksum 0x0990, unused inodes 2024
187   Block bitmap at 262144 (+0), Inode bitmap at 262160 (+16)
188   Inode table at 262176-262428 (+32)
189   12304 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
190   Free blocks: 266224-278527
191   Free inodes: 32385-34408
192 Group 17: (Blocks 278528-294911) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
193   Checksum 0xcd8f, unused inodes 2024
194   Block bitmap at 262145 (+4294950913), Inode bitmap at 262161 (+4294950929)
195   Inode table at 262429-262681 (+4294951197)
196   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
197   Free blocks: 278528-294911
198   Free inodes: 34409-36432
199 Group 18: (Blocks 294912-311295) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
200   Checksum 0xdf82, unused inodes 2024
201   Block bitmap at 262146 (+4294934530), Inode bitmap at 262162 (+4294934546)
202   Inode table at 262682-262934 (+4294935066)
203   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
204   Free blocks: 294912-311295
205   Free inodes: 36433-38456
206 Group 19: (Blocks 311296-327679) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
207   Checksum 0xd576, unused inodes 2024
208   Block bitmap at 262147 (+4294918147), Inode bitmap at 262163 (+4294918163)
209   Inode table at 262935-263187 (+4294918935)
210   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
211   Free blocks: 311296-327679
212   Free inodes: 38457-40480
213 Group 20: (Blocks 327680-344063) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
214   Checksum 0xfb98, unused inodes 2024
215   Block bitmap at 262148 (+4294901764), Inode bitmap at 262164 (+4294901780)
216   Inode table at 263188-263440 (+4294902804)
217   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
218   Free blocks: 327680-344063
219   Free inodes: 40481-42504
220 Group 21: (Blocks 344064-360447) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
221   Checksum 0x57e5, unused inodes 2024
222   Block bitmap at 262149 (+4294885381), Inode bitmap at 262165 (+4294885397)
223   Inode table at 263441-263693 (+4294886673)
224   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
225   Free blocks: 344064-360447
226   Free inodes: 42505-44528
227 Group 22: (Blocks 360448-376831) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
228   Checksum 0xee70, unused inodes 2024
229   Block bitmap at 262150 (+4294868998), Inode bitmap at 262166 (+4294869014)
230   Inode table at 263694-263946 (+4294870542)
231   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
232   Free blocks: 360448-376831
233   Free inodes: 44529-46552
234 Group 23: (Blocks 376832-393215) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
235   Checksum 0x420d, unused inodes 2024
236   Block bitmap at 262151 (+4294852615), Inode bitmap at 262167 (+4294852631)
237   Inode table at 263947-264199 (+4294854411)
238   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
239   Free blocks: 376832-393215
240   Free inodes: 46553-48576
241 Group 24: (Blocks 393216-409599) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
242   Checksum 0xb3ac, unused inodes 2024
243   Block bitmap at 262152 (+4294836232), Inode bitmap at 262168 (+4294836248)
244   Inode table at 264200-264452 (+4294838280)
245   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
246   Free blocks: 393216-409599
247   Free inodes: 48577-50600
248 Group 25: (Blocks 409600-425983) [INODE_UNINIT, ITABLE_ZEROED]
249   Checksum 0xaab1, unused inodes 2024
250   Backup superblock at 409600, Group descriptors at 409601-409602
251   Reserved GDT blocks at 409603-410114
252   Block bitmap at 262153 (+4294819849), Inode bitmap at 262169 (+4294819865)
253   Inode table at 264453-264705 (+4294822149)
254   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
255   Free blocks: 410115-425983
256   Free inodes: 50601-52624
257 Group 26: (Blocks 425984-442367) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
258   Checksum 0xab55, unused inodes 2024
259   Block bitmap at 262154 (+4294803466), Inode bitmap at 262170 (+4294803482)
260   Inode table at 264706-264958 (+4294806018)
261   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
262   Free blocks: 425984-442367
263   Free inodes: 52625-54648
264 Group 27: (Blocks 442368-458751) [INODE_UNINIT, ITABLE_ZEROED]
265   Checksum 0x28a7, unused inodes 2024
266   Backup superblock at 442368, Group descriptors at 442369-442370
267   Reserved GDT blocks at 442371-442882
268   Block bitmap at 262155 (+4294787083), Inode bitmap at 262171 (+4294787099)
269   Inode table at 264959-265211 (+4294789887)
270   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
271   Free blocks: 442883-458751
272   Free inodes: 54649-56672
273 Group 28: (Blocks 458752-475135) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
274   Checksum 0x73c6, unused inodes 2024
275   Block bitmap at 262156 (+4294770700), Inode bitmap at 262172 (+4294770716)
276   Inode table at 265212-265464 (+4294773756)
277   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
278   Free blocks: 458752-475135
279   Free inodes: 56673-58696
280 Group 29: (Blocks 475136-491519) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
281   Checksum 0xb9dd, unused inodes 2024
282   Block bitmap at 262157 (+4294754317), Inode bitmap at 262173 (+4294754333)
283   Inode table at 265465-265717 (+4294757625)
284   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
285   Free blocks: 475136-491519
286   Free inodes: 58697-60720
287 Group 30: (Blocks 491520-507903) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
288   Checksum 0xef7a, unused inodes 2024
289   Block bitmap at 262158 (+4294737934), Inode bitmap at 262174 (+4294737950)
290   Inode table at 265718-265970 (+4294741494)
291   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
292   Free blocks: 491520-507903
293   Free inodes: 60721-62744
294 Group 31: (Blocks 507904-524287) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
295   Checksum 0xa124, unused inodes 2024
296   Block bitmap at 262159 (+4294721551), Inode bitmap at 262175 (+4294721567)
297   Inode table at 265971-266223 (+4294725363)
298   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
299   Free blocks: 507904-524287
300   Free inodes: 62745-64768
301 Group 32: (Blocks 524288-540671) [INODE_UNINIT, ITABLE_ZEROED]
302   Checksum 0xcb02, unused inodes 2024
303   Block bitmap at 524288 (+0), Inode bitmap at 524304 (+16)
304   Inode table at 524320-524572 (+32)
305   12304 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
306   Free blocks: 528368-540671
307   Free inodes: 64769-66792
308 Group 33: (Blocks 540672-557055) [INODE_UNINIT, ITABLE_ZEROED]
309   Checksum 0x1cd5, unused inodes 2024
310   Block bitmap at 524289 (+4294950913), Inode bitmap at 524305 (+4294950929)
311   Inode table at 524573-524825 (+4294951197)
312   0 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
313   Free blocks:
314   Free inodes: 66793-68816
315 Group 34: (Blocks 557056-573439) [INODE_UNINIT, ITABLE_ZEROED]
316   Checksum 0x0ed8, unused inodes 2024
317   Block bitmap at 524290 (+4294934530), Inode bitmap at 524306 (+4294934546)
318   Inode table at 524826-525078 (+4294935066)
319   0 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
320   Free blocks:
321   Free inodes: 68817-70840
322 Group 35: (Blocks 573440-589823) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
323   Checksum 0x17e4, unused inodes 2024
324   Block bitmap at 524291 (+4294918147), Inode bitmap at 524307 (+4294918163)
325   Inode table at 525079-525331 (+4294918935)
326   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
327   Free blocks: 573440-589823
328   Free inodes: 70841-72864
329 Group 36: (Blocks 589824-606207) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
330   Checksum 0x390a, unused inodes 2024
331   Block bitmap at 524292 (+4294901764), Inode bitmap at 524308 (+4294901780)
332   Inode table at 525332-525584 (+4294902804)
333   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
334   Free blocks: 589824-606207
335   Free inodes: 72865-74888
336 Group 37: (Blocks 606208-622591) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
337   Checksum 0x9577, unused inodes 2024
338   Block bitmap at 524293 (+4294885381), Inode bitmap at 524309 (+4294885397)
339   Inode table at 525585-525837 (+4294886673)
340   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
341   Free blocks: 606208-622591
342   Free inodes: 74889-76912
343 Group 38: (Blocks 622592-638975) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
344   Checksum 0x2ce2, unused inodes 2024
345   Block bitmap at 524294 (+4294868998), Inode bitmap at 524310 (+4294869014)
346   Inode table at 525838-526090 (+4294870542)
347   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
348   Free blocks: 622592-638975
349   Free inodes: 76913-78936
350 Group 39: (Blocks 638976-655359) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
351   Checksum 0x809f, unused inodes 2024
352   Block bitmap at 524295 (+4294852615), Inode bitmap at 524311 (+4294852631)
353   Inode table at 526091-526343 (+4294854411)
354   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
355   Free blocks: 638976-655359
356   Free inodes: 78937-80960
357 Group 40: (Blocks 655360-671743) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
358   Checksum 0x713e, unused inodes 2024
359   Block bitmap at 524296 (+4294836232), Inode bitmap at 524312 (+4294836248)
360   Inode table at 526344-526596 (+4294838280)
361   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
362   Free blocks: 655360-671743
363   Free inodes: 80961-82984
364 Group 41: (Blocks 671744-688127) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
365   Checksum 0x7bca, unused inodes 2024
366   Block bitmap at 524297 (+4294819849), Inode bitmap at 524313 (+4294819865)
367   Inode table at 526597-526849 (+4294822149)
368   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
369   Free blocks: 671744-688127
370   Free inodes: 82985-85008
371 Group 42: (Blocks 688128-704511) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
372   Checksum 0x69c7, unused inodes 2024
373   Block bitmap at 524298 (+4294803466), Inode bitmap at 524314 (+4294803482)
374   Inode table at 526850-527102 (+4294806018)
375   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
376   Free blocks: 688128-704511
377   Free inodes: 85009-87032
378 Group 43: (Blocks 704512-720895) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
379   Checksum 0xf9dc, unused inodes 2024
380   Block bitmap at 524299 (+4294787083), Inode bitmap at 524315 (+4294787099)
381   Inode table at 527103-527355 (+4294789887)
382   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
383   Free blocks: 704512-720895
384   Free inodes: 87033-89056
385 Group 44: (Blocks 720896-737279) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
386   Checksum 0xb154, unused inodes 2024
387   Block bitmap at 524300 (+4294770700), Inode bitmap at 524316 (+4294770716)
388   Inode table at 527356-527608 (+4294773756)
389   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
390   Free blocks: 720896-737279
391   Free inodes: 89057-91080
392 Group 45: (Blocks 737280-753663) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
393   Checksum 0x7b4f, unused inodes 2024
394   Block bitmap at 524301 (+4294754317), Inode bitmap at 524317 (+4294754333)
395   Inode table at 527609-527861 (+4294757625)
396   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
397   Free blocks: 737280-753663
398   Free inodes: 91081-93104
399 Group 46: (Blocks 753664-770047) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
400   Checksum 0x2de8, unused inodes 2024
401   Block bitmap at 524302 (+4294737934), Inode bitmap at 524318 (+4294737950)
402   Inode table at 527862-528114 (+4294741494)
403   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
404   Free blocks: 753664-770047
405   Free inodes: 93105-95128
406 Group 47: (Blocks 770048-786431) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
407   Checksum 0x63b6, unused inodes 2024
408   Block bitmap at 524303 (+4294721551), Inode bitmap at 524319 (+4294721567)
409   Inode table at 528115-528367 (+4294725363)
410   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
411   Free blocks: 770048-786431
412   Free inodes: 95129-97152
413 Group 48: (Blocks 786432-802815) [INODE_UNINIT, ITABLE_ZEROED]
414   Checksum 0x8a8c, unused inodes 2024
415   Block bitmap at 786432 (+0), Inode bitmap at 786448 (+16)
416   Inode table at 786464-786716 (+32)
417   12304 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
418   Free blocks: 790512-802815
419   Free inodes: 97153-99176
420 Group 49: (Blocks 802816-819199) [INODE_UNINIT, ITABLE_ZEROED]
421   Checksum 0x5d7a, unused inodes 2024
422   Backup superblock at 802816, Group descriptors at 802817-802818
423   Reserved GDT blocks at 802819-803330
424   Block bitmap at 786433 (+4294950913), Inode bitmap at 786449 (+4294950929)
425   Inode table at 786717-786969 (+4294951197)
426   15869 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
427   Free blocks: 803331-819199
428   Free inodes: 99177-101200
429 Group 50: (Blocks 819200-835583) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
430   Checksum 0x5c9e, unused inodes 2024
431   Block bitmap at 786434 (+4294934530), Inode bitmap at 786450 (+4294934546)
432   Inode table at 786970-787222 (+4294935066)
433   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
434   Free blocks: 819200-835583
435   Free inodes: 101201-103224
436 Group 51: (Blocks 835584-851967) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
437   Checksum 0x566a, unused inodes 2024
438   Block bitmap at 786435 (+4294918147), Inode bitmap at 786451 (+4294918163)
439   Inode table at 787223-787475 (+4294918935)
440   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
441   Free blocks: 835584-851967
442   Free inodes: 103225-105248
443 Group 52: (Blocks 851968-868351) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
444   Checksum 0x7884, unused inodes 2024
445   Block bitmap at 786436 (+4294901764), Inode bitmap at 786452 (+4294901780)
446   Inode table at 787476-787728 (+4294902804)
447   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
448   Free blocks: 851968-868351
449   Free inodes: 105249-107272
450 Group 53: (Blocks 868352-884735) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
451   Checksum 0xd4f9, unused inodes 2024
452   Block bitmap at 786437 (+4294885381), Inode bitmap at 786453 (+4294885397)
453   Inode table at 787729-787981 (+4294886673)
454   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
455   Free blocks: 868352-884735
456   Free inodes: 107273-109296
457 Group 54: (Blocks 884736-901119) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
458   Checksum 0x6d6c, unused inodes 2024
459   Block bitmap at 786438 (+4294868998), Inode bitmap at 786454 (+4294869014)
460   Inode table at 787982-788234 (+4294870542)
461   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
462   Free blocks: 884736-901119
463   Free inodes: 109297-111320
464 Group 55: (Blocks 901120-917503) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
465   Checksum 0xc111, unused inodes 2024
466   Block bitmap at 786439 (+4294852615), Inode bitmap at 786455 (+4294852631)
467   Inode table at 788235-788487 (+4294854411)
468   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
469   Free blocks: 901120-917503
470   Free inodes: 111321-113344
471 Group 56: (Blocks 917504-933887) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
472   Checksum 0x30b0, unused inodes 2024
473   Block bitmap at 786440 (+4294836232), Inode bitmap at 786456 (+4294836248)
474   Inode table at 788488-788740 (+4294838280)
475   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
476   Free blocks: 917504-933887
477   Free inodes: 113345-115368
478 Group 57: (Blocks 933888-950271) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
479   Checksum 0x3a44, unused inodes 2024
480   Block bitmap at 786441 (+4294819849), Inode bitmap at 786457 (+4294819865)
481   Inode table at 788741-788993 (+4294822149)
482   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
483   Free blocks: 933888-950271
484   Free inodes: 115369-117392
485 Group 58: (Blocks 950272-966655) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
486   Checksum 0x2849, unused inodes 2024
487   Block bitmap at 786442 (+4294803466), Inode bitmap at 786458 (+4294803482)
488   Inode table at 788994-789246 (+4294806018)
489   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
490   Free blocks: 950272-966655
491   Free inodes: 117393-119416
492 Group 59: (Blocks 966656-983039) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
493   Checksum 0xb852, unused inodes 2024
494   Block bitmap at 786443 (+4294787083), Inode bitmap at 786459 (+4294787099)
495   Inode table at 789247-789499 (+4294789887)
496   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
497   Free blocks: 966656-983039
498   Free inodes: 119417-121440
499 Group 60: (Blocks 983040-999423) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
500   Checksum 0xf0da, unused inodes 2024
501   Block bitmap at 786444 (+4294770700), Inode bitmap at 786460 (+4294770716)
502   Inode table at 789500-789752 (+4294773756)
503   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
504   Free blocks: 983040-999423
505   Free inodes: 121441-123464
506 Group 61: (Blocks 999424-1015807) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
507   Checksum 0x3ac1, unused inodes 2024
508   Block bitmap at 786445 (+4294754317), Inode bitmap at 786461 (+4294754333)
509   Inode table at 789753-790005 (+4294757625)
510   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
511   Free blocks: 999424-1015807
512   Free inodes: 123465-125488
513 Group 62: (Blocks 1015808-1032191) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
514   Checksum 0x6c66, unused inodes 2024
515   Block bitmap at 786446 (+4294737934), Inode bitmap at 786462 (+4294737950)
516   Inode table at 790006-790258 (+4294741494)
517   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
518   Free blocks: 1015808-1032191
519   Free inodes: 125489-127512
520 Group 63: (Blocks 1032192-1048575) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
521   Checksum 0x2238, unused inodes 2024
522   Block bitmap at 786447 (+4294721551), Inode bitmap at 786463 (+4294721567)
523   Inode table at 790259-790511 (+4294725363)
524   16384 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
525   Free blocks: 1032192-1048575
526   Free inodes: 127513-129536
527 Group 64: (Blocks 1048576-1052255) [INODE_UNINIT, ITABLE_ZEROED]
528   Checksum 0xb5ee, unused inodes 2024
529   Block bitmap at 1048576 (+0), Inode bitmap at 1048592 (+16)
530   Inode table at 1048608-1048860 (+32)
531   3425 free blocks, 2024 free inodes, 0 directories, 2024 unused inodes
532   Free blocks: 1048577-1048591, 1048593-1048607, 1048861-1052255
533   Free inodes: 129537-131560
534 [root@yinzhengjie ~]#
535 '''
用dumpe2fs 查看超级块和是否有碎片
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# dumpe2fs -h /dev/sdb3  #仅显示超级块中保存的信息
 9 dumpe2fs 1.41.12 (17-May-2010)
10 Filesystem volume name:   <none>  #文件系统卷标名称
11 Last mounted on:          <not available>   #上一次上面时候挂载的
12 Filesystem UUID:          87f7686e-09bd-4a1e-a567-4939c6a4dcab
13 Filesystem magic number:  0xEF53  #文件的魔术号
14 Filesystem revision #:    1 (dynamic)
15 Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize  #支持的默认属性
16 Filesystem flags:         signed_directory_hash
17 Default mount options:    (none)
18 Filesystem state:         clean
19 Errors behavior:          Continue
20 Filesystem OS type:       Linux
21 Inode count:              131560
22 Block count:              1052256
23 Reserved block count:     31567
24 Free blocks:              998268
25 Free inodes:              131549
26 First block:              0
27 Block size:               2048
28 Fragment size:            2048
29 Reserved GDT blocks:      512
30 Blocks per group:         16384
31 Fragments per group:      16384
32 Inodes per group:         2024
33 Inode blocks per group:   253
34 Flex block group size:    16
35 Filesystem created:       Thu May 11 12:42:49 2017
36 Last mount time:          n/a
37 Last write time:          Thu May 11 12:42:49 2017
38 Mount count:              0
39 Maximum mount count:      29
40 Last checked:             Thu May 11 12:42:49 2017
41 Check interval:           15552000 (6 months)
42 Next check after:         Tue Nov  7 11:42:49 2017
43 Lifetime writes:          97 MB
44 Reserved blocks uid:      0 (user root)
45 Reserved blocks gid:      0 (group root)
46 First inode:              11
47 Inode size:               256
48 Required extra isize:     28
49 Desired extra isize:      28
50 Journal inode:            8
51 Default directory hash:   half_md4
52 Directory Hash Seed:      ff3c9e24-63aa-462a-9d6d-863f99c556d0
53 Journal backup:           inode blocks
54 Journal features:         (none)
55 Journal size:             64M
56 Journal length:           32768
57 Journal sequence:         0x00000001
58 Journal start:            0
59 
60 [root@yinzhengjie ~]#
61 '''
dumpe2fs的-h参数用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# tune2fs -l /dev/sdb3  #查看超级块中的信息。
 9 tune2fs 1.41.12 (17-May-2010)
10 Filesystem volume name:   <none>
11 Last mounted on:          <not available>
12 Filesystem UUID:          87f7686e-09bd-4a1e-a567-4939c6a4dcab
13 Filesystem magic number:  0xEF53
14 Filesystem revision #:    1 (dynamic)
15 Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
16 Filesystem flags:         signed_directory_hash 
17 Default mount options:    (none)
18 Filesystem state:         clean
19 Errors behavior:          Continue
20 Filesystem OS type:       Linux
21 Inode count:              131560
22 Block count:              1052256
23 Reserved block count:     31567
24 Free blocks:              998268
25 Free inodes:              131549
26 First block:              0
27 Block size:               2048
28 Fragment size:            2048
29 Reserved GDT blocks:      512
30 Blocks per group:         16384
31 Fragments per group:      16384
32 Inodes per group:         2024
33 Inode blocks per group:   253
34 Flex block group size:    16
35 Filesystem created:       Thu May 11 12:42:49 2017
36 Last mount time:          n/a
37 Last write time:          Thu May 11 12:42:49 2017
38 Mount count:              0
39 Maximum mount count:      29
40 Last checked:             Thu May 11 12:42:49 2017
41 Check interval:           15552000 (6 months)
42 Next check after:         Tue Nov  7 11:42:49 2017
43 Lifetime writes:          97 MB
44 Reserved blocks uid:      0 (user root)
45 Reserved blocks gid:      0 (group root)
46 First inode:              11
47 Inode size:               256
48 Required extra isize:     28
49 Desired extra isize:      28
50 Journal inode:            8
51 Default directory hash:   half_md4
52 Directory Hash Seed:      ff3c9e24-63aa-462a-9d6d-863f99c556d0
53 Journal backup:           inode blocks
54 [root@yinzhengjie ~]# 
55 [root@yinzhengjie ~]#
56 '''
用tune2fs查看超级块中的信息。
  1 #!/usr/bin/env python
  2 #_*_coding:utf-8_*_
  3 #@author :yinzhengjie
  4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
  5 #EMAIL:y1053419035@qq.com
  6 
  7 '''
  8 [root@yinzhengjie ~]# tune2fs -l /dev/sdb3  #查看/dev/sdb3 超级块中的信息
  9 tune2fs 1.41.12 (17-May-2010)
 10 Filesystem volume name:   <none>
 11 Last mounted on:          <not available>
 12 Filesystem UUID:          87f7686e-09bd-4a1e-a567-4939c6a4dcab
 13 Filesystem magic number:  0xEF53
 14 Filesystem revision #:    1 (dynamic)
 15 Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize  #含有分区特性“huge_file”
 16 Filesystem flags:         signed_directory_hash
 17 Default mount options:    (none)
 18 Filesystem state:         not clean
 19 Errors behavior:          Continue
 20 Filesystem OS type:       Linux
 21 Inode count:              131560
 22 Block count:              1052256
 23 Reserved block count:     31567
 24 Free blocks:              998268
 25 Free inodes:              131549
 26 First block:              0
 27 Block size:               2048
 28 Fragment size:            2048
 29 Reserved GDT blocks:      512
 30 Blocks per group:         16384
 31 Fragments per group:      16384
 32 Inodes per group:         2024
 33 Inode blocks per group:   253
 34 Flex block group size:    16
 35 Filesystem created:       Thu May 11 12:42:49 2017
 36 Last mount time:          n/a
 37 Last write time:          Thu May 11 13:04:33 2017
 38 Mount count:              0
 39 Maximum mount count:      29
 40 Last checked:             Thu May 11 12:42:49 2017
 41 Check interval:           15552000 (6 months)
 42 Next check after:         Tue Nov  7 11:42:49 2017
 43 Lifetime writes:          97 MB
 44 Reserved blocks uid:      0 (user root)
 45 Reserved blocks gid:      0 (group root)
 46 First inode:              11
 47 Inode size:               256
 48 Required extra isize:     28
 49 Desired extra isize:      28
 50 Journal inode:            8
 51 Default directory hash:   half_md4
 52 Directory Hash Seed:      ff3c9e24-63aa-462a-9d6d-863f99c556d0
 53 Journal backup:           inode blocks
 54 [root@yinzhengjie ~]# tune2fs -O ^huge_file /dev/sdb3   #关闭/dev/sdb3的huge_file分区特性
 55 tune2fs 1.41.12 (17-May-2010)
 56 
 57 Please run e2fsck on the filesystem.
 58 
 59 [root@yinzhengjie ~]# tune2fs -l /dev/sdb3
 60 tune2fs 1.41.12 (17-May-2010)
 61 Filesystem volume name:   <none>
 62 Last mounted on:          <not available>
 63 Filesystem UUID:          87f7686e-09bd-4a1e-a567-4939c6a4dcab
 64 Filesystem magic number:  0xEF53
 65 Filesystem revision #:    1 (dynamic)
 66 Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super uninit_bg dir_nlink extra_isize  #果真huge_file的分区特性没了
 67 Filesystem flags:         signed_directory_hash
 68 Default mount options:    (none)
 69 Filesystem state:         not clean
 70 Errors behavior:          Continue
 71 Filesystem OS type:       Linux
 72 Inode count:              131560
 73 Block count:              1052256
 74 Reserved block count:     31567
 75 Free blocks:              998268
 76 Free inodes:              131549
 77 First block:              0
 78 Block size:               2048
 79 Fragment size:            2048
 80 Reserved GDT blocks:      512
 81 Blocks per group:         16384
 82 Fragments per group:      16384
 83 Inodes per group:         2024
 84 Inode blocks per group:   253
 85 Flex block group size:    16
 86 Filesystem created:       Thu May 11 12:42:49 2017
 87 Last mount time:          n/a
 88 Last write time:          Thu May 11 13:04:49 2017
 89 Mount count:              0
 90 Maximum mount count:      29
 91 Last checked:             Thu May 11 12:42:49 2017
 92 Check interval:           15552000 (6 months)
 93 Next check after:         Tue Nov  7 11:42:49 2017
 94 Lifetime writes:          97 MB
 95 Reserved blocks uid:      0 (user root)
 96 Reserved blocks gid:      0 (group root)
 97 First inode:              11
 98 Inode size:               256
 99 Required extra isize:     28
100 Desired extra isize:      28
101 Journal inode:            8
102 Default directory hash:   half_md4
103 Directory Hash Seed:      ff3c9e24-63aa-462a-9d6d-863f99c556d0
104 Journal backup:           inode blocks
105 [root@yinzhengjie ~]# tune2fs -O huge_file /dev/sdb3  #打开/dev/sdb3的huge_file分区特性
106 tune2fs 1.41.12 (17-May-2010)
107 [root@yinzhengjie ~]# tune2fs -l /dev/sdb3
108 tune2fs 1.41.12 (17-May-2010)
109 Filesystem volume name:   <none>
110 Last mounted on:          <not available>
111 Filesystem UUID:          87f7686e-09bd-4a1e-a567-4939c6a4dcab
112 Filesystem magic number:  0xEF53
113 Filesystem revision #:    1 (dynamic)
114 Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize  #/dev/sdb3的huge_file分区特性又有了
115 Filesystem flags:         signed_directory_hash
116 Default mount options:    (none)
117 Filesystem state:         not clean
118 Errors behavior:          Continue
119 Filesystem OS type:       Linux
120 Inode count:              131560
121 Block count:              1052256
122 Reserved block count:     31567
123 Free blocks:              998268
124 Free inodes:              131549
125 First block:              0
126 Block size:               2048
127 Fragment size:            2048
128 Reserved GDT blocks:      512
129 Blocks per group:         16384
130 Fragments per group:      16384
131 Inodes per group:         2024
132 Inode blocks per group:   253
133 Flex block group size:    16
134 Filesystem created:       Thu May 11 12:42:49 2017
135 Last mount time:          n/a
136 Last write time:          Thu May 11 13:05:00 2017
137 Mount count:              0
138 Maximum mount count:      29
139 Last checked:             Thu May 11 12:42:49 2017
140 Check interval:           15552000 (6 months)
141 Next check after:         Tue Nov  7 11:42:49 2017
142 Lifetime writes:          97 MB
143 Reserved blocks uid:      0 (user root)
144 Reserved blocks gid:      0 (group root)
145 First inode:              11
146 Inode size:               256
147 Required extra isize:     28
148 Desired extra isize:      28
149 Journal inode:            8
150 Default directory hash:   half_md4
151 Directory Hash Seed:      ff3c9e24-63aa-462a-9d6d-863f99c556d0
152 Journal backup:           inode blocks
153 [root@yinzhengjie ~]#
154 '''
tune2fs的对特性的开启与关闭用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# fsck -t ext4 /dev/sdb3  #对文件系统检测
 9 fsck from util-linux-ng 2.17.2
10 e2fsck 1.41.12 (17-May-2010)
11 /dev/sdb3 was not cleanly unmounted, check forced.
12 Pass 1: Checking inodes, blocks, and sizes  #检测 inodes, blocks, and sizes
13 Pass 2: Checking directory structure        #检测目录机构
14 Pass 3: Checking directory connectivity     #检测目录连整性
15 Pass 4: Checking reference counts           #引用的次数
16 Pass 5: Checking group summary information  #检查组汇总信息
17 /dev/sdb3: 11/131560 files (0.0% non-contiguous), 53988/1052256 blocks
18 [root@yinzhengjie ~]#
19 '''
用fsck进行文件类型检查

 

11.创建交换分区

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8     如果物理内存不够用时,可以将那些最近很少使用的页面数据(Page)置换出去,即切换到硬盘上,但是要注意的是内
 9 存文件的格式和硬盘中文件的格式是不一样的,所以这个分区必须格式化成跟内存兼容的模式不能转换成文件的格式。以便
10 把内存的page直接存入这个分区,方便内存直接调用。而这个页面(page)数据对于32位的操作系统一个page大概是4K左右,
11 对于64位操作系统这个page大小是可变的,4k-2M的大小都是比较常见的。事实上到底能使用多大的页面(page)取决于CPU
12 而不取决于内存哟!这就是虚拟内存的概念。在linux上我们称之为交换分区。记住,虚拟内存必须是一个单独的分区。
13 
14 那么问题来了:虚拟内存能代替物理内存运行程序吗?
15     答案是否定的,只是使用虚拟内存暂时保存数据,而不是代替物理内存运行程序。
16     虚拟内存的作用是这样的:
17         当运行某个大程序、大游戏,需要的内存超过空闲内存但小于物理内存总量时,会暂时把内存里这些数据放到磁盘
18     上的虚拟内存里,空出物理内存运行游戏。等退出游戏后,又会把虚拟内存里的东西读出来,放回物理内存。所以,虚拟
19     内存,并不是用来虚拟物理内存的,而是暂存数据的。如果对内存的需求大于物理内存总量,那虚拟内存设多大都不管用。
20     电脑内存太低,根本的方法还是增加物理内存,才能流畅。虚拟内存机制上就不管用,即使管用,比物理内存低100倍的速
21     度,也管不上什么实际的作用。所以,虚拟内存大了是没用的,反而白占用磁盘空间。
22 '''
23 
24 '''
25 交换分区:
26       mkswap 格式化为虚拟内存
27       -L label 指定卷标
28       swapon 启动虚拟内存
29       -a 启动所有的虚拟分区
30       -p:指定优先级
31       swapoff 关闭虚拟内存
32       更多参数请参考man mkswap
33 ''' 
  1 #!/usr/bin/env python
  2 #_*_coding:utf-8_*_
  3 #@author :yinzhengjie
  4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
  5 #EMAIL:y1053419035@qq.com
  6 
  7 '''
  8 [root@yinzhengjie ~]# fdisk /dev/sdb  #对第二块硬盘进行分区调整
  9 
 10 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
 11          switch off the mode (command 'c') and change display units to
 12          sectors (command 'u').
 13 
 14 Command (m for help): p  #查看当前分区情况
 15 
 16 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 17 255 heads, 63 sectors/track, 1305 cylinders
 18 Units = cylinders of 16065 * 512 = 8225280 bytes
 19 Sector size (logical/physical): 512 bytes / 512 bytes
 20 I/O size (minimum/optimal): 512 bytes / 512 bytes
 21 Disk identifier: 0x8614a108
 22 
 23    Device Boot      Start         End      Blocks   Id  System
 24 /dev/sdb1               1         132     1060258+  83  Linux
 25 /dev/sdb2             133         264     1060290   83  Linux
 26 /dev/sdb3             265         526     2104515   83  Linux
 27 /dev/sdb4             527        1305     6257317+   5  Extended
 28 /dev/sdb5             527         919     3156741   83  Linux
 29 /dev/sdb6             920        1181     2104483+  83  Linux    #我想讲第6个分区弄成交换分区。
 30 
 31 Command (m for help): t  #调整分区ID
 32 Partition number (1-6): 6  #选择分区编号为6
 33 Hex code (type L to list codes): L   #查看分区类型所对应的ID号,我们发现“82”就是交换分区的编号
 34 
 35  0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 36  1  FAT12           39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-
 37  2  XENIX root      3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
 38  3  XENIX usr       40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 39  4  FAT16 <32M      41  PPC PReP Boot   85  Linux extended  c7  Syrinx
 40  5  Extended        42  SFS             86  NTFS volume set da  Non-FS data
 41  6  FAT16           4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .
 42  7  HPFS/NTFS       4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility
 43  8  AIX             4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt
 44  9  AIX bootable    50  OnTrack DM      93  Amoeba          e1  DOS access
 45  a  OS/2 Boot Manag 51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O
 46  b  W95 FAT32       52  CP/M            9f  BSD/OS          e4  SpeedStor
 47  c  W95 FAT32 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs
 48  e  W95 FAT16 (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  GPT
 49  f  W95 Ext'd (LBA) 55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
 50 10  OPUS            56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
 51 11  Hidden FAT12    5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor
 52 12  Compaq diagnost 61  SpeedStor       a9  NetBSD          f4  SpeedStor
 53 14  Hidden FAT16 <3 63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary
 54 16  Hidden FAT16    64  Novell Netware  af  HFS / HFS+      fb  VMware VMFS
 55 17  Hidden HPFS/NTF 65  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
 56 18  AST SmartSleep  70  DiskSecure Mult b8  BSDI swap       fd  Linux raid auto
 57 1b  Hidden W95 FAT3 75  PC/IX           bb  Boot Wizard hid fe  LANstep
 58 1c  Hidden W95 FAT3 80  Old Minix       be  Solaris boot    ff  BBT
 59 1e  Hidden W95 FAT1
 60 Hex code (type L to list codes): 82   #设置该分区的标号
 61 Changed system type of partition 6 to 82 (Linux swap / Solaris)
 62 
 63 Command (m for help): P   #查看当前分区情况
 64 
 65 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 66 255 heads, 63 sectors/track, 1305 cylinders
 67 Units = cylinders of 16065 * 512 = 8225280 bytes
 68 Sector size (logical/physical): 512 bytes / 512 bytes
 69 I/O size (minimum/optimal): 512 bytes / 512 bytes
 70 Disk identifier: 0x8614a108
 71 
 72    Device Boot      Start         End      Blocks   Id  System
 73 /dev/sdb1               1         132     1060258+  83  Linux
 74 /dev/sdb2             133         264     1060290   83  Linux
 75 /dev/sdb3             265         526     2104515   83  Linux
 76 /dev/sdb4             527        1305     6257317+   5  Extended
 77 /dev/sdb5             527         919     3156741   83  Linux
 78 /dev/sdb6             920        1181     2104483+  82  Linux swap / Solaris
 79 
 80 Command (m for help): W  #保存并退出
 81 The partition table has been altered!
 82 
 83 Calling ioctl() to re-read partition table.
 84 Syncing disks.
 85 [root@yinzhengjie ~]#
 86 [root@yinzhengjie ~]# fdisk -l /dev/sdb  #查看分区信息
 87 
 88 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
 89 255 heads, 63 sectors/track, 1305 cylinders
 90 Units = cylinders of 16065 * 512 = 8225280 bytes
 91 Sector size (logical/physical): 512 bytes / 512 bytes
 92 I/O size (minimum/optimal): 512 bytes / 512 bytes
 93 Disk identifier: 0x8614a108
 94 
 95    Device Boot      Start         End      Blocks   Id  System
 96 /dev/sdb1               1         132     1060258+  83  Linux
 97 /dev/sdb2             133         264     1060290   83  Linux
 98 /dev/sdb3             265         526     2104515   83  Linux
 99 /dev/sdb4             527        1305     6257317+   5  Extended
100 /dev/sdb5             527         919     3156741   83  Linux
101 /dev/sdb6             920        1181     2104483+  82  Linux swap / Solaris
102 [root@yinzhengjie ~]# 
103 '''
调整分区为交换分区(swap)格式
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# kpartx -af /dev/sdb
 9 [root@yinzhengjie ~]# partx -a /dev/sdb   #重读分区表信息,其实也可以不用敲击这些命令的如果你是一块新硬盘的话。
10 BLKPG: Device or resource busy
11 error adding partition 1
12 BLKPG: Device or resource busy
13 error adding partition 2
14 BLKPG: Device or resource busy
15 error adding partition 3
16 BLKPG: Device or resource busy
17 error adding partition 4
18 BLKPG: Device or resource busy
19 error adding partition 5
20 BLKPG: Device or resource busy
21 error adding partition 6
22 [root@yinzhengjie ~]# 
23 '''
用partx 重读一下分区表,避免系统未识别最新分区信息。
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mkswap /dev/sdb6  #将分区格式化成swap格式
 9 Setting up swapspace version 1, size = 2104476 KiB
10 no label, UUID=41687bb2-c775-489c-9b32-1e4be73c233b   #看见没有,这里是“no label”,是因为我没有定义卷标名。
11 [root@yinzhengjie ~]# 
12 [root@yinzhengjie ~]# mkswap -L myswap /dev/sdb6   #用-L参数定义一个卷标名。
13 Setting up swapspace version 1, size = 2104476 KiB
14 LABEL=myswap, UUID=0553b99a-ee75-4476-8eda-70c591206467  #看见没,“LABEL=myswap”这就是我定义的卷标名称。
15 [root@yinzhengjie ~]# 
16 '''
用mkswap定义卷标名称
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# cat /proc/meminfo | grep "^S"   #查看当前交换分区大小
 9 SwapCached:            0 kB
10 SwapTotal:       2031612 kB  #目前交换分区大小为2G
11 SwapFree:        2031612 kB  #表示空闲交换分区大小
12 Shmem:              1444 kB
13 Slab:              75020 kB
14 SReclaimable:      15620 kB
15 SUnreclaim:        59400 kB
16 [root@yinzhengjie ~]#
17 [root@yinzhengjie ~]# swapon /dev/sdb6   #启用我们已经格式化好的交换分区“/dev/sdb”
18 [root@yinzhengjie ~]# cat /proc/meminfo | grep "^S"   #再次查看当前交换分区大小
19 SwapCached:            0 kB
20 SwapTotal:       4136088 kB   #我们发现交换分区大小变大了2G
21 SwapFree:        4136088 kB
22 Shmem:              1444 kB
23 Slab:              75148 kB
24 SReclaimable:      15656 kB
25 SUnreclaim:        59492 kB
26 [root@yinzhengjie ~]#
27 [root@yinzhengjie ~]# swapoff /dev/sdb6  #关闭交换分区“/dev/sdb”
28 [root@yinzhengjie ~]#
29 [root@yinzhengjie ~]# cat /proc/meminfo | grep "^S"  #验证是否关闭成功
30 SwapCached:            0 kB
31 SwapTotal:       2031612 kB   #发现的确是少了2G的空间
32 SwapFree:        2031612 kB
33 Shmem:              1444 kB
34 Slab:              75068 kB
35 SReclaimable:      15636 kB
36 SUnreclaim:        59432 kB
37 [root@yinzhengjie ~]#
38 
39 '''
swapon和swapoff的用法展示

 

12.获取IDE磁盘的相关信息

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 hdparm
 9     -i 从操作系统读取
10     -I 直接从硬盘读取
11     -g 显示硬盘的布局信息
12     -t 测试硬盘的性能
13     -T 测试硬盘的性能
14 
15 '''
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8      一个磁头一次可以读取128位信息,系统就会认为它被虚拟成128个磁头(heads)。所以两个磁头(一个盘片有两个面,
 9 一个盘面有一个磁头,所以说一个盘片有2个磁头)就是256个虚拟磁头(heads)。
10 [root@yinzhengjie ~]#
11 [root@yinzhengjie ~]# fdisk -l /dev/sdb  #我们可以看出来磁盘的信息
12 
13 Disk /dev/sdb: 10.7 GB, 10737418240 bytes
14 255 heads, 63 sectors/track, 1305 cylinders  #这里有255个磁头其实是工业生产导致,理论上就是256大家知道即可。
15 Units = cylinders of 16065 * 512 = 8225280 bytes
16 Sector size (logical/physical): 512 bytes / 512 bytes
17 I/O size (minimum/optimal): 512 bytes / 512 bytes
18 Disk identifier: 0x8614a108
19 
20    Device Boot      Start         End      Blocks   Id  System
21 /dev/sdb1               1         132     1060258+  83  Linux
22 /dev/sdb2             133         264     1060290   83  Linux
23 /dev/sdb3             265         526     2104515   83  Linux
24 /dev/sdb4             527        1305     6257317+   5  Extended
25 /dev/sdb5             527         919     3156741   83  Linux
26 /dev/sdb6             920        1181     2104483+  82  Linux swap / Solaris
27 [root@yinzhengjie ~]#
28 '''
29 
30 '''
31 [root@yinzhengjie ~]# hdparm -i /dev/sdb  #从操作系统读取
32 
33 /dev/sdb:
34 SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
35  HDIO_GET_IDENTITY failed: Invalid argument
36 [root@yinzhengjie ~]#
37 [root@yinzhengjie ~]# hdparm -I /dev/sdb  #直接从硬盘读取
38 
39 /dev/sdb:
40 SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
41 
42 ATA device, with non-removable media
43 Standards:
44         Likely used: 1
45 Configuration:
46         Logical         max     current
47         cylinders       0       0
48         heads           0       0
49         sectors/track   0       0
50         --
51         Logical/Physical Sector size:           512 bytes
52         device size with M = 1024*1024:           0 MBytes
53         device size with M = 1000*1000:           0 MBytes
54         cache/buffer size  = unknown
55 Capabilities:
56         IORDY not likely
57         Cannot perform double-word IO
58         R/W multiple sector transfer: not supported
59         DMA: not supported
60         PIO: pio0
61 [root@yinzhengjie ~]#
62 [root@yinzhengjie ~]# hdparm -g /dev/sdb  #显示硬盘的布局信息
63 
64 /dev/sdb:
65  geometry      = 1305(柱面数)/255(磁头,heads)/63(每磁道的扇区数), sectors = 20971520(总的扇区数), start = 0(从第几个扇区开始)
66 [root@yinzhengjie ~]#
67 
68 '''
hdparm用法展示

 

13.挂载

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 挂载分类:
 9     手动挂载
10     按需挂载(autofs,这种效率比较低,当用的时候才去挂载,需要等待时间。)
11     开机自动挂载
12 
13 mount[options] -t 文件类型 -o option 设备 挂载点
14      [options] : 命令的选项
15            -n:不更新/etc/mtab文件
16            --bind:dir1 dir2 将目录挂载到目录上,使得dir2也能访问dir1的文件
17            -t fstype
18            -r 只读挂载
19            -w:读写挂载
20            -L lable 以卷标指定,也可以使用LABLE="lable"
21            -U UUID:使用UUID挂载,也可以使用 UUID="uuid"
22                -o options:挂载时启动分区特性
23                          async:异步I/O
24                          sync:同步I/O
25                          noatime/atime 是否更新文件时间戳,不是特别重要的文件,建议noatime
26                          auto: 是否能够被mount -a 自动挂载所有(/etc/fstab中)的文件自动挂载
27                          dev/nodev:是否能创建设备文件
28                          diratime/nodirtime:是否更新目录的时间戳
29                          exec/noexec:是否允许执行二进制程序
30                          _netdev:网络设备
31                          remount:重新挂载
32                          relatime/norelatime 是否实时更新
33                          acl 文件访问控制列表
34 
35 挂载点:挂载以后原始数据将被隐藏
36    1、选择空闲目录
37    2、必须事先存在
38 卸载:
39    1、空闲时可以卸载
40    2、其实也可以强行卸载
41 umount 设备|挂载点
42 
43 直接使用mount可以显示当前系统的挂载信息,也可以查看/proc/mounts或者/etc/mtab
44 
45 光盘:
46  /dev/cdrom /dev/dvdrom /dev/sr0
47  [-t iso9660]
48 '''
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# cat /proc/filesystems  #查看内核能识别的文件系统类型
 9 nodev   sysfs  #其中“nodev”表示非设备文件系统,即伪文件系统,后面的参数是“sysfs”。
10 nodev   rootfs
11 nodev   bdev
12 nodev   proc
13 nodev   cgroup
14 nodev   cpuset
15 nodev   tmpfs
16 nodev   devtmpfs
17 nodev   binfmt_misc
18 nodev   debugfs
19 nodev   securityfs
20 nodev   sockfs
21 nodev   usbfs
22 nodev   pipefs
23 nodev   anon_inodefs
24 nodev   inotifyfs
25 nodev   devpts
26 nodev   ramfs
27 nodev   hugetlbfs
28         iso9660  #这就是设备文件系统,光盘
29 nodev   pstore
30 nodev   mqueue
31 nodev   selinuxfs
32         ext4    #这个也是设备文件系统,前面没有“nodev”进行标识。
33 nodev   vmhgfs
34 nodev   fuse
35         fuseblk
36 nodev   fusectl
37 [root@yinzhengjie ~]#
38 '''
查看内核能识别的文件系统类型
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mkdir /yinzhengjie  #创建一个挂载目录
 9 [root@yinzhengjie ~]# mount   #查看当前的挂载信息
10 /dev/sda2 on / type ext4 (rw)
11 proc on /proc type proc (rw)
12 sysfs on /sys type sysfs (rw)
13 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
14 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
15 /dev/sda1 on /boot type ext4 (rw)
16 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
17 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
18 [root@yinzhengjie ~]# mount /dev/sdb1 /yinzhengjie/  #将第二块设备的第一个分区挂载到"/yinzhengjie"目录下。
19 [root@yinzhengjie ~]# 
20 [root@yinzhengjie ~]# mount   #再次查看挂载信息,发现多出来了最后一项
21 /dev/sda2 on / type ext4 (rw)
22 proc on /proc type proc (rw)
23 sysfs on /sys type sysfs (rw)
24 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
25 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
26 /dev/sda1 on /boot type ext4 (rw)
27 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
28 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
29 /dev/sdb1 on /yinzhengjie type ext4 (rw)  #发现了挂载的目录
30 [root@yinzhengjie ~]# ll /yinzhengjie/ #查看挂载点信息,出现了“lost+found”目录表示挂载成功
31 total 16
32 drwx------. 2 root root 16384 May 12 04:31 lost+found
33 [root@yinzhengjie ~]# cd /yinzhengjie/
34 [root@yinzhengjie yinzhengjie]# touch {1..5}.txt  #我们创建5个文件看看
35 [root@yinzhengjie yinzhengjie]# ll  #发现也能成功创建文件,文件名是存在挂载目录下的。
36 total 16
37 -rw-r--r--. 1 root root     0 May 12 04:36 1.txt
38 -rw-r--r--. 1 root root     0 May 12 04:36 2.txt
39 -rw-r--r--. 1 root root     0 May 12 04:36 3.txt
40 -rw-r--r--. 1 root root     0 May 12 04:36 4.txt
41 -rw-r--r--. 1 root root     0 May 12 04:36 5.txt
42 drwx------. 2 root root 16384 May 12 04:31 lost+found
43 [root@yinzhengjie yinzhengjie]# cd  #回到自己的家目录去
44 [root@yinzhengjie ~]# umount /yinzhengjie/  #卸载挂载点
45 [root@yinzhengjie ~]# mount  #再一次查看挂载信息,发现之前的挂载点不见了。
46 /dev/sda2 on / type ext4 (rw)
47 proc on /proc type proc (rw)
48 sysfs on /sys type sysfs (rw)
49 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
50 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
51 /dev/sda1 on /boot type ext4 (rw)
52 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
53 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
54 [root@yinzhengjie ~]# 
55 [root@yinzhengjie ~]# ll /yinzhengjie/  #发现这个目录的文件也没有了,原因是卸载成功了,数据还存在那块设备上。
56 total 0
57 [root@yinzhengjie ~]# 
58 '''
mount的基本使用展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# ll /yinzhengjie/  #查看目录为空。
 9 total 0
10 [root@yinzhengjie ~]# mount  #先查看挂载之前的信息
11 /dev/sda2 on / type ext4 (rw)
12 proc on /proc type proc (rw)
13 sysfs on /sys type sysfs (rw)
14 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
15 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
16 /dev/sda1 on /boot type ext4 (rw)
17 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
18 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
19 [root@yinzhengjie ~]#
20 [root@yinzhengjie ~]# tune2fs -L yinzhengjie /dev/sdb1  #给这个分区设置一个卷标名称。
21 tune2fs 1.41.12 (17-May-2010)
22 [root@yinzhengjie ~]# e2label /dev/sdb1 #查看这个卷标名称
23 yinzhengjie
24 [root@yinzhengjie ~]#
25 [root@yinzhengjie ~]# mount LABEL="yinzhengjie"  /yinzhengjie/  #把卷标名称为"yinzhengjie" 的设备挂载到“/yinzhengjie/”这个目录下来。
26 [root@yinzhengjie ~]# mount  #查看挂载后的信息
27 /dev/sda2 on / type ext4 (rw)
28 proc on /proc type proc (rw)
29 sysfs on /sys type sysfs (rw)
30 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
31 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
32 /dev/sda1 on /boot type ext4 (rw)
33 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
34 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
35 /dev/sdb1 on /yinzhengjie type ext4 (rw)  #这里有记录,说明挂载成功了。
36 [root@yinzhengjie ~]# ll /yinzhengjie/  #看一下挂载目录,果真是访问到了数据
37 total 16
38 -rw-r--r--. 1 root root     0 May 12 04:36 1.txt
39 -rw-r--r--. 1 root root     0 May 12 04:36 2.txt
40 -rw-r--r--. 1 root root     0 May 12 04:36 3.txt
41 -rw-r--r--. 1 root root     0 May 12 04:36 4.txt
42 -rw-r--r--. 1 root root     0 May 12 04:36 5.txt
43 drwx------. 2 root root 16384 May 12 04:31 lost+found
44 [root@yinzhengjie ~]#
45 '''
mount命令基于卷标挂载用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# ll /yinzhengjie/
 9 total 0
10 [root@yinzhengjie ~]#
11 [root@yinzhengjie ~]# mount  #查看挂载信息
12 /dev/sda2 on / type ext4 (rw)
13 proc on /proc type proc (rw)
14 sysfs on /sys type sysfs (rw)
15 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
16 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
17 /dev/sda1 on /boot type ext4 (rw)
18 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
19 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
20 [root@yinzhengjie ~]#
21 [root@yinzhengjie ~]# blkid /dev/sdb1  #先查看设备的UUID信息
22 /dev/sdb1: LABEL="yinzhengjie" UUID="768fe361-9425-4928-b2d9-641064d1052a" TYPE="ext4"
23 [root@yinzhengjie ~]# mount UUID="768fe361-9425-4928-b2d9-641064d1052a" /yinzhengjie/  #将上面查阅到的UUID=
24 "768fe361-9425-4928-b2d9-641064d1052a"赋值下来,它就是“/dev/sdb1”这块设备,我们将它挂载到"/yinzhengjie"目录下。
25 [root@yinzhengjie ~]#
26 [root@yinzhengjie ~]# mount  #查看挂载信息
27 /dev/sda2 on / type ext4 (rw)
28 proc on /proc type proc (rw)
29 sysfs on /sys type sysfs (rw)
30 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
31 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
32 /dev/sda1 on /boot type ext4 (rw)
33 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
34 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
35 /dev/sdb1 on /yinzhengjie type ext4 (rw)
36 [root@yinzhengjie ~]# ll /yinzhengjie/  #发现能够成功范围数据。
37 total 16
38 -rw-r--r--. 1 root root     0 May 12 04:36 1.txt
39 -rw-r--r--. 1 root root     0 May 12 04:36 2.txt
40 -rw-r--r--. 1 root root     0 May 12 04:36 3.txt
41 -rw-r--r--. 1 root root     0 May 12 04:36 4.txt
42 -rw-r--r--. 1 root root     0 May 12 04:36 5.txt
43 drwx------. 2 root root 16384 May 12 04:31 lost+found
44 [root@yinzhengjie ~]#
45 '''
mount命令基于UUID进行挂载用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mount  #查看挂载信息
 9 /dev/sda2 on / type ext4 (rw)
10 proc on /proc type proc (rw)
11 sysfs on /sys type sysfs (rw)
12 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
13 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
14 /dev/sda1 on /boot type ext4 (rw)
15 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
16 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
17 /dev/sdb1 on /yinzhengjie type ext4 (rw)  #发现这个设备的挂载的权限是"读写(rw)"模式
18 [root@yinzhengjie ~]#
19 [root@yinzhengjie ~]# mount -o remount,ro /dev/sdb1  #我们对其进行重新挂载,并将挂载后权限设置为只读模式。
20 [root@yinzhengjie ~]# mount
21 /dev/sda2 on / type ext4 (rw)
22 proc on /proc type proc (rw)
23 sysfs on /sys type sysfs (rw)
24 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
25 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
26 /dev/sda1 on /boot type ext4 (rw)
27 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
28 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
29 /dev/sdb1 on /yinzhengjie type ext4 (ro) #过着,权限变成了只读(ro)了。
30 [root@yinzhengjie ~]#
31 
32 '''
mount命令的remount重新挂载用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mount
 9 /dev/sda2 on / type ext4 (rw)
10 proc on /proc type proc (rw)
11 sysfs on /sys type sysfs (rw)
12 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
13 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
14 /dev/sda1 on /boot type ext4 (rw)
15 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
16 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
17 /dev/sdb1 on /yinzhengjie type ext4 (ro) #权限是只读
18 [root@yinzhengjie ~]# mount -o remount,rw,acl /dev/sdb1 #启用文件访问控制列表功能(acl)
19 [root@yinzhengjie ~]# mount
20 /dev/sda2 on / type ext4 (rw)
21 proc on /proc type proc (rw)
22 sysfs on /sys type sysfs (rw)
23 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
24 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
25 /dev/sda1 on /boot type ext4 (rw)
26 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
27 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
28 /dev/sdb1 on /yinzhengjie type ext4 (rw,acl) #发现真的有acl和rw权限了。
29 [root@yinzhengjie ~]#
30 
31 '''
mount命令启动acl功能用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# tune2fs -o acl /dev/sdb1  #给该分区添加ACL熟悉,让其挂载的时候默认就支持ACL
 9 tune2fs 1.41.12 (17-May-2010)
10 [root@yinzhengjie ~]# tune2fs -l /dev/sdb1 | grep ^D  #查看该分区信息
11 Default mount options:    acl  #我们发现是启用了acl功能的,在mount的选项的时候它会自动支持该参数。
12 Desired extra isize:      28
13 Default directory hash:   half_md4
14 Directory Hash Seed:      63cd7ef0-15f3-4e20-978a-82472a392459
15 [root@yinzhengjie ~]#
16 [root@yinzhengjie ~]# mount /dev/sdb1 /yinzhengjie/
17 [root@yinzhengjie ~]# mount
18 /dev/sda2 on / type ext4 (rw)
19 proc on /proc type proc (rw)
20 sysfs on /sys type sysfs (rw)
21 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
22 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
23 /dev/sda1 on /boot type ext4 (rw)
24 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
25 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
26 /dev/sdb1 on /yinzhengjie type ext4 (rw)  #注意这里尽管没有acl显示,但是它还是有acl属性的,因为那个分区本身就支持acl,是咱们给配置的。
27 [root@yinzhengjie ~]#
28     如果你想取消mount这个参数咋办呢?很简单,只要加一个“^”这个符号就好使了,如下:
29 [root@yinzhengjie ~]# tune2fs -o ^acl /dev/sdb1
30 tune2fs 1.41.12 (17-May-2010)
31 [root@yinzhengjie ~]# tune2fs -l /dev/sdb1 | grep ^D
32 Default mount options:    (none)  #发现该属性的确是没有啦!为空!
33 Desired extra isize:      28
34 Default directory hash:   half_md4
35 Directory Hash Seed:      63cd7ef0-15f3-4e20-978a-82472a392459
36 [root@yinzhengjie ~]#
37 '''
利用tune2fs给mount添加默认acl功能用法展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# mkdir -p /media/yinzhengjie/cdrom  #创建挂载点
 9 [root@yinzhengjie ~]# ls -l /dev/cdrom  #查看媒体文件所对应的链接
10 lrwxrwxrwx. 1 root root 3 May 12 02:38 /dev/cdrom -> sr0
11 [root@yinzhengjie ~]# ls -l /dev/sr0
12 brw-rw----+ 1 root cdrom 11, 0 May 12 02:38 /dev/sr0
13 [root@yinzhengjie ~]# ls -l /dev/dvd
14 lrwxrwxrwx. 1 root root 3 May 12 02:38 /dev/dvd -> sr0
15 [root@yinzhengjie ~]#
16 [root@yinzhengjie ~]# mount -o ro /dev/cdrom /media/yinzhengjie/cdrom/  #以只读(ro)的方式挂载,等价于:mount -r /dev/cdrom /media/yinzhengjie/cdrom/
17 [root@yinzhengjie ~]# mount
18 /dev/sda2 on / type ext4 (rw)
19 proc on /proc type proc (rw)
20 sysfs on /sys type sysfs (rw)
21 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
22 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
23 /dev/sda1 on /boot type ext4 (rw)
24 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
25 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
26 /dev/sdb1 on /yinzhengjie type ext4 (rw)
27 /dev/sr0 on /media/yinzhengjie/cdrom type iso9660 (ro)
28 [root@yinzhengjie ~]# ll /media/yinzhengjie/cdrom/
29 total 712
30 -r--r--r--. 2 root root     14 Oct 24  2014 CentOS_BuildTag
31 dr-xr-xr-x. 3 root root   2048 Oct 24  2014 EFI
32 -r--r--r--. 2 root root    212 Nov 27  2013 EULA
33 -r--r--r--. 2 root root  18009 Nov 27  2013 GPL
34 dr-xr-xr-x. 3 root root   2048 Oct 24  2014 images
35 dr-xr-xr-x. 2 root root   2048 Oct 24  2014 isolinux
36 dr-xr-xr-x. 2 root root 686080 Oct 24  2014 Packages
37 -r--r--r--. 2 root root   1354 Oct 19  2014 RELEASE-NOTES-en-US.html
38 dr-xr-xr-x. 2 root root   4096 Oct 24  2014 repodata
39 -r--r--r--. 2 root root   1706 Nov 27  2013 RPM-GPG-KEY-CentOS-6
40 -r--r--r--. 2 root root   1730 Nov 27  2013 RPM-GPG-KEY-CentOS-Debug-6
41 -r--r--r--. 2 root root   1730 Nov 27  2013 RPM-GPG-KEY-CentOS-Security-6
42 -r--r--r--. 2 root root   1734 Nov 27  2013 RPM-GPG-KEY-CentOS-Testing-6
43 -r--r--r--. 1 root root   3380 Oct 24  2014 TRANS.TBL
44 [root@yinzhengjie ~]#
45 '''
mount命令用只读的方式挂载光盘
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 [root@yinzhengjie ~]# umount /dev/sr0  #卸载给设备报错了
 9 umount: /media/yinzhengjie/cdrom: device is busy.
10         (In some cases useful info about processes that use
11          the device is found by lsof(8) or fuser(1))  #说是用lsof和fuser命令可以找到这个设备被谁使用
12 [root@yinzhengjie ~]#
13 [root@yinzhengjie ~]# fuser /media/yinzhengjie/cdrom/ #看一下是哪个进程再访问这个设备
14 /media/yinzhengjie/cdrom/:  2420c
15 [root@yinzhengjie ~]#
16 [root@yinzhengjie ~]# fuser -v /media/yinzhengjie/cdrom/  #查看详细信息,到底是哪个用户和对应的进程在访问该设备。
17                      USER        PID ACCESS COMMAND
18 /media/yinzhengjie/cdrom/:
19                      root       2420 ..c.. bash
20 [root@yinzhengjie ~]# who  #其实是我自己开了2个设备在测试呢!
21 root     pts/0        2017-05-12 03:08 (172.16.3.210)
22 root     pts/1        2017-05-12 05:42 (172.16.3.210)
23 [root@yinzhengjie ~]#
24 [root@yinzhengjie ~]# fuser -km /media/yinzhengjie/cdrom/  #将正在访问的该设备的用户踢出去。
25 /media/yinzhengjie/cdrom/:  2420c
26 [root@yinzhengjie ~]# who  #执行了上个命令,哪个用户就被提出终端了!
27 root     pts/1        2017-05-12 05:42 (172.16.3.210)
28 [root@yinzhengjie ~]# 
29 [root@yinzhengjie ~]# umount /dev/sr0  #再一次执行卸载,发现没有报错
30 [root@yinzhengjie ~]# mount   #也成功卸载掉了
31 /dev/sda2 on / type ext4 (rw)
32 proc on /proc type proc (rw)
33 sysfs on /sys type sysfs (rw)
34 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
35 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
36 /dev/sda1 on /boot type ext4 (rw)
37 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
38 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
39 [root@yinzhengjie ~]#
40 '''
umount卸载报错解决方案展示
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8     其实mount命令是通过“/proc/mounts[也是和内核相关的文件哟]”这个文件获取到当前系统上正在挂载的相关信息,只不过mount用了比较让我们易
 9 读的方式输出出来而已。
10 [root@yinzhengjie ~]# cat /proc/mounts
11 rootfs / rootfs rw 0 0
12 proc /proc proc rw,relatime 0 0
13 sysfs /sys sysfs rw,seclabel,relatime 0 0
14 devtmpfs /dev devtmpfs rw,seclabel,relatime,size=490820k,nr_inodes=122705,mode=755 0 0
15 devpts /dev/pts devpts rw,seclabel,relatime,gid=5,mode=620,ptmxmode=000 0 0
16 tmpfs /dev/shm tmpfs rw,seclabel,relatime 0 0
17 /dev/sda2 / ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
18 none /selinux selinuxfs rw,relatime 0 0
19 devtmpfs /dev devtmpfs rw,seclabel,relatime,size=490820k,nr_inodes=122705,mode=755 0 0
20 /proc/bus/usb /proc/bus/usb usbfs rw,relatime 0 0
21 /dev/sda1 /boot ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
22 none /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
23 vmware-vmblock /var/run/vmblock-fuse fuse.vmware-vmblock rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other 0 0
24 /dev/sdb1 /yinzhengjie ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
25 [root@yinzhengjie ~]#
26     我们知道mount命令可以让我们用来挂载以及查看相关相信,但是最终的数据存放在哪里呢?当然是要有一个配置文件了,其中“/etc/mtab ”就是一个用来存放
27 挂载信息的。
28 [root@yinzhengjie ~]# cat /etc/mtab
29 /dev/sda2 / ext4 rw 0 0
30 proc /proc proc rw 0 0
31 sysfs /sys sysfs rw 0 0
32 devpts /dev/pts devpts rw,gid=5,mode=620 0 0
33 tmpfs /dev/shm tmpfs rw,rootcontext="system_u:object_r:tmpfs_t:s0" 0 0
34 /dev/sda1 /boot ext4 rw 0 0
35 none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
36 vmware-vmblock /var/run/vmblock-fuse fuse.vmware-vmblock rw,nosuid,nodev,default_permissions,allow_other 0 0
37 /dev/sdb1 /yinzhengjie ext4 rw 0 0
38 [root@yinzhengjie ~]#
39     让我们来做个测试,我们卸载一个挂载点,看这个配置文件是否也发生变化。
40 [root@yinzhengjie ~]# umount /dev/sdb1  #我们卸载之前手动挂载的分区
41 [root@yinzhengjie ~]# cat /etc/mtab  #再次查看该配置文件,果不其然,随着mount命令将挂载信息删除了。
42 /dev/sda2 / ext4 rw 0 0
43 proc /proc proc rw 0 0
44 sysfs /sys sysfs rw 0 0
45 devpts /dev/pts devpts rw,gid=5,mode=620 0 0
46 tmpfs /dev/shm tmpfs rw,rootcontext="system_u:object_r:tmpfs_t:s0" 0 0
47 /dev/sda1 /boot ext4 rw 0 0
48 none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
49 vmware-vmblock /var/run/vmblock-fuse fuse.vmware-vmblock rw,nosuid,nodev,default_permissions,allow_other 0 0
50 [root@yinzhengjie ~]# 
51 '''
扩展:mount的前世今生

 

14.查看磁盘信息命令

a>.df 磁盘空间使用状态报告

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 [root@yinzhengjie ~]# df #默认是以KB为单位的
 8 Filesystem     1K-blocks    Used Available Use% Mounted on
 9 /dev/sda2       18208184 2504904  14771696  15% /
10 tmpfs             502172      72    502100   1% /dev/shm
11 /dev/sda1         289293   28473    245460  11% /boot
12 [root@yinzhengjie ~]# df -m  #以MB为空间
13 Filesystem     1M-blocks  Used Available Use% Mounted on
14 /dev/sda2          17782  2447     14426  15% /
15 tmpfs                491     1       491   1% /dev/shm
16 /dev/sda1            283    28       240  11% /boot
17 [root@yinzhengjie ~]# df -h  #将文件大小显示易读格式
18 Filesystem      Size  Used Avail Use% Mounted on
19 /dev/sda2        18G  2.4G   15G  15% /
20 tmpfs           491M   72K  491M   1% /dev/shm
21 /dev/sda1       283M   28M  240M  11% /boot
22 [root@yinzhengjie ~]# df -i  #显示inode数量
23 Filesystem      Inodes IUsed   IFree IUse% Mounted on
24 /dev/sda2      1164592 98347 1066245    9% /
25 tmpfs           125543     3  125540    1% /dev/shm
26 /dev/sda1        76912    38   76874    1% /boot
27 [root@yinzhengjie ~]# df -ih #划算成一度单位,注意下面的M或者K表示的不是文件的大小,而是表示的数字K=1000,M=1000000
28 Filesystem     Inodes IUsed IFree IUse% Mounted on
29 /dev/sda2        1.2M   97K  1.1M    9% /
30 tmpfs            123K     3  123K    1% /dev/shm
31 /dev/sda1         76K    38   76K    1% /boot
32 [root@yinzhengjie ~]# df -P  #全部显示,就是当Filesystem名称过长的时候,不会换行显示。
33 Filesystem     1024-blocks    Used Available Capacity Mounted on
34 /dev/sda2         18208184 2504908  14771692      15% /
35 tmpfs               502172      72    502100       1% /dev/shm
36 /dev/sda1           289293   28473    245460      11% /boot
37 [root@yinzhengjie ~]# df -Ph #将文件大小显示易读格式且每行信息不换行显示。
38 Filesystem      Size  Used Avail Use% Mounted on
39 /dev/sda2        18G  2.4G   15G  15% /
40 tmpfs           491M   72K  491M   1% /dev/shm
41 /dev/sda1       283M   28M  240M  11% /boot
42 [root@yinzhengjie ~]# df -Ph /dev/sda1  #可以单独查看一个分区情况。
43 Filesystem      Size  Used Avail Use% Mounted on
44 /dev/sda1       283M   28M  240M  11% /boot
45 [root@yinzhengjie ~]#
46 [root@yinzhengjie ~]# df -T     #显示时显示文件类型
47 Filesystem     Type  1K-blocks    Used Available Use% Mounted on
48 /dev/sda2      ext4   18208184 2504920  14771680  15% /
49 tmpfs          tmpfs    502172      72    502100   1% /dev/shm
50 /dev/sda1      ext4     289293   28473    245460  11% /boot
51 [root@yinzhengjie ~]#
52 '''

b>.du 显示文件占用磁盘的情况

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 [root@yinzhengjie ~]# ls -ldh /etc/  #查看目录大小,很明显不准确!
 8 drwxr-xr-x. 102 root root 4.0K May 12 05:48 /etc/
 9 [root@yinzhengjie ~]# du -s /etc/  #用du查看文件大小,默认为K.
10 39788   /etc/
11 [root@yinzhengjie ~]# du -sh /etc/  #用du查看目录大小,默认为M
12 39M     /etc/
13 [root@yinzhengjie ~]# du -sh /etc/sysconfig/network-scripts/ifcfg-eth0  #我们也可以查看文件的大小 
14 4.0K    /etc/sysconfig/network-scripts/ifcfg-eth0
15 [root@yinzhengjie ~]# 
16 
17 '''

 

15.开机自动挂载

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 开机自动挂载
 8    /etc/rc.d/rc.sysinit:系统初始化脚本
 9       其中一个功能:挂载/etc/fstab文件中定义的文件系统挂载点
10 [root@yinzhengjie ~]# cat  /etc/fstab
11 
12 #
13 # /etc/fstab
14 # Created by anaconda on Tue Apr 11 05:43:15 2017
15 #
16 # Accessible filesystems, by reference, are maintained under '/dev/disk'
17 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
18 #
19 UUID=421dd611-48a1-4a71-9f06-60605f68ef0d /                       ext4    defaults        1 1
20 UUID=003bdf87-a068-4553-b506-f174b1f82ed6 /boot                   ext4    defaults        1 2
21 UUID=1020e7eb-2f17-4a4d-b8bf-36776dcbf547 swap                    swap    defaults        0 0
22 tmpfs                   /dev/shm                tmpfs   defaults        0 0
23 devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
24 sysfs                   /sys                    sysfs   defaults        0 0
25 proc                    /proc                   proc    defaults        0 0
26 [root@yinzhengjie ~]#
27 我们看以下挂载的格式,从左往右一次又6列参数,那么这6列参数是啥意思呢?请看以下分析:
28 1>.要挂载的设备:设备文件、LABEL=”ladel” UUID
29 2>.挂载点:有的文件系统没有挂载点  swap没有挂载点,挂载点为swap
30 3>.文件系统类型:
31 4>.挂载选项:多个选项间使用逗号分隔
32 5>.转储频率:
33     0:从不备份
34     1:每日备份
35     2:每隔一天备份
36 6>.自检次序
37     1:首先自检,通常只能被/使用
38     2-9:顺序
39     0:从不自检
40 '''
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 [root@yinzhengjie ~]# vim + /etc/fstab  #编辑mount配置文件,并将光标移动在最后一行,“+”参数表示最后一行
 8 [root@yinzhengjie ~]# cat /etc/fstab  #在最后一行添加你需要开机挂载的设备和目录。
 9 
10 #
11 # /etc/fstab
12 # Created by anaconda on Tue Apr 11 05:43:15 2017
13 #
14 # Accessible filesystems, by reference, are maintained under '/dev/disk'
15 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
16 #
17 UUID=421dd611-48a1-4a71-9f06-60605f68ef0d /                       ext4    defaults        1 1
18 UUID=003bdf87-a068-4553-b506-f174b1f82ed6 /boot                   ext4    defaults        1 2
19 UUID=1020e7eb-2f17-4a4d-b8bf-36776dcbf547 swap                    swap    defaults        0 0
20 tmpfs                   /dev/shm                tmpfs   defaults        0 0
21 devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
22 sysfs                   /sys                    sysfs   defaults        0 0
23 proc                    /proc                   proc    defaults        0 0
24 /dev/sdb1               /yinzhengjie            ext4    defaults,acl    0 0  #这就是我们新加的一行。
25 [root@yinzhengjie ~]# mount     #查看当前挂载项。
26 /dev/sda2 on / type ext4 (rw)
27 proc on /proc type proc (rw)
28 sysfs on /sys type sysfs (rw)
29 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
30 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
31 /dev/sda1 on /boot type ext4 (rw)
32 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
33 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
34 [root@yinzhengjie ~]# mount -a  #重新加载“ /etc/fstab”把fstab里面没有挂载的信息进行挂载,其功效等同于重做操作系统时进行的自动挂载。或者执行“init 6”再查看配置文件是否生效。
35 [root@yinzhengjie ~]# mount  #再次查看当前挂载项。
36 /dev/sda2 on / type ext4 (rw)
37 proc on /proc type proc (rw)
38 sysfs on /sys type sysfs (rw)
39 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
40 tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
41 /dev/sda1 on /boot type ext4 (rw)
42 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
43 vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
44 /dev/sdb1 on /yinzhengjie type ext4 (rw,acl)  #发现最后一行多出了一行挂载信息。说明你操作成功了。
45 [root@yinzhengjie ~]#
46 
47 '''
修改 /etc/fstab配置文件进行开机自动挂载展示

 

16.查看内存空间使用状态

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 [root@yinzhengjie ~]# cat /proc/meminfo  #查看内存信息
 8 MemTotal:        1004348 kB
 9 MemFree:          671056 kB
10 Buffers:           18764 kB
11 Cached:           126240 kB
12 SwapCached:            0 kB
13 Active:           108700 kB
14 Inactive:         110672 kB
15 Active(anon):      74616 kB
16 Inactive(anon):     1184 kB
17 Active(file):      34084 kB
18 Inactive(file):   109488 kB
19 Unevictable:           0 kB
20 Mlocked:               0 kB
21 SwapTotal:       4136088 kB
22 SwapFree:        4136088 kB
23 Dirty:               164 kB
24 Writeback:             0 kB
25 AnonPages:         74376 kB
26 Mapped:            42396 kB
27 Shmem:              1440 kB
28 Slab:              75132 kB
29 SReclaimable:      15608 kB
30 SUnreclaim:        59524 kB
31 KernelStack:        1560 kB
32 PageTables:        10916 kB
33 NFS_Unstable:          0 kB
34 Bounce:                0 kB
35 WritebackTmp:          0 kB
36 CommitLimit:     4638260 kB
37 Committed_AS:     336672 kB
38 VmallocTotal:   34359738367 kB
39 VmallocUsed:      156112 kB
40 VmallocChunk:   34359567284 kB
41 HardwareCorrupted:     0 kB
42 AnonHugePages:     12288 kB
43 HugePages_Total:       0
44 HugePages_Free:        0
45 HugePages_Rsvd:        0
46 HugePages_Surp:        0
47 Hugepagesize:       2048 kB
48 DirectMap4k:        6144 kB
49 DirectMap2M:     1042432 kB
50 DirectMap1G:           0 kB
51 [root@yinzhengjie ~]# free -m  #其实free命令的数据时取自“/proc/meminfo”文件的,知识为了易读性可以用free -m参数查看内存使用情况
52              total       used       free     shared    buffers     cached
53 Mem:           980        325        655          1         18        123
54 -/+ buffers/cache:        183        797 #这一行才是正点,其他的都是虚的,实际使用内存为183,实际空余内存为797
55 Swap:         4039          0       4039
56 [root@yinzhengjie ~]# free -g  #这个参数是以GB为单位,列出磁盘中内存信息,空余查看内存比较大的时候用,如果你的内存不深就很少的话就会跟我一样出现下面的尴尬参数了。
57              total       used       free     shared    buffers     cached
58 Mem:             0          0          0          0          0          0
59 -/+ buffers/cache:          0          0
60 Swap:            3          0          3
61 [root@yinzhengjie ~]# 
62 
63 '''

 

17.dd命令常用参数展示:

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 dd命令:
 9    bs:一次读多大的数据量
10    count:读取次数
11    if:输入文件
12    of:输出文件
13    dd if=input_file of=output_file
14    dd if=input_file of=output_file bs=#[b|k|m|g] count=#
15    cat /dev/cdrom > /tmp/linux.iso #制作光盘
16 /dev/zero:吐01的
17 '''
 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 [root@yinzhengjie ~]# cat /etc/issue
 8 CentOS release 6.6 (Final)
 9 Kernel \r on an \m
10 
11 
12         This is Yin Zhengjie's server
13 
14 
15 
16 
17 
18 [root@yinzhengjie ~]# 
19 [root@yinzhengjie ~]# dd if=/etc/issue of=/tmp/issue.dd
20 0+1 records in #读了多少个
21 0+1 records out #输出了多少个
22 84 bytes (84 B) copied, 0.00011992 s, 700 kB/s  #多少字节被复制,一共花了多长时间,每秒钟传输数据的平局速度。
23 [root@yinzhengjie ~]# cat /tmp/issue.dd  #查看内容的确被复制
24 CentOS release 6.6 (Final)
25 Kernel \r on an \m
26 
27 
28         This is Yin Zhengjie's server
29 
30 
31 
32 
33 
34 [root@yinzhengjie ~]#
35 
36 
37 '''
利用dd拷贝文件效率要高与cp命令

  其实dd相比cp是一个更低级的命令,跟语言一样,语言越高级越接近用户,处理速度就越慢,语言越低级就越接近机器,处理速度就越快,那么为什么dd命令处理速度要相比cp更快呢?其实很简单,cp命令才拷贝文件的时候,先通过VFS系统(即虚拟文件系统)将源数据通通的读取出来,然后在将这些数据传给VFS,并通过文件系统在重新生成一份一模一样的数据才完成了拷贝功能,但是dd命令就不一样了,他绕过了VFS系统,直接找到源数据的inode所对应的blocks,直接将这些blocks内存中拷贝一份,这就是两者的差距。

                 

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 '''
 7 [root@yinzhengjie ~]# dd if=/dev/zero of=/yinzhengjie.swapfile bs=1M count=100  #创建一个100M的文件
 8 100+0 records in
 9 100+0 records out
10 104857600 bytes (105 MB) copied, 0.145994 s, 718 MB/s
11 [root@yinzhengjie ~]#
12 [root@yinzhengjie ~]# ll -h / | grep yinzhengjie  #验证文件是否创建成功
13 drwxr-xr-x.   3 root root 4.0K May 12 04:36 yinzhengjie
14 -rw-r--r--.   1 root root 100M May 12 10:46 yinzhengjie.swapfile  #发现有这个100M的文件
15 [root@yinzhengjie ~]#
16 [root@yinzhengjie ~]# mkswap -f /yinzhengjie.swapfile #强制将这个文件格式化成交换分区
17 Setting up swapspace version 1, size = 102396 KiB
18 no label, UUID=f5896342-dd1f-4980-8806-2086ae3fec90
19 [root@yinzhengjie ~]# free -m  #先查看内存信息
20              total       used       free     shared    buffers     cached
21 Mem:           980        890         90          1        451        227
22 -/+ buffers/cache:        212        768
23 Swap:         4039          0       4039 #我们发现现在的total=4039
24 [root@yinzhengjie ~]# swapon /yinzhengjie.swapfile #开启这个文件的交换分区
25 [root@yinzhengjie ~]# free -m #发现果然多了100M的swap分区
26              total       used       free     shared    buffers     cached
27 Mem:           980        890         90          1        451        227
28 -/+ buffers/cache:        212        768
29 Swap:         4139          0       4139  #我们发现现在的total=4139
30 [root@yinzhengjie ~]# 
31 '''
利用dd命令创建一个swap分区文件,但是不到玩不得不要用!

以下是dd生产环节中常用的几个案例:

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 '''
 8 linux制作光盘的2种方式:
 9 [root@yinzhengjie ~]# dd if=/dev/cdrom of=/yinzhengjie/linux.iso                #利用dd命令制作光盘,方法一
10 [root@yinzhengjie ~]# cat /dev/cdrom > /yinzhengjie/linux.iso                   #利用cat命令制作光盘,方法二
11 linux中的磁盘对拷贝:
12 [root@yinzhengjie ~]# dd if=/dev/sda of=/dev/sdb                                #即将/dev/sda设备的信息拷贝一份到/dev/sdb上去。
13 [root@yinzhengjie ~]# dd if=/dev/sda of=/tmp/myfile bs=512 count=1              #讲/dev/sda的MBR分区进行备份,当分区表破坏时,可以用/tmp/myfile进行还原。
14 [root@yinzhengjie ~]# dd if=/dev/zero of=/dev/sdb bs=512 count=1                #删除/dev/sdb的分区信息,当然里面的数据还是可以找回来的,可以通过专业的数据恢复工具。
15 [root@yinzhengjie ~]# dd if=/dev/zero of=/yinzhengjie.swapfile bs=1M count=100  #创建一个100M的本地回环设备,可以用来做分区格式化的(当然得需要一些额外的操作)
16 '''
17 
18 #这里只是dd命令的冰山一角,想要了解dd命令更多的用法,请参考man帮助,在哪里或许你能找到你感兴趣的参数。

 

18.巧记归档命令

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4%E4%B9%8B%E8%B7%AF/
 5 #EMAIL:y1053419035@qq.com
 6 
 7 
 8 '''
 9 文件链接
10    ln 源文件 目标文件
11     硬链接:
12          不能跨分区,
13      指向同一个indone的两个位置
14          不能对目录创建硬链接
15      硬链接会改变文件被链接的次数
16     符号链接:
17         ln -s
18      符号链接可以跨分区
19      符号链接文件跟源文件不同一个inode
20      可以对目录创建符号链接
21      符号链接不会改变源文件被链接的次数
22 
23 
24 dev 第一个表示主设备号 第二个表示次设备号
25 
26 压缩工具
27    zip:
28    gzip:gunzip= gzip -d,zcat
29    后缀:.gz
30    -c 指定要压缩的文件
31    bzip2,bunzip2
32    -k 保留源文件
33    后缀 .bz
34    xz
35      后缀.xz
36    -#:指定压缩比 1-9,默认的为6
37 
38 
39 归档工具:
40    tar [options] file.tar file1....
41     -c:创建归档
42     -x:展开归档
43     -t:不展开而直接查看被归档的文件
44     -z:使用gzip压缩
45     -j:使用bz2压缩
46     -J:使用xz压缩
47 
48 
49 '''

 

 

posted @ 2017-05-11 13:42  尹正杰  阅读(7083)  评论(0编辑  收藏  举报