七、磁盤奄喂、文件系統(tǒng)

1之剧、破壞mbr表并修復(fù)

 #第一步,需要事先備份好MBR分區(qū)表砍聊,或者從其他服務(wù)器獲取MBR分區(qū)表
 #總共是512bytes背稼,前446bytes是 boot loader;后64bytes是分區(qū)表
 #使用dd工具玻蝌,備份64bytes的分區(qū)表蟹肘,通過scp將備份數(shù)據(jù)傳輸?shù)狡渌?wù)器
[root@centos8 ~]#dd if=/dev/sda of=/data/dpt.img bs=1 count=64 skip=446
[root@Centos7 data]# hexdump -C dpt.img 

00000000  80 20 21 00 83 35 70 05  00 08 00 00 00 00 40 00  |. !..5p.......@.|
00000010  00 35 71 05 83 fe ff ff  00 08 40 00 00 00 40 06  |.5q.......@...@.|
00000020  00 fe ff ff 82 fe ff ff  00 08 80 06 00 00 40 00  |..............@.|
00000030  00 fe ff ff 05 fe ff ff  00 08 c0 06 00 f8 3f 12  |..............?.|
00000040

[root@Centos7 ~]#scp /data/dpt.img 10.154.119.134:
root@10.154.119.134's password: 
dpt.img                                                               100%   64    44.2KB/s   00:00    
 
 #破壞MBR分區(qū)表
 #skip是跳過讀取文件的位數(shù),seek是跳過寫入文件的位數(shù)
[root@centos8 ~]#dd if=/dev/zero of=/dev/sda bs=1 count=64 seek=446
[root@centos8 ~]#reboot


#用光盤啟動,進入rescue mode,選第3項skip to shell
#啟動之后俯树,發(fā)現(xiàn)沒有網(wǎng)絡(luò)帘腹,需要配置臨時網(wǎng)絡(luò)
#從遠(yuǎn)程服務(wù)器獲取到分區(qū)表的備份
sh-4.4#ifconfig ens33 10.154.119.140/24
sh-4.4#scp 10.154.119.134:/root/dpt.img .

#恢復(fù)MBR分區(qū)表
sh-4.4#dd if=dpt.img of=/dev/sda bs=1 seek=446
sh-4.4#exit

2、總結(jié)RAID的各個級別及其組合方式和性能的不同许饿。

1??RAID概念:獨立磁盤冗余陣列阳欲。多個磁盤合成一個陣列,以此來提供更好的性能、冗余球化。

常見raid級別統(tǒng)計:

raid級別 組合方式 性能 冗余
raid-0 最少2塊磁盤 讀寫性能提升
raid-1 2N塊磁盤 讀性能提升秽晚、寫性能下降 另一塊磁盤為復(fù)制作用
raid-5 最少3塊磁盤 讀寫性能提升 最多一塊磁盤損壞
raid-10 最少4塊磁盤 讀寫性能提升 每組鏡像只能壞一塊磁盤
raid-01 最少4塊磁盤 讀寫性能提升 安全性差,不建議使用

3筒愚、創(chuàng)建一個2G的文件系統(tǒng)赴蝇,塊大小為2048byte,預(yù)留1%可用空間,文件系統(tǒng) ext4巢掺,卷標(biāo)為TEST句伶,要求此分區(qū)開機后自動掛載至/test目錄,且默認(rèn)有acl掛載選項

#創(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 0xdd10be81.

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): 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
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@Centos7 ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  200G  0 disk 
├─sda1   8:1    0    2G  0 part /boot
├─sda2   8:2    0   50G  0 part /data
├─sda3   8:3    0    2G  0 part [SWAP]
├─sda4   8:4    0    1K  0 part 
└─sda5   8:5    0  100G  0 part /
sdb      8:16   0   20G  0 disk 
└─sdb1   8:17   0    2G  0 part 
sr0     11:0    1  4.4G  0 rom  

