第1章 RAID 磁盘阵列

1.1 使用raid的目的

1)获得更大的容量

2)让数据更安全

3)读写速度更快

1.2 raid0、raid1、raid5、raid10对比

raid类型

数量

优点

缺点

使用类型

raid0 条带

至少1块硬盘。

把所有硬盘的容量加在一起,读写速度更快

一块硬盘损坏,整体都不能使用

数据不是很重要,追求性能

数据库的从库

集群的某个节点

raid1 镜像

只能是两块硬盘

安全,有100%的冗余

写入速度比较慢

读取还可以

成本较高

对数据安全要求比较高,不需要太多的性能

raid5

至少三块硬盘

有奇偶校验,有一定的冗余,最多损坏1块硬盘 损失一块硬盘的容量

读取性能可以

写入很慢

比较通用。

+spare

可以作为热备

raid10

最少4块硬盘

数量必须是偶数

读写的速度都很快,安全性较高冗余,最多可以损坏一半

成本高

容量浪费一半

数据库

重要的文件

第2章 磁盘分区

2.1 mbr是什么

mbr引导:主引导记录

2.1.1 mbr在哪里

磁盘的0磁头 0磁道 1扇区 前446字节

一个扇区的大小为512字节

前446字节    mbr

中间64字节   分区表

最后2字节    分区结束表示55AA

2.1.2 分区表

在分区表的64字节里,划分为4个格子 16*4

每个格子里存放的是分区的信息(主分区 扩展分区)

2.1.3 如何查看磁盘第一个扇区里的内容

拿出出来前512个字节

[root@znix ~]# dd if=/dev/sda of=/tmp/512.bin bs=512 count=1

1+0 records in

1+0 records out

512 bytes (512 B) copied, 0.000190527 s, 2.7 MB/s

看下文件的类型

[root@znix ~]# file /tmp/512.bin

/tmp/512.bin: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, boot drive 0x80, 1st sector stage2 0x6280, GRUB version 0.94; partition 1: ID=0x83, active, starthead 32, startsector 2048, 409600 sectors; partition 2: ID=0x82, starthead 159, startsector 411648, 1572864 sectors; partition 3: ID=0x83, starthead 135, startsector 1984512, 18987008 sectors, code offset 0x48

2.1.4 如何查看二进制文件的内容

od命令查看二进制文件的内容

[root@znix ~]#   od -xa /tmp/512.bin

……

0000760    0000    0000    0000    0000    0000    0000    0000    aa55   结束标识符

nul nul nul nul nul nul nul nul nul nul nul nul nul nul   U   *

0001000

2.2 主分区、扩展分区、逻辑分区的关系

2.2.1 主分区

最多有4个主分区

2.2.2 扩展分区

没有办法直接使用 ,需要划分成逻辑分区才可以使用。

2.2.3 逻辑分区

必须要在扩展分区下面划分逻辑分区才可以使用。

逻辑分区

sas/sata/scsi/ 中为 sda  5-15

2.3 在系统中磁盘分区的命名

磁盘设备都放在/dev/目录下

sas/sata/scsi/接口     sd 开头

ide 接口               hd开头

2.3.1 磁盘名称示例

第一块硬盘 sda

第二块硬盘 sdb

第三块硬盘 sdc

2.3.2 第一块硬盘 sda

主分区 1-4

扩展分区 1-4 一般为4

逻辑分区 从5+开始

2.3.3 分区的命名规则

第一块硬盘的第一个主分区:sda1

第一块硬盘的第一个逻辑分区:sda5

第二块硬盘的第二个逻辑分区:sdb6

2.4 回顾分区方式

2.4.1 没有重要数据

/boot   200M    存放系统的引导信息 内核

swap   交换分区   防止内存用光了 临时的一个内存

如果你的内存小于8G swap是内存的1.5倍   如果你的内存大于8G swap给8G

/        根分区 剩余多少给多少

2.4.2 很多重要数据

/boot   200M    存放系统的引导信息 内核

swap   交换分区   防止内存用光了 临时的一个内存

如果你的内存小于8G swap是内存的1.5倍   如果你的内存大于8G swap给8G

/         根分区              20G-200G

/data  存放重要的数据 剩余多少给多少

2.4.3 不知道数据是否重要

/boot   200M    存放系统的引导信息 内核

swap   交换分区   防止内存用光了 临时的一个内存

如果你的内存小于8G swap是内存的1.5倍   如果你的内存大于8G swap给8G

