1、破坏mbr表并修复
[18:22:05 root@bear ~]#hostname -I
10.0.0.217 10.0.0.203 192.168.122.1
[18:25:01 root@bear ~]#hexdump -C /data/dpt.img
00000000 80 04 01 04 83 fe c2 ff 00 08 00 00 00 00 20 00 |.............. .|
00000010 00 fe c2 ff 83 fe c2 ff 00 08 20 00 00 00 80 0c |.......... .....|
00000020 00 fe c2 ff 83 fe c2 ff 00 08 a0 0c 00 00 40 06 |..............@.|
00000030 00 fe c2 ff 05 fe c2 ff 00 08 e0 12 00 f8 1f 06 |................|
00000040
[18:26:30 root@bear ~]#hexdump -C -n 512 /dev/sda
.....
00000180 47 65 6f 6d 00 48 61 72 64 20 44 69 73 6b 00 52 |Geom.Hard Disk.R|
00000190 65 61 64 00 20 45 72 72 6f 72 0d 0a 00 bb 01 00 |ead. Error......|
000001a0 b4 0e cd 10 ac 3c 00 75 f4 c3 00 00 00 00 00 00 |.....<.u........|
000001b0 00 00 00 00 00 00 00 00 91 12 3a 79 00 00 80 04 |..........:y....|
000001c0 01 04 83 fe c2 ff 00 08 00 00 00 00 20 00 00 fe |............ ...|
000001d0 c2 ff 83 fe c2 ff 00 08 20 00 00 00 80 0c 00 fe |........ .......|
000001e0 c2 ff 83 fe c2 ff 00 08 a0 0c 00 00 40 06 00 fe |............@...|
000001f0 c2 ff 05 fe c2 ff 00 08 e0 12 00 f8 1f 06 55 aa |..............U.|
00000200
[18:31:09 root@bear ~]#scp /data/dpt.img 10.0.0.219:
The authenticity of host '10.0.0.219 (10.0.0.219)' can't be established.
ECDSA key fingerprint is SHA256:ogBAuBXsoY2E8l4DA7PowAaa9TlS8DbuXt/vheFYwoY.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.0.0.219' (ECDSA) to the list of known hosts.
root@10.0.0.219's password:
dpt.img
[18:30:55 root@centos7 ~]#ll
total 7044
....
-rw-r--r--. 1 root root 64 Jan 9 18:32 dpt.img
[18:32:57 root@bear ~]#dd if=/dev/zero of=/dev/sda bs=1 count=64 seek=446
64+0 records in
64+0 records out
64 bytes copied, 0.00117178 s, 54.6 kB/s
[18:36:50 root@bear ~]#fdisk -l
Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 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
Disklabel type: dos
Disk identifier: 0x793a1291
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 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 /dev/sdc: 20 GiB, 21474836480 bytes, 41943040 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
#用光盘启动,进入rescue mode,选第3项skip to shell
#配置网络
#ip a a 10.0.0.217/24 dev/ens33
#scp 10.0.0.219:/data/dpt.img .
#恢复MBR分区表
#dd if=dpt.img of=/dev/sda bs=1 seek=446
#exit
2、总结RAID的各个级别及其组合方式和性能的不同。
RAID功能实现
提高IO能力,磁盘并行读写
提高耐用性,磁盘冗余算法来实现
RAID实现的方式 外接式磁盘阵列:通过扩展卡提供适配能力
内接式RAID:主板集成RAID控制器,安装OS前在BIOS里配置
软件RAID:通过OS实现,比如:群晖的NAS
RAID级别
级别:多块磁盘组织在一起的工作方式有所不同
- RAID-0:条带卷,strip
- RAID-1:镜像卷,mirror
- RAID-2
- ..
- RAID-5
- RAID-6
- RAID-10
- RAID-01
- RAID级别
RAID-0
以 chunk 单位,读写数据
读、写性能提升 可用空间:N*min(S1,S2,...) 无容错能力 最少磁盘数:2, 2+
RAID-1
读性能提升、写性能略有下降 可用空间:1*min(S1,S2,...) 有冗余能力 最少磁盘数:2, 2N
RAID-4
多块数据盘异或运算值存于专用校验盘
磁盘利用率 (N-1)/N 有冗余能力 至少3块硬盘才可以实现
RAID-5 读、写性能提升 可用空间:(N-1)*min(S1,S2,...) 有容错能力:允许最多1块磁盘损坏 最少磁盘数:3, 3+
RAID-6
读、写性能提升 可用空间:(N-2)*min(S1,S2,...) 有容错能力:允许最多2块磁盘损坏 最少磁盘数:4, 4+
RAID-10
读、写性能提升 可用空间:N*min(S1,S2,...)/2 有容错能力:每组镜像最多只能坏一块 比01 更强 最少磁盘数:4, 4+
RAID-01
多块磁盘先实现RAID0,再组合成RAID1
RAID-50
JBOD:Just a Bunch Of Disks
功能:将多块磁盘的空间合并一个大的连续空间使用 可用空间:sum(S1,S2,...)
RAID7 可以理解为一个独立存储计算机,自身带有操作系统和管理工具,可以独立运行,理论上性能最高的 RAID模式 常用级别: RAID-0, RAID-1, RAID-5, RAID-10, RAID-50, JBOD
3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
[19:53:51 root@centos7 ~]#mkfs.ext4 -b 2048 -L TEST -m 1 /dev/sdb2
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=TEST
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 1048576 blocks
10485 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=269484032
64 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
Allocating group tables: done
[19:54:12 root@centos7 ~]#lsblk -f /dev/sdb2
NAME FSTYPE LABEL UUID MOUNTPOINT
sdb2 ext4 TEST b12e5cdb-d708-4b45-bd48-21d390efed8a
[19:56:31 root@centos7 ~]#tune2fs /dev/sdb2 -l
tune2fs 1.42.9 (28-Dec-2013)
Filesystem volume name: TEST
Last mounted on: <not available>
Filesystem UUID: b12e5cdb-d708-4b45-bd48-21d390efed8a
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 131072
Block count: 1048576
Reserved block count: 10485
Free blocks: 994651
Free inodes: 131061
First block: 0
Block size: 2048
Fragment size: 2048
Group descriptor size: 64
Reserved GDT blocks: 512
Blocks per group: 16384
Fragments per group: 16384
Inodes per group: 2048
Inode blocks per group: 256
Flex block group size: 16
Filesystem created: Mon Jan 11 19:54:11 2021
Last mount time: n/a
Last write time: Mon Jan 11 19:54:12 2021
Mount count: 0
Maximum mount count: -1
Last checked: Mon Jan 11 19:54:11 2021
Check interval: 0 (<none>)
Lifetime writes: 65 MB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: ee0f5e87-f9a7-4904-b045-a25c5aea2b0a
Journal backup: inode blocks
[20:01:36 root@centos7 ~]#vim /etc/fstab
[20:03:16 root@centos7 ~]#cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Nov 8 16:01:07 2020
#
# 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=dbe468bf-af09-454b-8c4b-9ae7708540c2 / xfs defaults 0 0
UUID=f075492b-00dd-4f35-ab8d-dc62874dcfaa /boot xfs defaults 0 0
UUID=59a5aeda-4a71-4cee-a1ad-2d2f867c95e1 /data xfs defaults 0 0
UUID=7cf09312-8ce2-4ce7-b61c-ad7e63b8a88d swap swap defaults 0 0
UUID=8f2473f7-7171-46eb-bed0-7dfc0d5dbfdb /mnt/sdb1 ext4 defaults 0 1
UUID=b12e5cdb-d708-4b45-bd48-21d390efed8a /mnt/sdb2 ext4 defaults 0 0
[20:03:57 root@centos7 ~]#mkdir /mnt/sdb2; mount /dev/sdb2 /mnt/sdb2
[20:04:48 root@centos7 ~]#lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 xfs f075492b-00dd-4f35-ab8d-dc62874dcfaa /boot
├─sda2 xfs dbe468bf-af09-454b-8c4b-9ae7708540c2 /
├─sda3 swap 7cf09312-8ce2-4ce7-b61c-ad7e63b8a88d [SWAP]
├─sda4
└─sda5 xfs 59a5aeda-4a71-4cee-a1ad-2d2f867c95e1 /data
sdb
├─sdb1 ext4 8f2473f7-7171-46eb-bed0-7dfc0d5dbfdb /mnt/sdb1
└─sdb2 ext4 TEST b12e5cdb-d708-4b45-bd48-21d390efed8a /mnt/sdb2
sr0 iso9660 CentOS 7 x86_64 2020-04-22-00-55-24-00
[20:04:54 root@centos7 ~]#reboot
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(centos7) at 20:05:21.
Type `help' to learn how to use Xshell prompt.
[C:\~]$
Connecting to 10.0.0.219:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Last login: Mon Jan 11 17:09:09 2021 from 10.0.0.1
[20:08:44 root@centos7 ~]#df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 998180 0 998180 0% /dev
tmpfs 1013952 0 1013952 0% /dev/shm
tmpfs 1013952 10496 1003456 2% /run
tmpfs 1013952 0 1013952 0% /sys/fs/cgroup
/dev/sda2 104806400 6077216 98729184 6% /
/dev/sda5 52403200 166160 52237040 1% /data
/dev/sdb2 1998538 9236 1960140 1% /mnt/sdb2
/dev/sdb1 3997376 16376 3754904 1% /mnt/sdb1
/dev/sda1 1038336 313728 724608 31% /boot
tmpfs 202792 8 202784 1% /run/user/42
tmpfs 202792 0 202792 0% /run/user/0
4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
##添加两块硬盘sde和sdf 各10G大小
[20:56:07 root@bear ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 50G 0 part /data
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 4G 0 part [SWAP]
sdb 8:16 0 10G 0 disk
└─vg_mysql-lv_data 253:0 0 32G 0 lvm /mysql/data
sdc 8:32 0 20G 0 disk
└─vg_mysql-lv_data 253:0 0 32G 0 lvm /mysql/data
sdd 8:48 0 10G 0 disk
└─vg_mysql-lv_data 253:0 0 32G 0 lvm /mysql/data
sde 8:64 0 10G 0 disk
sdf 8:80 0 10G 0 disk
sr0 11:0 1 7.7G 0 rom /run/media/wang/CentOS-8-2-2004-x86_64-dvd
[20:56:23 root@bear ~]#pvcreate /dev/sde /dev/sdf
Physical volume "/dev/sde" successfully created.
Physical volume "/dev/sdf" successfully created.
[20:58:53 root@bear ~]#pvs
PV VG Fmt Attr PSize PFree
/dev/sdb vg_mysql lvm2 a-- <10.00g 0
/dev/sdc vg_mysql lvm2 a-- <20.00g 0
/dev/sdd vg_mysql lvm2 a-- <10.00g <8.00g
/dev/sde lvm2 --- 10.00g 10.00g
/dev/sdf lvm2 --- 10.00g 10.00g
[21:00:07 root@bear ~]#vgcreate -s 16M testvg /dev/sde /dev/sdf
Volume group "testvg" successfully created
[21:03:07 root@bear ~]#vgdisplay
--- Volume group ---
VG Name testvg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size <19.97 GiB
PE Size 16.00 MiB
Total PE 1278
Alloc PE / Size 0 / 0
Free PE / Size 1278 / <19.97 GiB
VG UUID WzWshF-MTVW-H8ee-jvcw-fQth-e0Cq-1zmnJm
[21:03:14 root@bear ~]#lvcreate -n testlv -L 5G testvg
Logical volume "testlv" created.
[21:06:42 root@bear ~]#lvdisplay
--- Logical volume ---
LV Path /dev/testvg/testlv
LV Name testlv
VG Name testvg
LV UUID v8sxfS-8O1W-HwvM-R8k9-GSd9-IhUc-MoX6Df
LV Write Access read/write
LV Creation host, time bear.centos.org, 2021-01-16 21:06:42 +0800
LV Status available
# open 0
LV Size 5.00 GiB
Current LE 320
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
[21:09:31 root@bear ~]#mkdir /users -p
[21:11:09 root@bear ~]#blkid /dev/mapper/testvg-testlv
/dev/mapper/testvg-testlv: UUID="1140c161-2072-47a0-a863-5b562363cb79" TYPE="ext4"
[21:11:48 root@bear ~]#vim /etc/fstab #添加testlv 挂载点
[21:10:09 root@bear ~]#mount -a
[21:10:37 root@bear ~]#df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 953M 0 953M 0% /dev
tmpfs tmpfs 981M 0 981M 0% /dev/shm
tmpfs tmpfs 981M 9.8M 971M 1% /run
tmpfs tmpfs 981M 0 981M 0% /sys/fs/cgroup
/dev/sda2 xfs 100G 5.4G 95G 6% /
/dev/sda3 xfs 50G 1.4G 49G 3% /data
/dev/sda1 ext4 976M 172M 738M 19% /boot
tmpfs tmpfs 197M 1.2M 195M 1% /run/user/42
tmpfs tmpfs 197M 4.6M 192M 3% /run/user/1000
/dev/sr0 iso9660 7.7G 7.7G 0 100% /run/media/wang/CentOS-8-2-2004-x86_64-dvd
/dev/mapper/vg_mysql-lv_data ext4 31G 1.2G 29G 4% /mysql/data
/dev/mapper/testvg-testlv ext4 4.9G 20M 4.6G 1% /users