1、破坏mbr表并修复
[root@centos7 ~]#dd if=/dev/zero of=/dev/sda bs=1 count=446
446+0 records in
446+0 records out
446 bytes (446 B) copied, 0.000324999 s, 1.4 MB/s
[root@centos7 ~]#hexdump -C -n 512 /dev/sda -v
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 20 |............... |
000001c0 21 00 83 aa 28 82 00 08 00 00 00 00 20 00 00 aa |!...(....... ...|
000001d0 29 82 83 fe ff ff 00 08 20 00 00 00 40 01 00 fe |)....... ...@...|
000001e0 ff ff 82 fe ff ff 00 08 60 01 00 00 40 00 00 fe |........`...@...|
000001f0 ff ff 05 fe ff ff 00 08 a0 01 00 f8 df 00 55 aa |..............U.|
00000200
[root@centos7 ~]#
重启后无法启动,选择镜像盘启动,选择救援模式
#chroot /mnt/sysimage
#grub2-install /dev/sda
#sync
#exit
#exit
2、总结RAID的各个级别及其组合方式和性能的不同。 RAID:独立磁盘荣冗余阵列。 RAID实现了什么?
- 提高了IO性能,磁盘并行读写能力
- 提供耐用性也就是冗余能力 RAID实现方式
- 通过扩展卡实现外接磁盘阵列
- 主板进程的RAID控制器
- 软件RAID RAID分类 RAID-0 读写性能提升,无容错能力即无冗余,至少2快磁盘 RAID-1 读性能提升,写性能略微下降,浪费磁盘空间,有冗余,至少2,2N RAID-5 读写提升,可用空间(N-1)*min(s1,s2...).最多运行一块硬盘损坏,至少3快磁盘 RAID-6 读、写性能提升,可用空间(N-2))*min(s1,s2...)有冗余最多运行一块硬盘损坏,至少4,4+ RAID-10 读、写性能提升可用空间:Nmin(S1,S2,...)/2有容错能力:每组镜像最多只能坏一块最少磁盘数:4, 4+
RAID-01 RAID-50 实现软RAID工具,mdadm
-C: 创建模式
-n #: 使用#个块设备来创建此RAID
-l #:指明要创建的RAID的级别
-a {yes|no}:自动创建目标RAID设备的设备文件
-c CHUNK_SIZE: 指明块大小,单位k
-x #: 指明空闲盘的个数
[root@centos7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 10G 0 part /
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 5G 0 part /data
sdb 8:16 0 20G 0 disk
sdc 8:32 0 20G 0 disk
sr0 11:0 1 4.4G 0 rom /mnt
[root@centos7 ~]#mdadm -C /dev/md0 -a yes -l 1 -n2 /dev/sd{b,c}
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
Continue creating array? ^[^A
Continue creating array? (y/n) y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@centos7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 10G 0 part /
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 5G 0 part /data
sdb 8:16 0 20G 0 disk
└─md0 9:0 0 20G 0 raid1
sdc 8:32 0 20G 0 disk
└─md0 9:0 0 20G 0 raid1
sr0 11:0 1 4.4G 0 rom /mnt
3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
[root@centos7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 10G 0 part /
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 5G 0 part /data
sdb 8:16 0 20G 0 disk
sdc 8:32 0 20G 0 disk
sr0 11:0 1 4.4G 0 rom /mnt
[root@centos7 ~]#fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xc15d4c0d.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +2G
Partition 1 of type Linux and of size 2 GiB is set
Command (m for help): w
[root@centos7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 10G 0 part /
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 5G 0 part /data
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 2G 0 part
sdc 8:32 0 20G 0 disk
sr0 11:0 1 4.4G 0 rom /mnt
[root@centos7 ~]#mkfs.ext4 -b 2048 -m 1 -L TEST /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=TEST
OS type: Linux
Block size=2048 (log=1)
[root@centos7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 10G 0 part /
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 5G 0 part /data
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 2G 0 part /test
sdc 8:32 0 20G 0 disk
sr0 11:0 1 4.4G 0 rom /mnt
编辑设置开机启动挂载
vim /etc/fstab
UUID=e942271b-98d6-48f6-af38-44ce45302d0c /test ext4 acl 0 0
4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
[root@centos7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 10G 0 part /
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 5G 0 part /data
sdb 8:16 0 10G 0 disk
sdc 8:32 0 10G 0 disk
sr0 11:0 1 4.4G 0 rom /mnt
[root@centos7 ~]#pvcreate /dev/sdb /dev/sdc
Physical volume "/dev/sdb" successfully created.
Physical volume "/dev/sdc" successfully created.
[root@centos7 ~]#pvs
PV VG Fmt Attr PSize PFree
/dev/sdb lvm2 --- 10.00g 10.00g
/dev/sdc lvm2 --- 10.00g 10.00g
[root@centos7 ~]#vgcreate testvg /dev/sdb /dev/sdc -s 16
Volume group "testvg" successfully created
[root@centos7 ~]#vgs
VG #PV #LV #SN Attr VSize VFree
testvg 2 0 0 wz--n- <19.97g <19.97g
[root@centos7 ~]#vgs
vgs vgscan vgsplit
[root@centos7 ~]#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 etfkpQ-w3SZ-4bZz-UIIY-i3hI-d6ER-hAngOD
[root@centos7 ~]#lvcreate -L 5G -n testlv testvg
Logical volume "testlv" created.
[root@centos7 ~]#lvs
lvs lvscan
[root@centos7 ~]#lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
testlv testvg -wi-a----- 5.00g
[root@centos7 ~]#lvdisplay
--- Logical volume ---
LV Path /dev/testvg/testlv
LV Name testlv
VG Name testvg
LV UUID in6R7Q-gv2g-u7vW-puuj-X8rk-bFSu-XriokN
LV Write Access read/write
LV Creation host, time centos7, 2021-01-05 12:16:57 +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:0
[root@centos7 ~]#mkdir /users
[root@centos7 ~]#mkfs.xfs /dev/testvg/testlv
meta-data=/dev/testvg/testlv isize=512 agcount=4, agsize=327680 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@centos7 ~]#mount /dev/testvg/testlv /users/
[root@centos7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 10G 0 part /
├─sda3 8:3 0 2G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 5G 0 part /data
sdb 8:16 0 10G 0 disk
└─testvg-testlv 253:0 0 5G 0 lvm /users
sdc 8:32 0 10G 0 disk
sr0 11:0 1 4.4G 0 rom /mnt
[root@centos7 ~]#