# VM Clean up
# some tips for free up spaces on linux VM
# Check Current Spaces (with following commands)
- list disk usage %
df-h
1
- check disk usage inside folder
sudo du -h --max-depth=1
1
# Free Up Commands
Jornal files
- system logs, can goes up to 4G
- check current journal file sizes
journalctl --disk-usage
1
- only keep 300M, remove others
journalctl --vacuum-size=300M
1
- only keep 7 days journal files
journalctl --vacuum-time=7d
1
Snap Packages
- show all snap packages
snap list --all
1
- list all disabled packages
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}
1
- remove deprecated google-cloud-sdk-packages
snap remove google-cloud-sdk --revision=264
1
- remove all disabled snap packages.
LANG=C snap list --all | while read snapname ver rev trk pub notes; do if [[ $notes = *disabled* ]]; then sudo snap remove "$snapname" --revision="$rev"; fi; done
1
Linux cleanup
sudo apt-get autoremove
sudo apt-get autoclean
1
2
2
# Enlarge Disk Spaces
- can be done without VM restart/shutdown
- check current disk space
df -h
1
- check disk info
lsblk
1
- use growpart command
sudo growpart /dev/sda 1`
1
- use resize2fs command
sudo resize2fs /dev/sda1`
1
- use command to check disk space. should be changed now.
df -h
1