CentOS6.9 ARM虚拟机扩容系统磁盘
?
由于擴容磁盤的操作非同小可,一旦哪一步出現問題,就會導致分區損壞,數據丟失等一系列嚴重的問題,因此建議:在進行虛擬機分區擴容之前,一定要備份重要數據文件,并且先在測試機上驗證以下步驟,再應用于您的生產機器。如果虛擬機的磁盤不夠用了,建議附加新磁盤進行使用,不到萬不得已一般不要擴容磁盤分區。
?
操作系統環境:
[root@hlmcent69n1 ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
?
1.關閉虛擬機
備注:擴容磁盤需要關閉虛擬機,否則無法調整磁盤的大小
?
2.調整磁盤的大小(示例中將原來的30GB調整為了100GB)
?
?
3.等待跟新完成,啟動虛擬機,查看到整塊磁盤已經變為100G,但/dev/sda1分區還是30G
?
?
4.使用命令:fdisk /dev/sda,重新劃分分區/dev/sda1
[root@hlmcent69n1 ~]# 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: 107.4 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 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: 0x0005498fDevice Boot Start End Blocks Id System /dev/sda1 * 1 3917 31456256 83 LinuxCommand (m for help): u ##默認以柱面的形式顯示,運行該參數后會以扇區的形式顯示 Changing display/entry units to sectorsCommand (m for help): pDisk /dev/sda: 107.4 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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 identifier: 0x0005498fDevice Boot Start End Blocks Id System /dev/sda1 * 2048 62914559 31456256 83 Linux ##記錄該標黃的start值Command (m for help): d ##將原來的/dev/sda1分區刪除 Selected partition 1Command (m for help): pDisk /dev/sda: 107.4 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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 identifier: 0x0005498fDevice Boot Start End Blocks Id SystemCommand (m for help): n ##重新創建分區 Command actione extendedp primary partition (1-4) p Partition number (1-4): 1 First sector (63-209715199, default 63): 2048 ##該值需要與上述標黃的start值相同 Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): Using default value 209715199Command (m for help): pDisk /dev/sda: 107.4 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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 identifier: 0x0005498fDevice Boot Start End Blocks Id System /dev/sda1 2048 209715199 104856576 83 LinuxCommand (m for help): a ##激活分區 Partition number (1-4): 1Command (m for help): p ##再次查看分區,確認已激活,激活后Boot對應的值為*Disk /dev/sda: 107.4 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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 identifier: 0x0005498fDevice Boot Start End Blocks Id System /dev/sda1 * 2048 209715199 104856576 83 LinuxCommand (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.
?
5.使用fdisk –l查看/dev/sda1已經變為了100G,但使用df –h查看/dev/sda1還是30G
?
?
6.此時拉伸文件系統的話,輸出信息類似如下,拉伸沒有生效。需要重啟電腦以便重讀分區表后,才能成功拉伸文件系統。備注:可以使用“blkid”命令查看分區的文件系統
?
?
7.重啟電腦后,重新使用命令:resize2fs,拉伸Ext4的文件系統,可以看到成功拉伸文件系統
?
?
?8.重新查看,發現/dev/sda1成功拉伸為了100G,并且之前的數據文件仍然存在并可正常使用。
?
?
轉載于:https://www.cnblogs.com/stonehe/p/8615336.html
總結
以上是生活随笔為你收集整理的CentOS6.9 ARM虚拟机扩容系统磁盘的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 输卵管不孕
- 下一篇: 转《Angular4项目部署到服务器上刷