virtualbox下扩展根目录分区

十年热恋 提交于 2020-02-06 17:38:39

参考链接:

https://hexeract.wordpress.com/2012/04/30/how-to-expand-the-root-filesystem-of-a-11-10-ubuntu-running-inside-vmware-player/

http://imcczy.com/how-to-expand-the-root-filesystem-in-vmware.html

http://blog.csdn.net/ouyang_peng/article/details/53261599

查看需要修改的硬盘

cmdVirtualBox的安装目录

12
cd VirtualBoxVBoxManage list hdds

转换成vdi格式

已是vdi格式的则略过。

  • vmdkvdi

    1
    VBoxManage clonehd D:Softwares...src.vmdk D:Softwares...dst.vdi --format VDI
  • vdivmdk

    1
    VBoxManage clonehd D:Softwares...src.vdi D:Softwares...dst.vmdk --format VMDK

修改硬盘镜像文件

123
VBoxManage modifyhd D:Softwares...dst.vdi --resize 92160# D:Softwares...dst.vdi 即为要扩容的镜像。# 92160 以MB为单位,即90G。

改完后重开下virtualbox即可看到对应镜像容量增大。

分区

查看文件系统

12345678910
root@~ df -hFilesystem      Size  Used Avail Use% Mounted on/dev/sda1        19G   11G  7.6G  58% /none            4.0K     0  4.0K   0% /sys/fs/cgroupudev            487M  4.0K  487M   1% /devtmpfs           100M  1.1M   99M   2% /runnone            5.0M     0  5.0M   0% /run/locknone            498M     0  498M   0% /run/shmnone            100M     0  100M   0% /run/user/dev/sda3        28G   21G  5.7G  79% /home/work

查看磁盘分区表

1234567891011121314
root@~ fdisk -l /dev/sdaDisk /dev/sda: 96.6 GB, 96636764160 bytes255 heads, 63 sectors/track, 11748 cylinders, total 188743680 sectorsUnits = sectors of 1 * 512 = 512 bytesSe 大专栏  virtualbox下扩展根目录分区ctor size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00077822   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048    39845887    19921920   83  Linux/dev/sda2        39847934    41940991     1046529    5  Extended/dev/sda3        41940992   100661247    29360128   83  Linux/dev/sda5        39847936    41940991     1046528   82  Linux swap / Solaris

记住此处的分区表起始位置为2048

开始分区:

1234567891011121314151617181920212223242526272829303132333435
root@~ fdisk /dev/sdaCommand (m for help): mCommand action   a   toggle a bootable flag   b   edit bsd disklabel   c   toggle the dos compatibility flag   d   delete a partition   l   list known partition types   m   print this menu   n   add a new partition   o   create a new empty DOS partition table   p   print the partition table   q   quit without saving changes   s   create a new empty Sun disklabel   t   change a partition's system id   u   change display/entry units   v   verify the partition table   w   write table to disk and exit   x   extra functionality (experts only)Command (m for help): pDisk /dev/sda: 96.6 GB, 96636764160 bytes255 heads, 63 sectors/track, 11748 cylinders, total 188743680 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00077822   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048    39845887    19921920   83  Linux/dev/sda2        39847934    41940991     1046529    5  Extended/dev/sda3        41940992   100661247    29360128   83  Linux/dev/sda5        39847936    41940991     1046528   82  Linux swap / Solaris

delete a partition删除所有分区后,直接add a new partition,不要退出fdisk

记得创建交换分区,change a partition's system id可以将分区改为交换分区。

最后write table to disk and exit保存并退出fdisk

修改fstab

记得修改/etc/fstab文件挂载选项,比如UUID改变后,需要改下。否则会无法重启。

重启虚拟机

1
root reboot

调整分区大小

1
root@~ resize2fs /dev/sda1
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!