[VirtualBox expands the root directory of the Linux virtual machine]

The process is pretty crap.

First of all, it can be set here in vbox.
increase capacity
After setting it up, turn on the virtual machine and find that the root directory has not changed, and then start to take a detour.

  1. First, I saw the method of adding partitions on the Internet. Followed
    the virtualbox virtual machine disk space expansion

  2. After the first step, I found that there is an extra disk, but I want to expand the root directory. So I found the following tutorial and downloaded the tool gparted.
    VirtualBox virtual machine Ubuntu (20.4) expands hard disk capacity

  3. As a result, the following problem appeared
    when GParted resized the ubuntu system disk, and the solution of cannot resize read-only file system appeared

  4. After solving the above problems, it was found that the capacity cannot be expanded. After searching, it was found that continuous unallocated space is required to expand the capacity.
    The ubuntu root directory was expanded
    , so the partition allocated in the first step was deleted, and the space became unallocated. At this time, I used gparted to merge, and finally saw that the root directory became larger. At this time, I thought it was successful, so I restarted.
    However, there are still big ones not coming.

  5. After restarting, my Ubuntu tmd directly enters emergency mode. I think there must be something wrong when expanding the root directory. So I continued to search and found that it was because a file was changed when creating the mount partition in the first step. Open it with vim, delete the information added in the first step, restart it again, and finally succeed.

Around a big bend, around to the origin. The result is

  • Delete or back up snapshots before capacity expansion.
    Virtualbox expands the pit of dynamic disk size

  • After setting the capacity of Vbox, there is no need to partition, just use gparted to expand the root directory directly.

  • sudo gparted

    Open the following interface:

    insert image description here

    You can see that there is an extra 10gb of unallocated capacity, select the adjacent partition, right-click, and select resize/move, and this prompt will appear.

    insert image description here
    Just do what it says, and the specific operation is in the link in the third step.

    Then you can resize as much as you want

Guess you like

Origin blog.csdn.net/qq_51794847/article/details/128403321