#新建文件系統(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)的屬性
[root@Centos7 ~]# blkid
/dev/sda1: UUID="71afae2d-2416-4c68-8375-e27437e32fa3" TYPE="xfs" 
/dev/sda2: UUID="bb537f14-b824-402e-81c3-63b87a82052a" TYPE="xfs" 
/dev/sda3: UUID="bb38c0b6-b4b3-41b8-96f9-30af2315226c" TYPE="swap" 
/dev/sda5: UUID="3089f417-1bba-4347-8f21-a4581fce760a" TYPE="xfs" 
/dev/sdb1: LABEL="test" UUID="328b2c3a-065f-4ef6-8523-af102f02afd3" TYPE="ext4" 
/dev/sr0: UUID="2020-11-04-11-36-43-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos" 

[root@Centos7 ~]# mkdir /test
[root@Centos7 ~]# mount -a
mount: /etc/fstab: parse error: ignore entry at line 3.
mount: /etc/fstab: parse error: ignore entry at line 4.
mount: /etc/fstab: parse error: ignore entry at line 6.
mount: /etc/fstab: parse error: ignore entry at line 7.

#將分區(qū)掛載到指定文件夾
[root@Centos7 ~]# vim /etc/fstab
/etc/fstab
Created by anaconda on Wed Nov 25 10:31:24 2020
#
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=3089f417-1bba-4347-8f21-a4581fce760a /                       xfs     defaults        0 0
UUID=71afae2d-2416-4c68-8375-e27437e32fa3 /boot                   xfs     defaults        0 0
UUID=bb537f14-b824-402e-81c3-63b87a82052a /data                   xfs     defaults        0 0
UUID=bb38c0b6-b4b3-41b8-96f9-30af2315226c swap                    swap    defaults        0 0
UUID=328b2c3a-065f-4ef6-8523-af102f02afd3 /test                   ext4    acl             0 0

[root@Centos7 ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  200G  0 disk 
├─sda1   8:1    0    2G  0 part /boot
├─sda2   8:2    0   50G  0 part /data
├─sda3   8:3    0    2G  0 part [SWAP]
├─sda4   8:4    0    1K  0 part 
└─sda5   8:5    0  100G  0 part /
sdb      8:16   0   20G  0 disk 
└─sdb1   8:17   0    2G  0 part /test
sr0     11:0    1  4.4G  0 rom 

4陆淀、創(chuàng)建一個至少有兩個PV組成的大小為20G的名為testvg的VG;要求PE大小為16MB, 而后在卷組中創(chuàng)建大小為5G的邏輯卷testlv;掛載至/users目錄

#第一步:創(chuàng)建分區(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.


Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): 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): +10G
Partition 2 of type Linux and of size 10 GiB is set

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): w
The partition table has been altered!

[root@Centos7 ~]# fdisk /dev/sdc
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): p
Partition number (1-4, default 1): 
First sector (4196352-41943039, default 4196352): 
Using default value 4196352
Last sector, +sectors or +size{K,M,G} (4196352-41943039, default 41943039): +10G
Partition 2 of type Linux and of size 10 GiB is set

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): w
The partition table has been altered!

