linux 虚拟机扩展硬盘后扩展到分区
生活随笔
收集整理的這篇文章主要介紹了
linux 虚拟机扩展硬盘后扩展到分区
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
| 導讀 | 我們管理的服務器可能會隨著業務量的不斷增長造成磁盤空間不足的情況,比如:共享文件服務器硬盤空間不足,在這個時候我們就需要增加磁盤空間,來滿足線上的業務;又或者我們在使用linux的過程中, 有時會因為安裝系統時分區不當導致有的分區空間不足,而有的分區空間過剩的情況,都可以是使用fdisk分區工具來動態調整分區的大小; |
擴展磁盤空間
硬盤空間為20G,使用vSphere Client增加磁盤大小,需要再增加10G空間;
擴展完后,重啟系統,再次使用fdisk -l查看,會發現硬盤空間變大了;
[root@linuxprobe?~]#?fdisk?-l Disk?/dev/sda:?32.2?GB,?32212254720?bytes 255?heads,?63?sectors/track,?3916?cylinders Units?=?cylinders?of?16065?*?512?=?8225280?bytes Sector?size?(logical/physical):?512?bytes?/?512?bytes I/O?size?(minimum/optimal):?512?bytes?/?512?bytes Disk?identifier:?0x0005210cDevice?Boot??????Start?????????End??????Blocks???Id??System /dev/sda1???*???????????1??????????26??????204800???83??Linux Partition?1?does?not?end?on?cylinder?boundary. /dev/sda2??????????????26????????1301????10240000???83??Linux /dev/sda3????????????1301????????1497?????1572864???82??Linux?swap?/?Solaris /dev/sda4????????????1497????????2611?????8952832???83??Linux [root@linuxprobe?~]#?df?-hT Filesystem?????Type???Size??Used?Avail?Use%?Mounted?on /dev/sda2??????ext4???9.7G??1.5G??7.7G??16%?/ tmpfs??????????tmpfs??939M?????0??939M???0%?/dev/shm /dev/sda1??????ext4???194M???34M??151M??19%?/boot /dev/sda4??????ext4???8.5G??148M??7.9G???2%?/data重新創建分區,調整分區信息
本次實驗主要對/dev/sda4這個分區擴展,如果是生產環境,請提前做好備份保存到其他分區,雖然擴展分區大小不會導致數據丟失,安全起見,請提前做好備份;
首先模擬出一些數據:
若提示磁盤忙,使用fuser找出將正在使用磁盤的程序并結束掉;
fuser?-m?-v?/data fuser?-m?-v?-i?-k?/data使用fdisk工具先刪除/dev/sda4分區,然后創建新分區,注意開始的磁柱號要和原來的一致(是保證數據不丟失的關鍵步驟),結束的磁柱號默認回車使用全部磁盤。
[root@linuxprobe?~]#?fdisk?/dev/sdaWARNING:?DOS-compatible?mode?is?deprecated.?It's?strongly?recommended?toswitch?off?the?mode?(command?'c')?and?change?display?units?tosectors?(command?'u').Command?(m?for?help):?p????????#查看分區表信息Disk?/dev/sda:?32.2?GB,?32212254720?bytes 255?heads,?63?sectors/track,?3916?cylinders Units?=?cylinders?of?16065?*?512?=?8225280?bytes Sector?size?(logical/physical):?512?bytes?/?512?bytes I/O?size?(minimum/optimal):?512?bytes?/?512?bytes Disk?identifier:?0x0005210cDevice?Boot??????Start?????????End??????Blocks???Id??System /dev/sda1???*???????????1??????????26??????204800???83??Linux Partition?1?does?not?end?on?cylinder?boundary. /dev/sda2??????????????26????????1301????10240000???83??Linux /dev/sda3????????????1301????????1497?????1572864???82??Linux?swap?/?Solaris /dev/sda4????????????1497????????2611?????8952832???83??LinuxCommand?(m?for?help):?d???????????#刪除分區Partition?number?(1-4):?4?????????#刪除第四個Command?(m?for?help):?p???????#再次查看分區信息,/dev/sda4已被刪除Disk?/dev/sda:?32.2?GB,?32212254720?bytes 255?heads,?63?sectors/track,?3916?cylinders Units?=?cylinders?of?16065?*?512?=?8225280?bytes Sector?size?(logical/physical):?512?bytes?/?512?bytes I/O?size?(minimum/optimal):?512?bytes?/?512?bytes Disk?identifier:?0x0005210cDevice?Boot??????Start?????????End??????Blocks???Id??System /dev/sda1???*???????????1??????????26??????204800???83??Linux Partition?1?does?not?end?on?cylinder?boundary. /dev/sda2??????????????26????????1301????10240000???83??Linux /dev/sda3????????????1301????????1497?????1572864???82??Linux?swap?/?SolarisCommand?(m?for?help):?n??????#創建新的分區Command?actione???extendedp???primary?partition?(1-4) p?????????????#創建為主分區 Selected?partition?4 First?cylinder?(1497-3916,?default?1497):??????????#經對比,正好和上一個磁盤柱一致,默認即可Using?default?value?1497 Last?cylinder,?+cylinders?or?+size{K,M,G}?(1497-3916,?default?3916):? Using?default?value?3916??????????????#直接默認就可以Command?(m?for?help):?p???????????????#查看分區表信息Disk?/dev/sda:?32.2?GB,?32212254720?bytes 255?heads,?63?sectors/track,?3916?cylinders Units?=?cylinders?of?16065?*?512?=?8225280?bytes Sector?size?(logical/physical):?512?bytes?/?512?bytes I/O?size?(minimum/optimal):?512?bytes?/?512?bytes Disk?identifier:?0x0005210cDevice?Boot??????Start?????????End??????Blocks???Id??System /dev/sda1???*???????????1??????????26??????204800???83??Linux Partition?1?does?not?end?on?cylinder?boundary. /dev/sda2??????????????26????????1301????10240000???83??Linux /dev/sda3????????????1301????????1497?????1572864???82??Linux?swap?/?Solaris /dev/sda4????????????1497????????3916????19436582???83??LinuxCommand?(m?for?help):?wp???????#保存并退出,如果創建有誤,直接退出不要保存即可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@linuxprobe?~]#?mount?/dev/sda4?/data [root@linuxprobe?~]#?df?-hT [root@linuxprobe?~]#?cat?/data/linuxprobe we?are??Linuxer本文轉載自:http://www.linuxprobe.com/linux-fdisk-size.htm
轉載于:https://blog.51cto.com/lk886655/1965031
總結
以上是生活随笔為你收集整理的linux 虚拟机扩展硬盘后扩展到分区的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: css过渡transition
- 下一篇: css-modules 简介