1、破坏mbr表并修复
#1、 备份MBR分区表到另外一台机器
[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分区表
[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、重启后无法进入系统
[root@localhost ~]# reboot
#4、用光盘启动,进入rescue mode,选第3项skip to shell
#进去后配置本机IP与备份那台做连接
#ifconfig ens160 10.0.0.201/24
#5、拷贝备份的MBR表
#scp 10.0.0.203:/root/dpt.img .
#6、恢复MBR分区表,重启正常进入系统
#dd if=dpt.img of=/dev/sda bs=1 seek=446
#exit
2、总结RAID的各个级别及其组合方式和性能的不同。
下面是常用的RAID
RAID0特性:
- 读写性能提升;
- 可用空间,N*min
- 无容错能力;
- 最小磁盘数2,2+
RAID1特性:
- 读性能提升,写性能略有下降,同一份数据要存两份;
- 可用空间,1*min,磁盘总空间的一半;
- 有冗余能力;
- 最少磁盘数,2,2+;
RAID5特性:
- 读写性能提升;
- 可用空间,N-1*min;
- 有冗余能力;
- 最少磁盘数,3,3+;
RAID10特性:
- 读写性能提升;
- 可用空间,N*min/2;
- 有冗余能力,每组镜像最多只能坏一块;
- 最少磁盘数,4,4+;
3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
#1、查看硬盘信息,一下将sdb作为操作目标
[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磁盘上创建大小为2G的分区
[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分区上创建文件系统
[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
#文件系统已经创建
[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、将分区挂载在/test目录中
# 在/etc/fstab文件末尾添加以下内容
[root@centos7 ~]# vim /etc/fstab
UUID=79450cbb-b1c7-447a-ab06-129afa93eb02 /test ext4 acl 0 0
#5、创建目标文件夹使配置生效
[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、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
#1、查看磁盘信息,以下操作将以sdc、sdd作为操作目标
[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、创建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、创建名为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、创建大小为5G的逻辑卷testlv,并建立文件系统
[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
#建立文件系统
[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、创建/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