[root@Centos7 ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  200G  0 disk 
├─sda1   8:1    0    2G  0 part /boot
├─sda2   8:2    0   50G  0 part /data
├─sda3   8:3    0    2G  0 part [SWAP]
├─sda4   8:4    0  512B  0 part 
└─sda5   8:5    0  100G  0 part /
sdb      8:16   0   20G  0 disk 
├─sdb1   8:17   0    2G  0 part /test
└─sdb2   8:18   0   10G  0 part 
sdc      8:32   0   30G  0 disk 
└─sdc1   8:33   0   10G  0 part 
sr0     11:0    1  4.4G  0 rom

#第二步:創(chuàng)建物理卷(pv)
[root@Centos7 ~]# pvcreate /dev/sd{b2,c1}
  Physical volume "/dev/sdb2" successfully created.
  Physical volume "/dev/sdc1" successfully created.
[root@Centos7 ~]# pvs
  PV         VG Fmt  Attr PSize  PFree 
  /dev/sdb2     lvm2 ---  10.00g 10.00g
  /dev/sdc1     lvm2 ---  10.00g 10.00g

#第三步:創(chuàng)建物理卷組 (vg)
[root@Centos7 ~]# vgcreate -s 16M testvg /dev/sd{b2,c1}
  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

#第四步:創(chuàng)建邏輯卷
[root@Centos7 ~]# lvcreate -n testlv -L 5G testvg
  Logical volume "testlv" created.

[root@Centos7 ~]# blkid
/dev/sr0: UUID="2020-11-04-11-36-43-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos" 
/dev/sdb1: LABEL="test" UUID="328b2c3a-065f-4ef6-8523-af102f02afd3" TYPE="ext4" 
/dev/sdb2: UUID="jSJtTC-YIss-VkXv-FNjH-n62y-3OhT-9pBFMN" TYPE="LVM2_member" 
/dev/sdc1: UUID="FMqJay-13AP-zKVy-NNLg-oTEZ-ecln-VvmE6b" TYPE="LVM2_member" 
/dev/sda1: UUID="71afae2d-2416-4c68-8375-e27437e32fa3" TYPE="xfs" 
/dev/sda2: UUID="bb537f14-b824-402e-81c3-63b87a82052a" TYPE="xfs" 
/dev/sda3: UUID="bb38c0b6-b4b3-41b8-96f9-30af2315226c" TYPE="swap" 
/dev/sda5: UUID="3089f417-1bba-4347-8f21-a4581fce760a" TYPE="xfs"

#第五步:創(chuàng)建文件系統(tǒng)
[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 ~]# blkid 
/dev/sr0: UUID="2020-11-04-11-36-43-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos" 
/dev/sdb1: LABEL="test" UUID="328b2c3a-065f-4ef6-8523-af102f02afd3" TYPE="ext4" 
/dev/sdb2: UUID="jSJtTC-YIss-VkXv-FNjH-n62y-3OhT-9pBFMN" TYPE="LVM2_member" 
/dev/sdc1: UUID="FMqJay-13AP-zKVy-NNLg-oTEZ-ecln-VvmE6b" TYPE="LVM2_member" 
/dev/sda1: UUID="71afae2d-2416-4c68-8375-e27437e32fa3" TYPE="xfs" 
/dev/sda2: UUID="bb537f14-b824-402e-81c3-63b87a82052a" TYPE="xfs" 
/dev/sda3: UUID="bb38c0b6-b4b3-41b8-96f9-30af2315226c" TYPE="swap" 
/dev/sda5: UUID="3089f417-1bba-4347-8f21-a4581fce760a" TYPE="xfs" 
/dev/mapper/testvg-testlv: UUID="b093f68c-f893-48e8-8b53-191a98ffa106" TYPE="xfs" 

[root@Centos7 ~]# mkdir /users
[root@Centos7 ~]# vim /etc/fstab 

#
/etc/fstab
Created by anaconda on Wed Nov 25 10:31:24 2020
#
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=3089f417-1bba-4347-8f21-a4581fce760a /                       xfs     defaults        0 0
UUID=71afae2d-2416-4c68-8375-e27437e32fa3 /boot                   xfs     defaults        0 0
UUID=bb537f14-b824-402e-81c3-63b87a82052a /data                   xfs     defaults        0 0
UUID=bb38c0b6-b4b3-41b8-96f9-30af2315226c swap                    swap    defaults        0 0
UUID=328b2c3a-065f-4ef6-8523-af102f02afd3 /test           ext4    acl             0 0
UUID=b093f68c-f893-48e8-8b53-191a98ffa106 /users          xfs     defaults        0 0



[root@Centos7 ~]# mount -a
mount: /etc/fstab: parse error: ignore entry at line 3.
mount: /etc/fstab: parse error: ignore entry at line 4.
mount: /etc/fstab: parse error: ignore entry at line 6.
mount: /etc/fstab: parse error: ignore entry at line 7.

[root@Centos7 ~]# df
Filesystem                1K-blocks    Used Available Use% Mounted on
devtmpfs                     487084       0    487084   0% /dev
tmpfs                        497852       0    497852   0% /dev/shm
tmpfs                        497852    7836    490016   2% /run
tmpfs                        497852       0    497852   0% /sys/fs/cgroup
/dev/sda5                 104806400 1840400 102966000   2% /
/dev/sda2                  52403200   33000  52370200   1% /data
/dev/sdb1                   1998538    9236   1960140   1% /test
/dev/sda1                   2086912  134324   1952588   7% /boot
tmpfs                         99572       0     99572   0% /run/user/0
/dev/mapper/testvg-testlv   5232640   32992   5199648   1% /users


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市轧苫,隨后出現(xiàn)的幾起案子秃殉,更是在濱河造成了極大的恐慌,老刑警劉巖浸剩,帶你破解...
    沈念sama閱讀 218,284評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件钾军,死亡現(xiàn)場離奇詭異,居然都是意外死亡绢要,警方通過查閱死者的電腦和手機吏恭,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,115評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來重罪,“玉大人樱哼,你說我怎么就攤上這事〗伺洌” “怎么了搅幅?”我有些...
    開封第一講書人閱讀 164,614評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長呼胚。 經(jīng)常有香客問我茄唐,道長,這世上最難降的妖魔是什么蝇更? 我笑而不...
    開封第一講書人閱讀 58,671評論 1 293
  • 正文 為了忘掉前任沪编,我火速辦了婚禮,結(jié)果婚禮上年扩,老公的妹妹穿的比我還像新娘蚁廓。我一直安慰自己,他們只是感情好厨幻,可當(dāng)我...
    茶點故事閱讀 67,699評論 6 392
  • 文/花漫 我一把揭開白布相嵌。 她就那樣靜靜地躺著腿时,像睡著了一般。 火紅的嫁衣襯著肌膚如雪饭宾。 梳的紋絲不亂的頭發(fā)上批糟,一...
    開封第一講書人閱讀 51,562評論 1 305
  • 那天,我揣著相機與錄音捏雌,去河邊找鬼。 笑死笆搓,一個胖子當(dāng)著我的面吹牛性湿,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播满败,決...
    沈念sama閱讀 40,309評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼肤频,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了算墨?” 一聲冷哼從身側(cè)響起宵荒,我...
    開封第一講書人閱讀 39,223評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎净嘀,沒想到半個月后报咳,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,668評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡挖藏,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,859評論 3 336
  • 正文 我和宋清朗相戀三年暑刃,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片膜眠。...
    茶點故事閱讀 39,981評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡岩臣,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出宵膨,到底是詐尸還是另有隱情架谎,我是刑警寧澤,帶...
    沈念sama閱讀 35,705評論 5 347
  • 正文 年R本政府宣布辟躏,位于F島的核電站谷扣,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏捎琐。R本人自食惡果不足惜抑钟,卻給世界環(huán)境...
    茶點故事閱讀 41,310評論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望野哭。 院中可真熱鬧在塔,春花似錦、人聲如沸拨黔。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,904評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至贺待,卻和暖如春徽曲,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背麸塞。 一陣腳步聲響...
    開封第一講書人閱讀 33,023評論 1 270
  • 我被黑心中介騙來泰國打工秃臣, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人哪工。 一個月前我還...
    沈念sama閱讀 48,146評論 3 370
  • 正文 我出身青樓奥此,卻偏偏與公主長得像,于是被迫代替她去往敵國和親雁比。 傳聞我的和親對象是個殘疾皇子稚虎,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,933評論 2 355

推薦閱讀更多精彩內(nèi)容