/         根分区              20G-200G

剩余空间不分 放着谁使用这台服务器谁来分区

2.5 ps 命令内容详解--每列的含义

2.5.1 ps aux 中的vsz与rss

[root@znix shm]# ps aux

USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

root          1  0.0  0.2  19352  1300 ?        Ss   Sep14   0:01 /sbin/ini

用户     进程号  CPU  内存

⚠VSZ 进程所占用的虚拟内存的大小(物理内存+swap)

⚠RSS 进程所占用的内存(物理内存)

2.5.2 ps -ef 列含义系简介

[root@znix shm]# ps -ef

UID         PID   PPID    C STIME TTY        TIME   CMD

root          1      0    0 Sep14 ?      00:00:01   /sbin/init

用户名    进程号 子进程号                          运行了什么命令

第3章 磁盘分区

3.1 linux里面的分区工具

fdisk   主要是给磁盘小于2T(只能出来分区表是mbr的)

parted  主要是给磁盘大于2T(gpt)

3.2 通过fdisk给磁盘进行分区(创建一个10M主分区和一个40M逻辑分区)

3.2.1 使用fdisk会提示一个错误

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

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x31dcd35a.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

警告 : 可以关闭dos的兼容模式,使用扇区作为分区的默认单位  -cu ↓

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

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

sectors (command 'u').

Command (m for help):

3.2.2 fdisk添加上了 -cu 参数

-cu 参数是在分区的时候,能够以扇区的方式进行。

[root@znix ~]# fdisk -cu /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xb9f506a4.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help):

3.2.3 查看fdisk的帮助信息

Command (m for help): m

Command action

d   delete a partition            删除一个分区

m   print this menu               显示帮助菜单

n   add a new partition           创建一个分区

p   print the partition table     显示分区表

q   quit without saving changes   退出不保存

w   write table to disk and exit  保存并退出

3.2.4 创建一个主分区

Command (m for help): n

Command action

e   extended       扩展分区

p   primary partition (1-4)  主分区

p

Partition number (1-4): 1    第一个分区

First sector (2048-208895, default 2048): 直接回车为默认

Using default value 2048  默认选择第一个扇区

Last sector, +sectors or +size{K,M,G} (2048-208895, default 208895): +10M

3.2.5 显示一下分出来的分区

Command (m for help): p

Disk /dev/sdb: 106 MB, 106954752 bytes

64 heads, 32 sectors/track, 102 cylinders, total 208896 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0xb9f506a4

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048       22527       10240   83

3.2.6 创建一个扩展分区

扩展分区的分区原则是:剩多少给多少

Command (m for help): n

Command action

e   extended  扩展分区

p   primary partition (1-4)

e

Partition number (1-4): 2

First sector (22528-208895, default 22528):

Using default value 22528

Last sector, +sectors or +size{K,M,G} (22528-208895, default 208895):

Using default value 208895

3.2.7 显示现在的分区表信息

Command (m for help): p

Disk /dev/sdb: 106 MB, 106954752 bytes

64 heads, 32 sectors/track, 102 cylinders, total 208896 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0xb9f506a4

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048       22527       10240   83  Linux

/dev/sdb2           22528      208895       93184    5  Extended

3.2.8 在拓展分区下创建逻辑分区

Command (m for help): n

Command action

l   logical (5 or over)  逻辑分区,创建完扩展分区后只能创建逻辑分区

p   primary partition (1-4)

l

First sector (24576-208895, default 24576):

Using default value 24576

Last sector, +sectors or +size{K,M,G} (24576-208895, default 208895): +40M

3.2.9 显示一下当前的分区表

Command (m for help): p

Disk /dev/sdb: 106 MB, 106954752 bytes

64 heads, 32 sectors/track, 102 cylinders, total 208896 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0xb9f506a4

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048       22527       10240   83  Linux

/dev/sdb2           22528      208895       93184    5  Extended

/dev/sdb5           24576      106495       40960   83  Linux

3.2.10 保存并退出

fdisk 必须保存以后才能生效,w为保存并退出

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

3.3 【示例】添加一块硬盘sdb 100m划分一个分区 ,挂载到/mnt目录

3.3.1 第一步 创建一个主分区

[root@znix ~]# fdisk -cu /dev/sdb

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 1

First sector (2048-208895, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-208895, default 208895):

Using default value 208895

都选择默认就是使用整块盘的空间创建一个分区

