磁盘管理之 raid 文件系统 分区
第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 文件系统 分区相关推荐
- 【操作系统/OS笔记20】打开文件、文件数据块分配、空闲空间管理、多磁盘管理(RAID)、磁盘调度算法概述
本次笔记内容: 12.12 打开文件的数据结构 12.13 文件的分配 12.14 空闲空间列表 12.15 多磁盘管理-RAID 12.16 磁盘调度 文章目录 打开文件 何谓"打开文件& ...
- linux磁盘管理、格式化、分区
磁盘管理 名词:DISK 磁盘.硬盘 磁盘作用:存储数据 种类:机械硬盘.固态硬盘 命名:SATA(串口)1./dev/sda 2./dev/sdb 分区方式1,MBR:主引导记录(Master Bo ...
- Linux磁盘管理工具RAID、Parted
一.RAID:磁盘冗余阵列 [RAID详解] https://blog.csdn.net/qq_41475058/article/details/89382997 1.核心关注点 RAID ( R ...
- Windows磁盘管理(Raid)
磁盘管理 题目 一.添加磁盘 二.创建RAID 三.RAID磁盘修复 四.禁用写入缓存 提示:若需要问题欢迎私聊' 题目 磁盘管理 安装及配置软 RAID5. 在安装好的AppSrv虚拟机中添加三块1 ...
- 磁盘管理第一章(分区与格式化)
磁盘管理第一章 对于非系统所在硬盘,内核自动更新分区表,而对于系统所在硬盘,不能直接列新,要使用以下命令 通知内核读取分区表 cenots5\centos7: partprobe (centos6不可 ...
- linux磁盘管理(挂载,分区)
(一)识别本地存储设备 fdisk -l ##真实存在的设备 cat /proc/partition ##系统识别的设备 blkid ##系统可使用的设备 df ##系统正挂载的设备 (二)设备的挂载 ...
- win10磁盘管理界面各系统分区介绍
同一块盘(2TB固态):ubuntu20.04+win10双系统在磁盘管理中的分区形态: 磁盘5:先安装win10后安装ubuntu20.04,安装ubuntu时选择安装界面最上方"与win ...
- Windows/Ubuntu双系统磁盘管理中删除Ubuntu分区后Ubuntu EFI分区无法删除卷解决办法
1.本来电脑安装了Windows.Ubuntu双系统,但是最近UOS出了个人版,就想体验一下. 2.因为要使用硬盘安装,所以之前的Ubuntu分区要处理一下. 3.Windows下,右键我的电脑-&g ...
- win10磁盘管理_Win10系统如何分区
还记得上一期win10系统瘦身的文章吗? 有同学在留言里咨询分盘 下面是写给你们的 接住了哈~ 通常惠普预装win10系统 可以查看到三个分区 系统C盘+数据D盘+恢复分区E盘 我们可通过win10压 ...
最新文章
- 分布式存储fastdfs安装使用
- boost::hana::greater_equal用法的测试程序
- 华为哪款手表支持鸿蒙,华为Watch 3最早或于5月发布 采用鸿蒙系统并支持eSIM
- 计算机视觉中常见图像扰动方法的Pytorch实现
- MongoDB 安全权限访问控制
- 天梯——赌马 (20 分)
- poj1005——I Think I Need a Houseboat
- scrollHeight,clientHeight,scrollTop
- 解决Adobe PhotoShop用户界面字体过小的问题
- 【PHP】面试经历总结之——新浪微博
- 用收敛标准计算神经网络迭代次数
- echart折线图删除_echart清空折线图数据
- 字体侵权太严重,我准备了700款可商用字体
- -128的补码及原码、反码、补码
- teamviewer连接不上的原因及解决方法有哪些
- Vue2:组件及组件通信
- [蓝牙] 1、蓝牙核心技术了解(蓝牙协议、架构、硬件和软件笔记)
- iOS判断当前是否为模拟器
- Code With Me插件,IDEA多人协作
- MyBatis 配置 settings 标签