1.1破壞mbr表并修復(fù)
##1. 添加一塊實(shí)驗(yàn)用磁盤:/dev/sdb
[root@bogon ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
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.
Created a new DOS disklabel with disk identifier 0x440d52d3.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (1-4, default 1):
First sector (2048-10485759, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-10485759, default 10485759):
Created a new partition 1 of type 'Linux' and of size 5 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@bogon ~]#
[root@bogon ~]#
[root@bogon ~]# partprobe /dev/sdb
[root@bogon ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 1310464 4k blocks and 327680 inodes
Filesystem UUID: ce994dfa-b43a-41ef-a867-de489f359f14
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
[root@bogon ~]# lsblk /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 5G 0 disk
└─sdb1 8:17 0 5G 0 part
[root@bogon ~]#
## 用hexdump -C /dev/sdb -n 512查看分區(qū)表前512字節(jié)
通過修改分區(qū)表修改如圖的64個(gè)字節(jié)來達(dá)到破壞效果
[root@bogon ~]# hexdump -C /dev/sdb -n 512
00000000 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 95 2e a5 86 00 00 00 20 |............... |
000001c0 21 00 83 b4 a8 8c 00 08 00 00 00 f8 9f 00 00 00 |!...............|
000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00000200
[root@bogon ~]#
# #備份 /dev/sdb mrb分區(qū)表:
[root@bogon software]# dd if=/dev/sdb of=/root/mbr-bak.img bs=1 count=64 skip=446
64+0 records in
64+0 records out
64 bytes copied, 0.000591286 s, 108 kB/s
[root@bogon software]# ls -lh
-rw-r--r-- 1 root root 64 Jan 10 22:05 mbr-bak.img
[root@bogon software]#
## 破壞/dev/sdb mbr 分區(qū)表
[root@bogon software]# dd if=/dev/zero of=/dev/sdb bs=1 count=64 seek=446
64+0 records in
64+0 records out
64 bytes copied, 0.000855001 s, 74.9 kB/s
[root@bogon software]#
## 破壞分區(qū)表前:
[root@bogon ~]# 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 19G 0 part
└─cl-root 253:0 0 19G 0 lvm /
sdb 8:16 0 5G 0 disk
└─sdb1 8:17 0 5G 0 part
sr0 11:0 1 1.6G 0 rom
## 破壞分區(qū)表后:
[root@bogon software]# 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 19G 0 part
└─cl-root 253:0 0 19G 0 lvm /
sdb 8:16 0 5G 0 disk
sr0 11:0 1 1.6G 0 rom
## 如果是根分區(qū)所在磁盤
#無法重新啟動(dòng)
[root@bogon software]#reboot
1.2修復(fù)/dev/sdb mbr分區(qū)表:
用光盤啟動(dòng),進(jìn)入rescue mode
先確保鼠標(biāo)在VMware界面里
重啟進(jìn)入進(jìn)度條時(shí),按一次Esc鍵
image.png
image.png
image.png
image.png
使用備份的mbr 表恢復(fù):
image.png
2、總結(jié)RAID的各個(gè)級別及其組合方式和性能的不同述暂。
Level | Description | Min number of drives |
---|---|---|
RAID0 | 缺點(diǎn):沒有數(shù)據(jù)冗余汽摹。 優(yōu)點(diǎn):性能提升(寫入和讀取速度) |
最小磁盤數(shù): 2 |
RAID1 | 優(yōu)點(diǎn):容錯(cuò)和簡單的數(shù)據(jù)恢復(fù)蔓姚。提高了讀取性能 缺點(diǎn):可用容量較低卓囚。每兆字節(jié)的成本更高(達(dá)到所需容量所需的驅(qū)動(dòng)器數(shù)量的兩倍) |
最小磁盤數(shù): 2 |
RAID5 | 優(yōu)點(diǎn):容錯(cuò)和IO性能提升(低于RAID 0 缺點(diǎn):由于奇偶校驗(yàn)開銷導(dǎo)致服務(wù)器執(zhí)行大量寫操作簿盅,性能降低 |
最小磁盤數(shù): 3 |
RAID6 | 優(yōu)點(diǎn):比RAID 5更高的冗余轧拄。提高了讀取性能揽祥。 缺點(diǎn):由于奇偶校驗(yàn)開銷,服務(wù)器執(zhí)行大量寫操作會降低性能 |
最小磁盤數(shù): 4 |
RAID10 | 優(yōu)點(diǎn):性能非常高檩电。容錯(cuò) 缺點(diǎn):可用容量較低/成本較高拄丰。有限的可擴(kuò)展性 |
最小磁盤數(shù): 4 |
3府树、創(chuàng)建一個(gè)2G的文件系統(tǒng),塊大小為2048byte愈案,預(yù)留1%可用空間,文件系統(tǒng) ext4挺尾,卷標(biāo)為TEST,要求此分區(qū)開機(jī)后自動(dòng)掛載至/test目錄站绪,且默認(rèn)有acl掛載選項(xiàng)
## 熱添加磁盤
[root@bogon ~]# ls /sys/class/scsi_host/ # 查看主機(jī)scsi 總線號
host0 host1 host2
[root@bogon ~]# 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 19G 0 part
└─cl-root 253:0 0 19G 0 lvm /
sdb 8:16 0 5G 0 disk
└─sdb1 8:17 0 5G 0 part
sr0 11:0 1 1.6G 0 rom
[root@bogon ~]#
[root@bogon ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@bogon ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@bogon ~]# echo "- - -" > /sys/class/scsi_host/host2/scan
[root@bogon ~]# lsblk ## 成功熱添加 sdc
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 19G 0 part
└─cl-root 253:0 0 19G 0 lvm /
sdb 8:16 0 5G 0 disk
└─sdb1 8:17 0 5G 0 part
sdc 8:32 0 2G 0 disk
sr0 11:0 1 1.6G 0 rom
[root@bogon ~]#
[root@bogon ~]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.32.1).
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.
Created a new DOS disklabel with disk identifier 0xa00230c2.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (1-4, default 1):
First sector (2048-10485759, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-10485759, default 10485759): +2G
Created a new partition 1 of type 'Linux' and of size 2 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@bogon ~]# mkfs.ext4 -t ext4 -b 2048 -L TEST -m 1 /dev/sdc1 ##格式化
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 1048576 2k blocks and 131072 inodes
Filesystem UUID: d4822e63-ea0f-4e37-9d9c-2bd7ed120980
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
[root@bogon ~]# blkid /dev/sdb1
/dev/sdb1: UUID="ce994dfa-b43a-41ef-a867-de489f359f14" TYPE="ext4" PARTUUID="440d52d3-01"
[root@bogon ~]#
[root@bogon /]# cat /etc/fstab |grep acl
UUID=0e342325-5312-444f-ad7a-6f6237bfac47 /test ext4 acl 0 0
[root@bogon /]#
[root@bogon /]# dumpe2fs -h /dev/sdc1
dumpe2fs 1.45.6 (20-Mar-2020)
Filesystem volume name: TEST
Last mounted on: <not available>
Filesystem UUID: d4822e63-ea0f-4e37-9d9c-2bd7ed120980
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 large_file huge_file dir_nlink extra_isize metadata_csum
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: 1011035
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 00:13:41 2021
Last mount time: n/a
Last write time: Mon Jan 11 00:13:41 2021
Mount count: 0
Maximum mount count: -1
Last checked: Mon Jan 11 00:13:41 2021
Check interval: 0 (<none>)
Lifetime writes: 1058 kB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 32
Desired extra isize: 32
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 03893215-8699-427e-9856-8ccb079b3099
Journal backup: inode blocks
Checksum type: crc32c
Checksum: 0x1c68f744
Journal features: (none)
Journal size: 32M
Journal length: 16384
Journal sequence: 0x00000001
Journal start: 0
[root@bogon /]#
4遭铺、創(chuàng)建一個(gè)至少有兩個(gè)PV組成的大小為20G的名為testvg的VG;要求PE大小 為16MB, 而后在卷組中創(chuàng)建大小為5G的邏輯卷testlv;掛載至/users目錄
[root@bogon ~]# vgcreate -s 16m testvg /dev/sdb1 /dev/sdc1 ## 創(chuàng)建VG
WARNING: ext4 signature detected on /dev/sdb1 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/sdb1.
WARNING: ext4 signature detected on /dev/sdc1 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/sdc1.
Physical volume "/dev/sdb1" successfully created.
Physical volume "/dev/sdc1" successfully created.
Volume group "testvg" successfully created
[root@bogon ~]# 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 <6.97 GiB
PE Size 16.00 MiB
Total PE 446
Alloc PE / Size 0 / 0
Free PE / Size 446 / <6.97 GiB
VG UUID U8E23g-ljdX-X1Ga-aDkd-7ouo-wby9-Rg424D
[root@bogon ~]# lvcreate -L 5G -n testlv testvg ## 創(chuàng)建lv
Logical volume "testlv" created.
[root@bogon ~]# mkfs.ext4 /dev/testvg/testlv ##格式化lv 為ext4格式
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 1310720 4k blocks and 327680 inodes
Filesystem UUID: 76031543-4f71-4730-a8f1-88494b6aa290
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
[root@bogon ~]# mkdir /users
[root@bogon ~]# mount /dev/testvg/testlv /users ## 掛載lv 到文件夾
[root@bogon ~]# 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 19G 0 part
└─cl-root 253:0 0 19G 0 lvm /
sdb 8:16 0 5G 0 disk
└─sdb1 8:17 0 5G 0 part
└─testvg-testlv 253:1 0 5G 0 lvm /users
sdc 8:32 0 5G 0 disk
└─sdc1 8:33 0 2G 0 part
└─testvg-testlv 253:1 0 5G 0 lvm /users
sr0 11:0 1 1.6G 0 rom
[root@bogon ~]#