3.3.2 显示当前的分区表

Command (m for help): p

Disk /dev/sdb: 106 MB, 106954752 bytes

64 heads, 32 sectors/track, 102 cylinders, total 208896 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0xb9f506a4

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      208895      103424   83  Linux

3.3.3 保存并退出

fdisk 必须保存以后才能生效,w为保存并退出

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

3.3.4 第二步 格式化创建文件系统

mkfs ==make filesystem即创建文件系统。

[root@znix ~]# mkfs.ext4 /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)  #block的大小

Fragment size=1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks

25896 inodes, 103424 blocks   #inode与block的数量

5171 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=67371008

13 block groups

8192 blocks per group, 8192 fragments per group

1992 inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961, 57345, 73729

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or

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

3.3.5 第三步 关闭分区的自我检查

tune2fs 命令

-c 挂载多少次 0 为关闭

-i 隔多长时间 0 为关闭

[root@znix ~]# tune2fs -c 0 -i 0 /dev/sdb1

tune2fs 1.41.12 (17-May-2010)

Setting maximal mount count to -1

Setting interval between checks to 0 seconds

3.3.6 第四步 挂载磁盘

[root@znix ~]# mount /dev/sdb1 /mnt/

[root@znix ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3       8.8G  1.9G  6.5G  23% /

tmpfs           238M     0  238M   0% /dev/shm

/dev/sda1       190M   40M  141M  22% /boot

/dev/sdb1        94M  1.6M   88M   2% /mnt

3.3.7 第五步 让磁盘永久挂载 开机自动挂载

两个文件可以实现:

/etc/rc.local

/etc/fstab

在/etc/rc.local文件中,写入什么命令都可以执行。

3.3.8 /etc/fstab 文件的内容

[root@znix ~]# cat /etc/fstab

#

# /etc/fstab

# Created by anaconda on Thu Aug 10 18:33:48 2017

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

UUID=49bad9e9-cf33-4a15-ba84-4fd28e70bd29 /                       ext4    defaults        1 1

UUID=7426d0f3-56d6-4fa6-a1c3-f2c8632bfbb8 /boot                   ext4    defaults        1 2

UUID=46bc0a52-b13f-4845-8baa-90207849d5c5 swap                    swap    defaults        0 0

tmpfs           /dev/shm    tmpfs            defaults         0                0

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

sysfs           /sys        sysfs            defaults         0                0

proc            /proc       proc             defaults         0                0

磁盘分区设备    挂载点      文件系统的类型   挂载参数   是否进行dump备份 是否进行fsk磁盘检查

3.3.9 将挂载信息写入配置文件

[root@znix ~]# tail -1 /etc/fstab

/dev/sdb1              /mnt                    ext4    defaults        0 0

3.3.10 显示系统中的uuid

使用blkid 命令可以查看系统磁盘的uuid

[root@znix ~]# blkid

/dev/sda3: UUID="49bad9e9-cf33-4a15-ba84-4fd28e70bd29" TYPE="ext4"

/dev/sda1: UUID="7426d0f3-56d6-4fa6-a1c3-f2c8632bfbb8" TYPE="ext4"

/dev/sda2: UUID="46bc0a52-b13f-4845-8baa-90207849d5c5" TYPE="swap"

/dev/sdb1: UUID="7101630b-b325-49d1-92b9-0a500c2a07f6" TYPE="ext4"

3.4 在挂载磁盘的时候出现未格式化错误

对磁盘进行一些操作的时候可能会提示没有格式化磁盘,需要格式化。

[root@znix ~]# tune2fs -c0 -i0 /dev/sdc

tune2fs 1.41.12 (17-May-2010)

tune2fs: Bad magic number in super-block while trying to open /dev/sdc

Couldn't find valid filesystem superblock.

没有找到可用的文件系统

磁盘管理之 raid 文件系统 分区相关推荐

  1. 【操作系统/OS笔记20】打开文件、文件数据块分配、空闲空间管理、多磁盘管理(RAID)、磁盘调度算法概述

    本次笔记内容: 12.12 打开文件的数据结构 12.13 文件的分配 12.14 空闲空间列表 12.15 多磁盘管理-RAID 12.16 磁盘调度 文章目录 打开文件 何谓"打开文件& ...

  2. linux磁盘管理、格式化、分区

    磁盘管理 名词:DISK 磁盘.硬盘 磁盘作用:存储数据 种类:机械硬盘.固态硬盘 命名:SATA(串口)1./dev/sda 2./dev/sdb 分区方式1,MBR:主引导记录(Master Bo ...

  3. Linux磁盘管理工具RAID、Parted

    一.RAID:磁盘冗余阵列 [RAID详解]  https://blog.csdn.net/qq_41475058/article/details/89382997  1.核心关注点 RAID ( R ...

  4. Windows磁盘管理(Raid)

    磁盘管理 题目 一.添加磁盘 二.创建RAID 三.RAID磁盘修复 四.禁用写入缓存 提示:若需要问题欢迎私聊' 题目 磁盘管理 安装及配置软 RAID5. 在安装好的AppSrv虚拟机中添加三块1 ...

  5. 磁盘管理第一章(分区与格式化)

    磁盘管理第一章 对于非系统所在硬盘,内核自动更新分区表,而对于系统所在硬盘,不能直接列新,要使用以下命令 通知内核读取分区表 cenots5\centos7: partprobe (centos6不可 ...

  6. linux磁盘管理(挂载,分区)

    (一)识别本地存储设备 fdisk -l ##真实存在的设备 cat /proc/partition ##系统识别的设备 blkid ##系统可使用的设备 df ##系统正挂载的设备 (二)设备的挂载 ...

  7. win10磁盘管理界面各系统分区介绍

    同一块盘(2TB固态):ubuntu20.04+win10双系统在磁盘管理中的分区形态: 磁盘5:先安装win10后安装ubuntu20.04,安装ubuntu时选择安装界面最上方"与win ...

  8. Windows/Ubuntu双系统磁盘管理中删除Ubuntu分区后Ubuntu EFI分区无法删除卷解决办法

    1.本来电脑安装了Windows.Ubuntu双系统,但是最近UOS出了个人版,就想体验一下. 2.因为要使用硬盘安装,所以之前的Ubuntu分区要处理一下. 3.Windows下,右键我的电脑-&g ...

  9. win10磁盘管理_Win10系统如何分区

    还记得上一期win10系统瘦身的文章吗? 有同学在留言里咨询分盘 下面是写给你们的 接住了哈~ 通常惠普预装win10系统 可以查看到三个分区 系统C盘+数据D盘+恢复分区E盘 我们可通过win10压 ...

最新文章

  1. opencv中LUT函数实现颜色空间缩减
  2. 使用 Python 的基于边缘和基于区域的分割
  3. 【多线程】join()和detach()的用法
  4. 详解边缘计算:为何而起、优势如何、哪些玩家以及正在爆发的场景
  5. JS笔记(20): JS中的同步编程和异步编程
  6. 用 ABAP 实现的报表欢迎屏幕 - Splash Screen
  7. python2 openpyxl 复制excel内容到新的excel文件中 告警问题
  8. SQL一键备份用户数据库
  9. new php,PHP: 新特性 - Manual
  10. Mysql学习总结(2)——Mysql超详细Window安装教程
  11. Thinkphp3.2在IIS中使用ISAPI_Rewrite去除index.php
  12. LCS2005标准版部署
  13. Linux基金会宣布成立Ceph基金会
  14. 多元统计分析基于r课后答案_(完整版)多元统计分析课后练习答案
  15. linux版udp发包工具,packet sender下载-Packet Sender(UDP/TCP网络测试工具)下载 v7.0.5官方版--pc6下载站...
  16. 双足机器人Maltab腿部建模,正运动学分析
  17. 我们有个共同的名字,XX工
  18. Android控件——HorizontalScrollView使用(一)
  19. 牛顿法求解柯西分布参数的最大似然估计(P055)
  20. 2022款联想拯救者Y9000P和Y9000X的区别

热门文章

  1. 学海无涯!腾讯、网易必问的20道题Android面试题,已拿offer入职
  2. 应用容器化之Kubernetes实践
  3. 金字塔图表 html,Highcharts 柱形图(柱状图及条形图)之 金字塔图 演示
  4. 绿卡日记:2020-11-20
  5. Linux云计算架构-使用LAMP搭建ecshop电商平台,并测试网站所能承受并发数
  6. increment java_Java LongAdder increment()用法及代码示例
  7. Java实现计数排序
  8. 正则表达式校验正数/负数
  9. Arduino+nRF24L01接收端(二)
  10. 页面使用html生成一个n行n列表格,HTML静态网页:表格、表单