1、破壞mbr表并修復(fù)
#1、 備份MBR分區(qū)表到另外一臺(tái)機(jī)器
[root@localhost ~]# mkdir /data
[root@localhost ~]# dd if=/dev/nvme0n1 of=/data/dpt.img bs=1 count=64 skip=446
64+0 records in
64+0 records out
64 bytes copied, 8.9457e-05 s, 715 kB/s
[root@localhost ~]# scp /data/dpt.img 10.0.0.203:
The authenticity of host '10.0.0.203 (10.0.0.203)' can't be established.
RSA key fingerprint is SHA256:eXT6e/Ovz9uGAIh3HTmQRqHTGyQp8woQl3OXYLPdtCQ.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.0.0.203' (RSA) to the list of known hosts.
root@10.0.0.203's password:
dpt.img 100% 64 178.3KB/s 00:00
#2彬犯、破壞MBR分區(qū)表
[root@localhost ~]# dd if=/dev/zero of=/dev/nvme0n1 bs=1 count=64 seek=446
64+0 records in
64+0 records out
64 bytes copied, 9.0814e-05 s, 705 kB/s
#3、重啟后無(wú)法進(jìn)入系統(tǒng)
[root@localhost ~]# reboot
#4查吊、用光盤啟動(dòng),進(jìn)入rescue mode,選第3項(xiàng)skip to shell
#進(jìn)去后配置本機(jī)IP與備份那臺(tái)做連接
#ifconfig ens160 10.0.0.201/24
#5、拷貝備份的MBR表
#scp 10.0.0.203:/root/dpt.img .
#6湖蜕、恢復(fù)MBR分區(qū)表逻卖,重啟正常進(jìn)入系統(tǒng)
#dd if=dpt.img of=/dev/sda bs=1 seek=446
#exit
2、總結(jié)RAID的各個(gè)級(jí)別及其組合方式和性能的不同昭抒。
下面是常用的RAID
RAID0特性:
- 讀寫性能提升评也;
- 可用空間,N*min
- 無(wú)容錯(cuò)能力灭返;
- 最小磁盤數(shù)2盗迟,2+
RAID1特性:
- 讀性能提升,寫性能略有下降熙含,同一份數(shù)據(jù)要存兩份罚缕;
- 可用空間,1*min,磁盤總空間的一半怎静;
- 有冗余能力邮弹;
- 最少磁盤數(shù)黔衡,2,2+腌乡;
RAID5特性:
- 讀寫性能提升盟劫;
- 可用空間,N-1*min与纽;
- 有冗余能力侣签;
- 最少磁盤數(shù),3急迂,3+影所;
RAID10特性:
- 讀寫性能提升;
- 可用空間袋毙,N*min/2;
- 有冗余能力型檀,每組鏡像最多只能壞一塊;
- 最少磁盤數(shù)听盖,4胀溺,4+;
3皆看、創(chuàng)建一個(gè)2G的文件系統(tǒng)仓坞,塊大小為2048byte,預(yù)留1%可用空間,文件系統(tǒng) ext4腰吟,卷標(biāo)為TEST无埃,要求此分區(qū)開(kāi)機(jī)后自動(dòng)掛載至/test目錄,且默認(rèn)有acl掛載選項(xiàng)
#1毛雇、查看硬盤信息嫉称,一下將sdb作為操作目標(biāo)
[root@centos7 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 29G 0 part
├─centos-root 253:0 0 27G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 5G 0 disk
sr0 11:0 1 1024M 0 rom
#2、在sdb磁盤上創(chuàng)建大小為2G的分區(qū)
[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 0xd6ff8485.
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-10485759, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759): +2G
Partition 1 of type Linux and of size 2 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#3灵疮、在sdb1分區(qū)上創(chuàng)建文件系統(tǒng)
[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)
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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
#文件系統(tǒng)已經(jīng)創(chuàng)建
[root@centos7 ~]# blkid
/dev/sda1: UUID="fd757a87-91b3-4517-8bc5-72466f0878a4" TYPE="xfs"
/dev/sda2: UUID="pwwTHd-Lszj-rYEP-f6Qu-Px2f-4i3e-347wHt" TYPE="LVM2_member"
/dev/sdb1: LABEL="TEST" UUID="79450cbb-b1c7-447a-ab06-129afa93eb02" TYPE="ext4"
/dev/mapper/centos-root: UUID="6f24832e-127f-4e86-9fbf-279a7efe326d" TYPE="xfs"
/dev/mapper/centos-swap: UUID="319099b9-55cc-4839-9788-a53cf6866f0a" TYPE="swap"
#4织阅、將分區(qū)掛載在/test目錄中
# 在/etc/fstab文件末尾添加以下內(nèi)容
[root@centos7 ~]# vim /etc/fstab
UUID=79450cbb-b1c7-447a-ab06-129afa93eb02 /test ext4 acl 0 0
#5、創(chuàng)建目標(biāo)文件夾使配置生效
[root@centos7 ~]#mkdir /test
[root@centos7 ~]# mount -a
#6震捣、掛載完畢荔棉,查看磁盤
[root@centos7 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 29G 0 part
├─centos-root 253:0 0 27G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 5G 0 disk
└─sdb1 8:17 0 2G 0 part
sr0 11:0 1 1024M 0 rom
4、創(chuàng)建一個(gè)至少有兩個(gè)PV組成的大小為20G的名為testvg的VG;要求PE大小 為16MB, 而后在卷組中創(chuàng)建大小為5G的邏輯卷testlv;掛載至/users目錄
#1蒿赢、查看磁盤信息润樱,以下操作將以sdc、sdd作為操作目標(biāo)
[root@centos7 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 29G 0 part
├─centos-root 253:0 0 27G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 5G 0 disk
└─sdb1 8:17 0 2G 0 part /test
sdc 8:32 0 10G 0 disk
sdd 8:48 0 10G 0 disk
sr0 11:0 1 1024M 0 rom
#2羡棵、創(chuàng)建PV
[root@centos7 ~]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created.
[root@centos7 ~]# pvcreate /dev/sdd
Physical volume "/dev/sdd" successfully created.
[root@centos7 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <29.00g 4.00m
/dev/sdc lvm2 --- 10.00g 10.00g
/dev/sdd lvm2 --- 10.00g 10.00g
#3壹若、創(chuàng)建名為testvg的VG,PE大小為16M
[root@centos7 ~]# vgcreate testvg -s 16M /dev/sdc /dev/sdd
Volume group "testvg" successfully created
[root@centos7 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <29.00g 4.00m
testvg 2 0 0 wz--n- <19.97g <19.97g
[root@centos7 ~]# vgdisplay testvg
--- 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 4kLfLX-ufLc-TH1k-eknK-rjF1-jdR4-5KvBtO
#4、創(chuàng)建大小為5G的邏輯卷testlv,并建立文件系統(tǒng)
[root@centos7 ~]# lvcreate -L 5G -n testlv testvg
Logical volume "testlv" created.
[root@centos7 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 26.99g
swap centos -wi-ao---- 2.00g
testlv testvg -wi-a----- 5.00g
[root@centos7 ~]# lvdisplay /dev/testvg/testlv
--- Logical volume ---
LV Path /dev/testvg/testlv
LV Name testlv
VG Name testvg
LV UUID jrgEC8-0Jbj-rCpA-bLPy-RY1S-ELME-M4v8cf
LV Write Access read/write
LV Creation host, time centos7, 2021-01-08 04:06:32 +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:2
#建立文件系統(tǒng)
[root@centos7 ~]# mkfs.ext4 /dev/testvg/testlv
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
#5舌稀、創(chuàng)建/users啊犬,并掛載
[root@centos7 ~]# mkdir /users
[root@centos7 ~]# mount /dev/testvg/testlv /us
users/ usr/
[root@centos7 ~]# mount /dev/testvg/testlv /users/
[root@centos7 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 29G 0 part
├─centos-root 253:0 0 27G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 5G 0 disk
└─sdb1 8:17 0 2G 0 part /test
sdc 8:32 0 10G 0 disk
└─testvg-testlv 253:2 0 5G 0 lvm /users
sdd 8:48 0 10G 0 disk
sr0 11:0 1 1024M 0 rom