Linux系統mbr修復及邏輯卷的管理

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

Linux系統mbr修復及邏輯卷的管理
Linux系統mbr修復及邏輯卷的管理
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 ~]#
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章