【Linux】Ubuntu storage analysis

Preface

  Because I wanted to compile a Linux SDK for ARM architecture, I didn’t expect that the size of the SDK after decompression and compilation was much larger than I imagined, directly exceeding the storage space allocated during the original installation. This directly caused me to reinstall several times and wasted a lot of time. I will record my experience here.

1 How to perform storage analysis on the system

  Compared with Windows, where you can directly open the resource manager to see the disk usage, it is relatively troublesome to check the disk usage on Linux systems such as Ubuntu, but it is also very simple, because Ubuntu comes with storage analysis software when it is installed. Here are the main recommendations two:

  • df -h: Quickly view disk usage across the entire system
  • du -csh <dir>: Check the storage size occupied by a certain path, for example, you can check the size of files on the desktop, etc.

Reference link

2 What should I do if a warning about insufficient storage space appears?

  Let me start with the conclusion: Never shut down your phone directly . Because the remaining storage space of Ubuntu is too small, it cannot be started. This is different from the C drive in Windows. When Ubuntu reminds you that the storage space is insufficient, it is really insufficient and cannot even support the next boot.
  The most appropriate solution at this time is to first delete some regenerable files, such as build files, etc., then shut down the computer, expand it and then turn it on again. This can avoid the embarrassing situation of being unable to turn on the computer because the storage space is too small.

3. What should I do if the storage space is too small and the computer cannot be turned on?

  So what should you do if you really shut down your phone and then can't turn it on? The general manifestation of this is that a lot of OK loads are loaded when booting, but if you wait for a while and still cannot enter the system, you can think that it cannot be booted (don't wait stupidly).
  At first I thought I could only reinstall, but after looking up everyone's methods, I found that you can actually manage files in Ubuntu without booting it, by using the DiskGenius software.

  First open DG, then find the directory where Ubuntu is installed, and drag vmdkthe suffix file to the disk list on the left side of DK:

Insert image description here
Insert image description here

Click the plus sign on the left side of the disk, and then you can manage the files in Ubuntu like the Windows File Explorer. If you need to delete something, just find the corresponding directory and delete it.

  At the same time, you can also see the disk usage here.

Insert image description here

A little thought, is it possible to expand the disk capacity in DG? I think it is possible, because DG can also expand the disk in the host. If you are interested, you may want to try it.

4 How to expand the system

  The easiest way: reinstall!
  Just kidding, if you do this every time, how much time will be wasted. First, shut down the system, then open the virtual machine settings and increase the storage.

Insert image description here

Insert image description here

Insert image description here
Insert image description here

Finally, click Expand, and you will be prompted here that only the space has been added. These spaces have not been allocated and need to be set in the system.

Update 2023.11.4: If this button is gray, you can delete the snapshot of the virtual machine first, and then click Expand.

Turn on the computer and install a gpartedsoftware called:

sudo apt install gparted

After installation, directly enter gpartedto open the software, and a window will automatically pop up:

Insert image description here

From here you can see that the newly added storage has not been allocated, so it still needs to be allocated.

Insert image description here
Insert image description here

Insert image description here

At this point, you are done. You can use df -hthe command to check the storage space size.

Guess you like

Origin blog.csdn.net/ZHOU_YONG915/article/details/133843742