码迷,mamicode.com
首页 > 其他好文 > 详细

11-磁盘管理

时间:2017-02-19 15:45:45      阅读:322      评论:0      收藏:0      [点我收藏+]

标签:height   number   cancel   logic   无限   管理   企业   自己   多个   

第1章 磁盘介绍

1.1 磁盘管理总概括图

技术分享

1.2 磁盘接口类型

1.2.1 SSD固态磁盘接口类型

1. SATA接口,SATA,SATA2.0 SATA3.0

2. PATA(IDE接口)

3. PCI-E接口,mSATA、m.2、PCIE(IDE)

项目

固态磁盘

传统机械磁盘

容量

较小

价格

随机存取

极快

一般

写入次数

SLC:10万次

MLC:1万次

特质的可以达到100-200万次

无限制

盘内阵列

极难

工作噪音

工作温度

极低

较明显

防震

很好

较差

数据恢复

重量

技术分享

磁盘相关名字翻译

disk 磁盘
head 磁头
sector 扇区
track 磁道
cylinder 柱面
units 单元块
block 数据块
inode 索引节点

1.2.2 磁道柱面扇区总括

磁盘最基本的u成部分是由坚硬的金属材料制成的涂以磁性介质的盘片(数层),不同容量磁盘的盘片不等

要点:

1. 一块磁盘有2-14个盘片,每个盘片有两个面,每个面对应一个读写磁头,用磁头号来区分盘面,即盘面数就是磁头数,盘片数*2=磁头数(盘面数)

2. 不同盘面的磁道被划分为多个扇形区域,每个区域就是一个扇区(Sector)

3. 同一个盘面,以盘片中心为圆心,每个不同半径的圆形轨迹就是一个磁道(Track)

4. 不同盘面相同半径的磁道组成一个圆柱面就是柱面(Cylinder)

5. 一个柱面包含多个磁道(半径相同),一个磁道包含多个扇区

6. 数据信息记录可表示为:某磁头,某磁道(柱面),某扇区

1.2.3 容量计算

[root@AIGE ~]# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0002edd7

Device Boot Start End Blocks Id System

[root@AIGE ~]# awk ‘BEGIN{print 255*63*1044*512/1000/1000}‘

8587.19 算容量

1.2.4 机械磁盘读写磁盘数据的原理小结

1. 磁盘是按照柱面为单位读写数据的,即先读取同一个盘面的某一个磁道,读完之后,如果数据没有读完,磁头也不会切换其他的磁道,而是选择切换磁头,读取下一个盘面的相同半径的磁道,直到所有盘面的相同半径的磁道读取完成之后,如果数据还没有读写完成,才会切换其他不同半径磁道,这个切换磁道的过程称为寻道。

2. 不同磁头间的切换是电子切换,而不同的磁道间的切换需要磁头做径向运动。这个径向运动需要步进电机调节,这个动作是机械的切换。

磁头寻道是机械运动,切换磁头是电子切换

第2章 文件系统

2.1 磁盘分区的重点

1)给磁盘分区的实质就是针对0磁头0磁道1扇区的前446字节后面接下来的64bytes的分区表进行设置,即主要是划分起始以及结束磁头号,扇区号及柱面号

2)给磁盘分区工具有fdisk(适合给小于2T的磁盘分区,适合mbr分区表),parted(擅长给大于2T的磁盘分区,可以对小于2T的磁盘分区,适合gpt格式分区表)

企业面试题:一台服务器6块600G的磁盘,raid5后,总大小3T,此时无法装系统。为什么?

解决方法:

法1:做raid后,不要重装系统,而是再raid界面继续分1个小的虚拟盘vd200G,用这个200G的虚拟磁盘装系统,装完系统后再把剩余的2.8T分区(通过parted)

法2:先拿1块盘做taid0,剩下5块再做raid5,在raid0上装系统

法3:装系统时(C6.8),会默认变化分区表为gpt即可安装系统

3)一块磁盘的分区表仅有64个bytes大小,每个分区表要占用16个字节,因此一块磁盘仅支持四个分区表信息,即主分区+扩展分区的总量不超过4个

4)磁盘分区是按照柱面来划分的

5)扩展分区不能直接使用的,还需要子啊扩展分区的基础上创建逻辑分区才行

6)扩展分区有自己的分区表,因此,扩展分区下面的逻辑分区可以多个。

2.2 磁盘分区注意事项要点。

一块硬盘的分区方式只能为如下组合:

