虚拟机磁盘扩容parted
1、虛擬化平臺虛擬機添加硬盤
系統查看添加的硬盤
| 1 2 3 4 5 6 7 8 | [root@yumserver?~]#?lsblk NAME????????????MAJ:MIN?RM??SIZE?RO?TYPE?MOUNTPOINT sda???????????????8:0????0???50G??0?disk? ├─sda1????????????8:1????0????1G??0?part?/boot └─sda2????????????8:2????0???49G??0?part? ??├─centos-root?253:0????0???44G??0?lvm??/ ??└─centos-swap?253:1????0????5G??0?lvm??[SWAP] sr0??????????????11:0????1??4.4G??0?rom |
如果沒有顯示出來新加的硬盤,則執行下面命令
| 1 2 3 | ?echo?"-?-?-">/sys/class/scsi_host/host0/scan ?echo?"-?-?-"?>/sys/class/scsi_host/host1/scan ?echo?"-?-?-"?>/sys/class/scsi_host/host2/scan |
再次查詢,發現新添加的sdb已經可以看到了。
| 1 2 3 4 5 6 7 8 9 | [root@yumserver?~]#?lsblk NAME????????????MAJ:MIN?RM??SIZE?RO?TYPE?MOUNTPOINT sda???????????????8:0????0???50G??0?disk? ├─sda1????????????8:1????0????1G??0?part?/boot └─sda2????????????8:2????0???49G??0?part? ??├─centos-root?253:0????0???44G??0?lvm??/ ??└─centos-swap?253:1????0????5G??0?lvm??[SWAP] sdb???????????????8:16???0???50G??0?disk? sr0??????????????11:0????1??4.4G??0?rom |
2、parted將sdb分區
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | [root@yumserver?~]#?parted?/dev/sdb GNU?Parted?3.1 使用?/dev/sdb Welcome?to?GNU?Parted!?Type?'help'?to?view?a?list?of?commands. (parted)?mklabel?gpt?????????????????????????????????????????????????????? (parted)?mkpart?primary?0%?100%??????????????????????????????????????????? (parted)?p???????????????????????????????????????????????????????????????? Model:?VMware?Virtual?disk?(scsi) Disk?/dev/sdb:?53.7GB Sector?size?(logical/physical):?512B/512B Partition?Table:?gpt Disk?Flags:? Number??Start???End?????Size????File?system??Name?????標志 ?1??????1049kB??53.7GB??53.7GB???????????????primary (parted)?q???????????????????????????????????????????????????????????????? 信息:?You?may?need?to?update?/etc/fstab. [root@yumserver?~]# |
再次查看,發現主分區sdb1出現了
| 1 2 3 4 5 6 7 8 9 10 11 | [root@yumserver?~]#?lsblk????????????????????????????????????????????????? NAME????????????MAJ:MIN?RM??SIZE?RO?TYPE?MOUNTPOINT sda???????????????8:0????0???50G??0?disk? ├─sda1????????????8:1????0??500M??0?part?/boot └─sda2????????????8:2????0?49.5G??0?part? ??├─centos-root?253:0????0?47.5G??0?lvm??/ ??└─centos-swap?253:1????0????2G??0?lvm??[SWAP] sdb???????????????8:16???0???50G??0?disk? └─sdb1????????????8:17???0???50G??0?part? sr0??????????????11:0????1?1024M??0?rom?? [root@yumserver?~]# |
3?、查看現有vg,lv,確定擴容
| 1 2 3 4 5 6 7 8 9 10 11 | [root@yumserver?~]#?pvs ??PV?????????VG?????Fmt??Attr?PSize???PFree ??/dev/sda2??centos?lvm2?a--??<49.51g????0? [root@yumserver?~]#?vgs ??VG?????#PV?#LV?#SN?Attr???VSize???VFree ??centos???1???2???0?wz--n-?<49.51g????0? [root@yumserver?~]#?lvs ??LV???VG?????Attr???????LSize???Pool?Origin?Data%??Meta%??Move?Log?Cpy%Sync?Convert ??root?centos?-wi-ao----?<47.51g???????????????????????????????????????????????????? ??swap?centos?-wi-ao----???2.00g???????????????????????????????????????????????????? [root@yumserver?~]# |
3?、分別創建pv,擴容vg,擴容lv,擴容文件系統
##此處發現不能tab補全命令,?yum install -y bash-completion
| 1 2 | [root@yumserver?~]#?pvcreate?/dev/sdb1 ??Physical?volume?"/dev/sdb1"?successfully?created. |
| 1 2 | [root@yumserver?~]#?vgextend?centos?/dev/sdb1 ??Volume?group?"centos"?successfully?extended |
| 1 2 3 | [root@yumserver?~]#?lvextend?/dev/centos/root?-l?+100%FREE ??Size?of?logical?volume?centos/root?changed?from?<47.51?GiB?(12162?extents)?to?97.50?GiB?(24961?extents). ??Logical?volume?centos/root?successfully?resized. |
此處為xfs
| 1 | [root@yumserver?~]#?xfs_growfs?/dev/centos/root |
再次查看,/目錄擴容成功
| 1 2 3 4 5 6 7 8 9 | [root@yumserver?~]#?df?-h 文件系統?????????????????容量??已用??可用?已用%?掛載點 devtmpfs?????????????????3.9G?????0??3.9G????0%?/dev tmpfs????????????????????3.9G?????0??3.9G????0%?/dev/shm tmpfs????????????????????3.9G??8.9M??3.9G????1%?/run tmpfs????????????????????3.9G?????0??3.9G????0%?/sys/fs/cgroup /dev/mapper/centos-root???98G??1.4G???97G????2%?/ /dev/sda1????????????????497M??143M??354M???29%?/boot tmpfs????????????????????783M?????0??783M????0%?/run/user/0 |
如果覺得對你有用,給點個贊吧.
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的虚拟机磁盘扩容parted的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【LINUX】Oracle数据库 lin
- 下一篇: Linux 中 ss 命令的使用实例介绍