How to manage disk usage in Ubuntu?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How to manage disk usage in Ubuntu?
# 1  
Old 09-19-2018
How to manage disk usage in Ubuntu?

Hello,
I have been running under ubuntu 14.04 trusty and 18.04 bionic.
What I wonder is about:

* how to stop all process in case hdd capacity is almost full and create space for system files

* if possible, to prevent filesystem to write anything into hdd when there is such a risk

* if there is any script that can manage/control the disk usage and protect the system.

* if possible to fix via recovery mode when disk usage is at 100%

Many thanks
Boris
# 2  
Old 09-22-2018
Let me attempt to answer these one at a time:

1. how to stop all process in case hdd capacity is almost full and create space for system files? Not sure if you truly mean "all processes" as that would shut down the whole system. Or how you would intend to create space. If you are wanting to allocate more space from somewhere or if you want to remove unneeded files.

2. if possible, to prevent filesystem to write anything into hdd when there is such a risk? There is already such a threshold called "reserved space". You can actually fill a disk to 100% and see 0MB available and yet there is there is some reserved space to keep the system online. This can be adjusted, but its pretty standard to have in every Linux distro.

3. if there is any script that can manage/control the disk usage and protect the system? It's possible, but again, not sure if you are wanting to allocate more space from another resource or get rid of unneeded content. The reserved space I just mentioned may suffice for this problem as well.

4. if possible to fix via recovery mode when disk usage is at 100%? Yes, but as I also mentioned, SSH should still work at 100% because of the reserved space.

Last edited by Neo; 09-22-2018 at 03:14 AM..
# 3  
Old 09-22-2018
Dear Azrael,
Thanks for your return.
Regarding remark 2, yes. That was what I needed.
Maybe to define a target directory name and empty it in case df -H is above %95-%98 etc would be good. I do not demand more space, just deletion of consumed part section is okay. Regarding remark 4, ssh did not work in my case, neither recovery/rescue mode . Now I have a clean vps

Kind regards
Boris

Last edited by baris35; 09-22-2018 at 05:16 AM..
# 4  
Old 09-22-2018
Quote:
Originally Posted by baris35
Maybe to define a target directory name and empty it in case df -H is above %95-%98 etc would be good. I do not demand more space, just deletion of consumed part section is okay.
Sorry, but i might be a bit slow: if you have some data which you don't need at all (in this "target directory") and it should be deleted automatically when the "disc" (i suppose what you mean is "filesystem") is 95% or 98% full - why can't that be deleted at first without getting the filesystem that full in first place?

Data is either nececssary or not: if it is, get a bigger disk and/or add a disk, make the filesystem bigger and avoid a full filesystem that way. If it is not necessary and you are prepared to throw it away at certain circumstance you can throw it away in first place, no?

Btw., you should nowadays ALWAYS use LVM (logical volume manager) and at most have the /boot and (if you use UEFI) the UEFI-system-partition as real partitions. Everything else (including the / FS) should come from a logical volume. It is easy to resize that logical volumes and resize the filesystems on them, minimising the administration overhead.

I use Linux on my desktop and my laptop and the following schema has worked best for me:

/dev/sda1 512MB mounted at /boot (for grub, the boot menu and the kernel images)
Everything else in a VG:
- 32GB swap (unecessary but Linux acts funny with suspend-to-RAM or suspend-to-disk when the paging space is smaller than the RAM and this is how much my laptop has installed)
- 20GB mounted at / (for the main OS installation)
- 20GB mounted at /altroot (this is for a secondary OS installation, comes in handy if for some reason the main installation goes to the fritz)
- 10GB mounted at /home (user data, resize according to necessity)
- 50GB mounted at /opt/images (all my virtual machines disk files go there, i use lots of virtual machines for test purposes but most only need barebone OS installations, therefore not much space necessary)

/ and /altroot are mounted vice versa: if i start the OS from what is normally /altroot it will be mounted at / and what is normally / will be mounted at /altroot instead. Everything else is mounted on its normal place. This way i have two separate OS installations and if one breaks i can still boot from the other and repair or even replace it. This has already saved my behind as the update from Xubuntu 17 to 18 left me with an unbootable system for no apparent reason.

I hope this helps.

bakunin
These 3 Users Gave Thanks to bakunin For This Post:
# 5  
Old 09-26-2018
Dear Bakunin,
Thank you so much for your detailed explanation.
I will try to test the same method at my end.
Much appreciated

Kind regards
Boris
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Disk usage monitoring and record the disk used in last 24 hour

HI I am Trying to edit the below code to send email every day with difference of disk utilized in for last 24 hours but instead getting same usage everyday. can you please help me to point out where my calculation is going wrong. Thank you. ================= #!/bin/bash TODAY="at $(date... (0 Replies)
Discussion started by: Mi4304
0 Replies

2. UNIX for Advanced & Expert Users

Ubuntu 14.04 - how to less ram usage

Hello, I have an ubuntu14.04 installed pc with 32GB ram. Operating System: Ubuntu 14.04.5 LTS Kernel: Linux 4.9.148-xxxx-std-ipv6-64 Architecture: x86_64 When I check free memory it shows: total used free shared buffers cached Mem: 31882 ... (2 Replies)
Discussion started by: baris35
2 Replies

3. UNIX for Dummies Questions & Answers

Disk Usage

Hi, I have always felt problems using commands to check disk usage, or I should say I might not be using the commands properly. dfspace and free are 2 most frequent command that I use, but the data that it echoes is not comprehandable atleast to me.:wall::wall::wall::wall::wall: I want... (4 Replies)
Discussion started by: TH3M0Nk
4 Replies

4. Ubuntu

XP and Linux (Ubuntu) on same disk, Can I install Ubuntu on not-yet partitioned portion of disk?

My PC (Esprimo, 3 yeas old) has one hard drive having 2 partitions C: (80 GB NTFS, XP) and D: (120 GB NTFS, empty) and and a 200 MB area that yet is not-partitioned. I would like to try Ubuntu and to install Ubuntu on the not-partitioned area . The idea is to have the possibility to run... (7 Replies)
Discussion started by: C.Weidemann
7 Replies

5. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

6. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

7. Shell Programming and Scripting

Disk Usage

Hi, I want to retrieve the directory in the shell script that is using maximum space on the disk.I was using du command but it displays all the directories that are using the space on the disk.How can retrieve the only directory which uses the maximum space on the disk?? Thanks in advance. ... (4 Replies)
Discussion started by: harikamamidala
4 Replies

8. UNIX for Dummies Questions & Answers

disk usage

how to i find out the disk usage on a server. say in windows examples its like C:/ D:/ and checking out the disk space. how can i find in Unix. can i just use df -k or should i go to each volume group and find that way. plz respond (2 Replies)
Discussion started by: karthikosu
2 Replies

9. UNIX for Dummies Questions & Answers

Disk Usage

Im using solaris 8 on a Sunfire 280r. Is there a command to show you how much disk space is being used in gigabytes or megabytes. I dont think theres an option for this using the df command. not for solaris anyway. thanks (3 Replies)
Discussion started by: lewisoco
3 Replies
Login or Register to Ask a Question