PPPE、PPE、PE、PPPP(即无法扩展,剩余空间浪费)

2.3 分区

技术分享
  1 [root@can ~]# fdisk /dev/sdb
  2 Command (m for help): m
  3 Command action
  4 a toggle a bootable flag
  5 b edit bsd disklabel
  6 c toggle the dos compatibility flag
  7 d delete a partition (删除一个分区)
  8 l list known partition types (查看分区类型对应编号列表)
  9 m print this menu (打印此帮助菜单)
 10 n add a new partition (新建一个分区)
 11 o create a new empty DOS partition table
 12 p print the partition table (打印分区表)
 13 q quit without saving changes (退出程序,不保存)
 14 s create a new empty Sun disklabel
 15 t change a partition‘s system id (更改分区类型)
 16 u change display/entry units
 17 v verify the partition table
 18 w write table to disk and exit (将操作写入分区表并退出程序)
 19 x extra functionality (experts only)
 20 [root@Can ~]# fdisk /dev/sdb
 21 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
 22 Building a new DOS disklabel with disk identifier 0x267db449.
 23 Changes will remain in memory only, until you decide to write them.
 24 After that, of course, the previous content won‘t be recoverable.
 25 Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 26 WARNING: DOS-compatible mode is deprecated. It‘s strongly recommended to
 27 switch off the mode (command ‘c‘) and change display units to
 28 sectors (command ‘u‘).
 29 Command (m for help): n
 30 Command action
 31 e extended
 32 p primary partition (1-4)
 33 p
 34 Partition number (1-4): 1
 35 First cylinder (1-130, default 1):
 36 Using default value 1
 37 Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +100M
 38 Command (m for help): p
 39 Disk /dev/sdb: 1073 MB, 1073741824 bytes
 40 255 heads, 63 sectors/track, 130 cylinders
 41 Units = cylinders of 16065 * 512 = 8225280 bytes
 42 Sector size (logical/physical): 512 bytes / 512 bytes
 43 I/O size (minimum/optimal): 512 bytes / 512 bytes
 44 Disk identifier: 0x267db449
 45 Device Boot Start End Blocks Id System
 46 /dev/sdb1 1 14 112423+ 83 Linux
 47 Command (m for help): n
 48 Command action
 49 e extended
 50 p primary partition (1-4)
 51 e
 52 Partition number (1-4): 2
 53 First cylinder (1-130, default 1): ^C
 54 [root@Can ~]# fdisk /dev/sdb
 55 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
 56 Building a new DOS disklabel with disk identifier 0x07986e9f.
 57 Changes will remain in memory only, until you decide to write them.
 58 After that, of course, the previous content won‘t be recoverable.
 59 Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 60 WARNING: DOS-compatible mode is deprecated. It‘s strongly recommended to
 61 switch off the mode (command ‘c‘) and change display units to
 62 sectors (command ‘u‘).
 63 Command (m for help): n
 64 Command action
 65 e extended
 66 p primary partition (1-4)
 67 p
 68 Partition number (1-4): 1
 69 First cylinder (1-130, default 1):
 70 Using default value 1
 71 Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +100M
 72 Command (m for help): n
 73 Command action
 74 e extended
 75 p primary partition (1-4)
 76 e
 77 Partition number (1-4): 2
 78 First cylinder (15-130, default 15):
 79 Using default value 15
 80 Last cylinder, +cylinders or +size{K,M,G} (15-130, default 130):
 81 Using default value 130
 82 Command (m for help): n
 83 Command action
 84 l logical (5 or over)
 85 p primary partition (1-4)
 86 l
 87 First cylinder (15-130, default 15):
 88 Using default value 15
 89 Last cylinder, +cylinders or +size{K,M,G} (15-130, default 130): +400M
 90 Command (m for help): p
 91 Disk /dev/sdb: 1073 MB, 1073741824 bytes
 92 255 heads, 63 sectors/track, 130 cylinders
 93 Units = cylinders of 16065 * 512 = 8225280 bytes
 94 Sector size (logical/physical): 512 bytes / 512 bytes
 95 I/O size (minimum/optimal): 512 bytes / 512 bytes
 96 Disk identifier: 0x07986e9f
 97 Device Boot Start End Blocks Id System
 98 /dev/sdb1 1 14 112423+ 83 Linux
 99 /dev/sdb2 15 130 931770 5 Extended
