Linux,  技术

How to handle storage running out of space issue in linux

If you run out of space in one disk and you want to add a new one but you would like to move the existing data to the new disk, what would you do?

Step 1: Identify the big folder

Identify the folder which has the biggest files and you want to move.

Here is the command you may want to run:

du -Sh | sort -rh | head -5

-S Do not include the size of subdirectories. This is very useful and it would exclude the parent folder if the child folder on the list already. This would save you a lot of trouble to de-dup.

the two -h should use together. We list the human readable result and we need sort it in human readable way.

Step 2: Copy the folder over to the new storage

rsync -a source/ destination
  • a = archive – means it preserves permissions (owners, groups), times, symbolic links, and devices.

Step 3: Rename the old folder

You don’t want to delete the folder too soon before the next step to make sure any program depends on the folder still running.

Step 4: Create softlink with the original name and link it to the new folder in new storage

ln -s file1 link1

And verify the program which depends on the folder still running.

Step 5: deleted the backup folder

Or you can zip the folder and back it up somewhere else:

zip -r /mnt/plotter/chiabk.zip ./chia-bk/

And you can unzip:

unzip chiabk.zip

Done.

Leave a Reply

Your email address will not be published. Required fields are marked *