柒
作者:互联网
1、破坏mbr表并修复。
答:① 备份mbr分区表。
dd if=/dev/sda of=dpt.img bs=1 count=64 skip=446:生成mbr分区表,到dpt.img文件。
scp /root/dpt.img 10.0.0.27:/data:远程复制dpt.img文件,到10.0.0.27服务器的/data目录中。
[root@centos7mini ~]#dd if=/dev/sda of=dpt.img bs=1 count=64 skip=446
64+0 records in
64+0 records out
64 bytes (64 B) copied, 0.00026209 s, 244 kB/s
[root@centos7mini ~]#ls dpt.img
dpt.img
[root@centos7mini ~]#scp /root/dpt.img 10.0.0.27:/data
The authenticity of host '10.0.0.27 (10.0.0.27)' can't be established.
ECDSA key fingerprint is SHA256:aZ9KspCQ179viUkXhEFYw6EM1GN/ij913jH9ERjZYv0.
ECDSA key fingerprint is MD5:d1:29:63:fd:91:6e:28:cb:a9:4b:0b:9a:b5:8c:56:95.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.27' (ECDSA) to the list of known hosts.
root@10.0.0.27's password:
dpt.img 100% 64 1.1KB/s 00:00
[root@centos7mini ~]#
② 破坏mbr分区表。
[root@centos7mini ~]#dd if=/dev/zero of=/dev/sda bs=1 count=64 seek=446
64+0 records in
64+0 records out
64 bytes (64 B) copied, 0.000359388 s, 178 kB/s
[root@centos7mini ~]#hexdump -C /dev/sda -n 512 -v
...
000001b0 00 00 00 00 00 00 00 00 19 a6 0b 00 00 00 00 00 |................|
000001c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001e0 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@centos7mini ~]#
③ reboot:重启系统。
④ 用光盘启动系统,进入"rescue mode",选择第3项"skip to shell"。
a. 在出现进度条的时候,点击Esc键,弹出对话框。
注:鼠标一定要进入VMware虚拟机,否则无效。
b. 在弹出的对话框中,选择“3. CD-ROM Drive”。
c. 选择“Troubleshooting”。
d. 选择“Rescue a CentOS system”。
e. 选择“Skip to shell”。
⑤ 临时配置网络。
ip a a 10.0.0.17/24 dev ens33:IP地址为10.0.0.17,子网掩码为255.255.255.0,网卡名称为ens33。
⑥ scp 10.0.0.27:/data/dpt.img .:远程复制10.0.0.27服务器的/data/dpt.img文件,到当前目录中。
⑦ 恢复mbr分区表。
dd if=dpt.img of=/dev/sda bs=1 count=64 seek=446:把dpt.img文件,赋值到mbr分区表中。
⑧ reboot:重启系统。
2、总结RAID的各个级别及其组合方式和性能的不同。
答:① RAID-0:
读写性能:提升
可用空间:等于硬盘数。空间利用率:100%
容错能力:无。1块硬盘损坏,导致其它硬盘的数据损坏
最少硬盘数:2块硬盘及以上
② RAID-1:
镜像
读写性能:读性能提升,写性能略有下降
可用空间:等于硬盘数的一半。空间利用率:50%
容错能力:有
最少硬盘数:2的整数倍硬盘
③ RAID-5:
读写性能:提升
可用空间:等于硬盘数减1。空间利用率:(N - 1)/ N
容错能力:有。允许最多1块硬盘损坏
最少硬盘数:3块硬盘及以上
④ RAID-6:
读写性能:提升
可用空间:等于硬盘数减2。空间利用率:(N - 2)/ N
容错能力:有。允许最多2块硬盘损坏
最少硬盘数:4块硬盘及以上
⑤ RAID-10:
多块硬盘先组合成RAID-1,再组合成RAID-0
读写性能:提升
可用空间:等于硬盘数的一半。空间利用率:50%
容错能力:有。每组镜像硬盘最多只能损坏1块
最少硬盘数:4块硬盘及以上
3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项。
答:① 创建一个2G的分区。
[root@centos7mini ~]#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.
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 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
Disk label type: dos
Disk identifier: 0x3c35ffd8
Device Boot Start End Blocks Id System
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response 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): p
Disk /dev/sdb: 21.5 GB, 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
Disk label type: dos
Disk identifier: 0x3c35ffd8
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@centos7mini ~]#
[root@centos7mini ~]#lsblk /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 2G 0 part
[root@centos7mini ~]#
② 创建文件系统,块大小为2048byte,预留1%可用空间,文件系统ext4,卷标为TEST。
[root@centos7mini ~]#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@centos7mini ~]#
[root@centos7mini ~]#lsblk -f /dev/sdb
NAME FSTYPE LABEL UUID MOUNTPOINT
sdb
└─sdb1 ext4 TEST ceb1b037-c69c-40d8-adaa-b3673c21c740
[root@centos7mini ~]#
③ 此分区开机后自动挂载至/test目录,且默认有acl挂载选项。
[root@centos7mini ~]#mkdir /test
[root@centos7mini ~]#
[root@centos7mini ~]#vim /etc/fstab
/dev/sdb1: LABEL="TEST" UUID="ceb1b037-c69c-40d8-adaa-b3673c21c740" TYPE="ext4"
Press ENTER or type command to continue
[root@centos7mini ~]#
[root@centos7mini ~]#cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu May 13 20:29:02 2021
#
# 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=39e66903-b3bb-4664-844e-9cf1e1726ec9 / xfs defaults 0 0
UUID=2a13f5bb-2492-4f2f-a446-c4ce2df5dbd4 /boot xfs defaults 0 0
UUID=84966365-16e6-408f-aff3-92156186ae70 /data xfs defaults 0 0
UUID=0ebd701e-9490-4871-ac93-748168c60cfc swap swap defaults 0 0
UUID=ceb1b037-c69c-40d8-adaa-b3673c21c740 /test ext4 defaults,acl 0 0
[root@centos7mini ~]#
[root@centos7mini ~]#mount -a
[root@centos7mini ~]#
[root@centos7mini ~]#df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 900M 0 900M 0% /dev
tmpfs 910M 0 910M 0% /dev/shm
tmpfs 910M 9.6M 901M 2% /run
tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/sda2 100G 2.0G 98G 2% /
/dev/sda3 50G 33M 50G 1% /data
/dev/sda1 1014M 142M 873M 15% /boot
tmpfs 182M 0 182M 0% /run/user/0
/dev/sdb1 2.0G 9.1M 1.9G 1% /test
[root@centos7mini ~]#
4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG,要求PE大小为16MB,而后在卷组中创建大小为5G的逻辑卷testlv,挂载至/users目录。
答:① 创建两个物理卷,两者组成的空间大小为20G。
[root@centos7mini ~]#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.
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p):
Using default response p
Partition number (2-4, default 2):
First sector (4196352-41943039, default 4196352):
Using default value 4196352
Last sector, +sectors or +size{K,M,G} (4196352-41943039, default 41943039):
Using default value 41943039
Partition 2 of type Linux and of size 18 GiB is set
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 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
Disk label type: dos
Disk identifier: 0x3c35ffd8
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 41943039 18873344 83 Linux
Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 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
Disk label type: dos
Disk identifier: 0x3c35ffd8
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 41943039 18873344 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@centos7mini ~]#
[root@centos7mini ~]#partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
[root@centos7mini ~]#
[root@centos7mini ~]#lsblk /dev/sdb2 /dev/sdc
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb2 8:18 0 18G 0 part
sdc 8:32 0 2G 0 disk
[root@centos7mini ~]#
[root@centos7mini ~]#pvcreate /dev/sdb2 /dev/sdc
Physical volume "/dev/sdb2" successfully created.
Physical volume "/dev/sdc" successfully created.
[root@centos7mini ~]#
[root@centos7mini ~]#pvs
PV VG Fmt Attr PSize PFree
/dev/sdb2 lvm2 --- <18.00g <18.00g
/dev/sdc lvm2 --- 2.00g 2.00g
[root@centos7mini ~]#
② 创建卷组,名称为testvg,PE大小为16MB。
[root@centos7mini ~]#vgcreate -s 16M testvg /dev/sdb2 /dev/sdc
Volume group "testvg" successfully created
[root@centos7mini ~]#
[root@centos7mini ~]#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 PZsbjt-t8am-IUy0-hwve-515t-dIVP-JT1CRh
[root@centos7mini ~]#
③ 创建逻辑卷,名称为testlv,空间大小为5G。
[root@centos7mini ~]#lvcreate -n testlv -L 5G testvg
Logical volume "testlv" created.
[root@centos7mini ~]#
[root@centos7mini ~]#lvdisplay
--- Logical volume ---
LV Path /dev/testvg/testlv
LV Name testlv
VG Name testvg
LV UUID oKPlnd-5hI6-Og1T-XYdH-aFEn-YYeB-Ukpihu
LV Write Access read/write
LV Creation host, time centos7mini, 2022-02-21 23:57:01 +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@centos7mini ~]#
④ 创建文件系统,类型为ext4。(题目中没有要求类型)
[root@centos7mini ~]#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
[root@centos7mini ~]#
[root@centos7mini ~]#blkid /dev/testvg/testlv
/dev/testvg/testlv: UUID="8e7e8dc4-4e60-486c-baea-de2b44fdef9b" TYPE="ext4"
[root@centos7mini ~]#
⑤ 挂载至/users目录。
[root@centos7mini ~]#mkdir /users
[root@centos7mini ~]#
[root@centos7mini ~]#vim /etc/fstab
/dev/testvg/testlv: UUID="8e7e8dc4-4e60-486c-baea-de2b44fdef9b" TYPE="ext4"
Press ENTER or type command to continue
[root@centos7mini ~]#
[root@centos7mini ~]#cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu May 13 20:29:02 2021
#
# 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=39e66903-b3bb-4664-844e-9cf1e1726ec9 / xfs defaults 0 0
UUID=2a13f5bb-2492-4f2f-a446-c4ce2df5dbd4 /boot xfs defaults 0 0
UUID=84966365-16e6-408f-aff3-92156186ae70 /data xfs defaults 0 0
UUID=0ebd701e-9490-4871-ac93-748168c60cfc swap swap defaults 0 0
UUID=ceb1b037-c69c-40d8-adaa-b3673c21c740 /test ext4 defaults,acl 0 0
UUID=8e7e8dc4-4e60-486c-baea-de2b44fdef9b /users ext4 defaults 0 0
[root@centos7mini ~]#
[root@centos7mini ~]#mount -a
[root@centos7mini ~]#
[root@centos7mini ~]#df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 900M 0 900M 0% /dev
tmpfs 910M 0 910M 0% /dev/shm
tmpfs 910M 9.6M 901M 2% /run
tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/sda2 100G 2.0G 98G 2% /
/dev/sda3 50G 33M 50G 1% /data
/dev/sda1 1014M 142M 873M 15% /boot
tmpfs 182M 0 182M 0% /run/user/0
/dev/sdb1 2.0G 9.1M 1.9G 1% /test
/dev/mapper/testvg-testlv 4.8G 20M 4.6G 1% /users
[root@centos7mini ~]#
标签:,00,bytes,dev,centos7mini,512,root 来源: https://www.cnblogs.com/qcjiayou/p/15921334.html