100 /dev/sdb5 15 66 417658+ 83 Linux
101 Command (m for help): n
102 Command action
103 l logical (5 or over)
104 p primary partition (1-4)
105 1^Hl
106 Invalid partition number for type `1‘
107 Command action
108 l logical (5 or over)
109 p primary partition (1-4)
110 l
111 First cylinder (67-130, default 67):
112 Using default value 67
113 Last cylinder, +cylinders or +size{K,M,G} (67-130, default 130):
114 Using default value 130
115 Command (m for help): p
116 Disk /dev/sdb: 1073 MB, 1073741824 bytes
117 255 heads, 63 sectors/track, 130 cylinders
118 Units = cylinders of 16065 * 512 = 8225280 bytes
119 Sector size (logical/physical): 512 bytes / 512 bytes
120 I/O size (minimum/optimal): 512 bytes / 512 bytes
121 Disk identifier: 0x07986e9f
122 Device Boot Start End Blocks Id System
123 /dev/sdb1 1 14 112423+ 83 Linux
124 /dev/sdb2 15 130 931770 5 Extended
125 /dev/sdb5 15 66 417658+ 83 Linux
126 /dev/sdb6 67 130 514048+ 83 Linux
127 Command (m for help): w
128 The partition table has been altered!
129 Calling ioctl() to re-read partition table.
130 Syncing disks.
131 partprobe (告诉内核分区表发生变化)
132 partprobe /dev/sdb/
133 格式化:
134 mkfs.ext4 /dev/sdb1
135 tune2fs -c -1 /dev/sdb1
136 mount /dev/sdb1 /mnt
137 parted
138 [root@Can ~]# parted /dev/sdb
139 GNU Parted 2.1
140 使用 /dev/sdb
141 Welcome to GNU Parted! Type ‘help‘ to view a list of commands.
142 (parted) p
143 Model: VMware, VMware Virtual S (scsi)
144 Disk /dev/sdb: 1074MB
145 Sector size (logical/physical): 512B/512B
146 Partition Table: msdos
147 Number Start End Size Type File system 标志
148 1 32.3kB 115MB 115MB primary ext4
149 2 115MB 1069MB 954MB extended
150 5 115MB 543MB 428MB logical
151 6 543MB 1069MB 526MB logical
152 (parted) rm 1
153 (parted) rm 2
154 (parted) p
155 Model: VMware, VMware Virtual S (scsi)
156 Disk /dev/sdb: 1074MB
157 Sector size (logical/physical): 512B/512B
158 Partition Table: msdos
159 Number Start End Size Type File system 标志
160 (parted) mklabel gpt
161 警告: The existing disk label on /dev/sdb will be destroyed and all data on this disk will
162 be lost. Do you want to continue?
163 是/Yes/否/No? yes
164 (parted) p
165 Model: VMware, VMware Virtual S (scsi)
166 Disk /dev/sdb: 1074MB
167 Sector size (logical/physical): 512B/512B
168 Partition Table: gpt
169 Number Start End Size File system Name 标志
170 (parted) mkpart primary 0 500
171 警告: The resulting partition is not properly aligned for best performance.
172 忽略/Ignore/放弃/Cancel? ignore
173 (parted) p
174 Model: VMware, VMware Virtual S (scsi)
175 Disk /dev/sdb: 1074MB
176 Sector size (logical/physical): 512B/512B
177 Partition Table: gpt
178 Number Start End Size File system Name 标志
179 1 17.4kB 500MB 500MB primary
180 (parted) mkpart logical 501 1000
181 (parted) p
182 Model: VMware, VMware Virtual S (scsi)
183 Disk /dev/sdb: 1074MB
184 Sector size (logical/physical): 512B/512B
185 Partition Table: gpt
186 Number Start End Size File system Name 标志
187 1 17.4kB 500MB 500MB primary
188 2 501MB 1000MB 499MB logical
189 (parted) quit
190 信息: You may need to update /etc/fstab.
191 格式化,挂载
192 非交互式
193 parted /dev/sdb mklabel gpt
194 parted /dev/sdb mkpart primary 0 500
195 parted /dev/sdb mkpart primary 501 1000
196 parted /dev/sdb p
197 mkfs -t ext4 /dev/sdb1 /dev/sdb2
198 mount /dev/sdb2 /tmp
199 
view code

11-磁盘管理

标签:height   number   cancel   logic   无限   管理   企业   自己   多个   

原文地址:http://www.cnblogs.com/can-H/p/6415835.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!