Dual-system Ubuntu20.04 disk non-adjacent partition root directory expansion

At the beginning, I only allocated 300G to Ubuntu for installing dual systems. I didn’t expect deep learning to consume so much space, so I thought about expanding the capacity of Ubuntu.

  There are two commonly used Ubuntu dual-system expansion methods on the Internet. One is to mount the free space compressed by Windows to Ubuntu, and the other is to directly merge the free space into the '/' root directory. However, the method of mounting the disk is a bit inconvenient to use. For example, if you want to move software such as anaconda to a new disk, you need to hang a soft link, and many Ubuntu software are installed with apt-get and stored under the root directory. The method of mounting a disk cannot solve the problem of insufficient root directory space, so the most worry-free method is to expand the root directory.
  It is worth mentioning here that I only divided two partitions when I installed Ubuntu, a swap partition and a '/' partition, so that the '/home' partition is a sub-partition of '/', so after expanding the root directory, the main directory capacity also increases. Some people may like to divide it into a '/home' partition. At this time, the root directory and the main directory are two independent partitions, which have to be expanded separately.

step

  • 1. In the disk management of Windows, allocate appropriate free space for the compressed volume.
  • 2. Start with the Ubuntu boot disk and enter the Ubuntu trial interface. (Because the subsequent operations will involve the disk partition of the Ubuntu system, the operation must be performed on the Ubuntu system in the U disk)
  • 3. Install gparted: sudo apt-get install gparted, open after the installation is complete: sudo gparted
      My disk partition looks like this:
    insert image description here  the red swap partition separates the partition to be allocated from the root directory partition, and the gparted disk merge needs to operate on adjacent partitions, so it needs to be moved Check the swap partition.
  • 4. Before operating the swap partition, it is necessary to temporarily disable the swap function: sudo swapoff -a.
  • 5. Right-click the swap partition, select "Resize/Move", and adjust the following two parameter values: Free Space Preceding, Free Space following. The swap partition needs to be moved forward, just set Free Space following to 0, and the system will automatically set Free Space Preceding to the required value.
  • 6. After moving the unpartitioned area and the area to be merged to be adjacent, you can click on the area to expand and merge. Also, right-click the root directory partition and select "Resize/Move". Set both Free Space Preceding and Free Space following 0 is enough, and finally remember to click the green √ to confirm.
    insert image description here
  • Turn on the swap function after the partition is completed: sudo swapon -a
     
      OK, the disk has been expanded, and you can install software as you like.

Guess you like

Origin blog.csdn.net/astruggler/article/details/128226355