Create Emergancy hard drive space on linux fast
Page 1 of 1
Create Emergancy hard drive space on linux fast
# Create Emergancy hard drive space on linux fast!
# Helps when you get disk full error!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Removing snap and snapd
Note: you can’t remove the ‘core’ snap package with sudo snap remove core, but we’ll do it later. Also kudos to Kevin Custer for the next step on snap core unmount!
Note: replace the XXXX with the ID number inside the core directory on your system. You can find it by running the df command and getting something like /dev/loop4 27776 27776 0 100% /snap/snapd/7264.
Now see what else is worth removing with this
glances
~~~
References
howtogeek.com/devops/how-to-view-and-monitor-disk-space-usage-from-the-linux-command-line
makeuseof.com/tag/how-to-analyze-your-disk-usage-pattern-in-linux
reddit.com/r/SolusProject/comments/8mqw1v/how_to_remove_snapcore
# Helps when you get disk full error!
- Code:
sudo apt autoremove -y
sudo crontab -u root -e
du -h <dir> 2>/dev/null | grep '[0-9\.]\+G'
sudo du -a /var | sort -n -r | head -n 10
sudo du -hsx * | sort -rh | head -10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Removing snap and snapd
- Code:
snap list # to list all the existing snap packages
sudo snap remove <name-of-the-package> # to remove the snap package
sudo snap remove snap-store # as example, to remove the snap-store package
Note: you can’t remove the ‘core’ snap package with sudo snap remove core, but we’ll do it later. Also kudos to Kevin Custer for the next step on snap core unmount!
- Code:
sudo umount /snap/snapd/XXXX # to unmount the snap core service
Note: replace the XXXX with the ID number inside the core directory on your system. You can find it by running the df command and getting something like /dev/loop4 27776 27776 0 100% /snap/snapd/7264.
- Code:
sudo apt purge snapd # to remove and purge the snapd package and all of its related services
- Code:
sudo rm -rf ~/snap /snap /var/snap /var/lib/snapd # to remove all the folder related to snap, if existing
Now see what else is worth removing with this
- Code:
sudo pip install glances
glances
~~~
References
howtogeek.com/devops/how-to-view-and-monitor-disk-space-usage-from-the-linux-command-line
makeuseof.com/tag/how-to-analyze-your-disk-usage-pattern-in-linux
reddit.com/r/SolusProject/comments/8mqw1v/how_to_remove_snapcore
Last edited by jamied_uk on 17th November 2022, 02:08; edited 1 time in total
Re: Create Emergancy hard drive space on linux fast
Dont restart till you creat space or it wont boot up!
there are fixes but is or can be long!
there are fixes but is or can be long!
Re: Create Emergancy hard drive space on linux fast
The following script will help remove snap
~~~~
~~~~
- Code:
#!/bin/sh
if [ ! -e /var/lib/dpkg/status ]; then
echo "This script only works on Ubuntu Classic"
exit 1
fi
if [ "$(id -u)" != 0 ]; then
echo "This script needs to be run as root"
exit 1
fi
echo "This script will permanently destroy and reset all state in snapd"
echo "You will loose all of your installed snaps"
echo
echo "Type: DESTROY to remove all of your snap state"
echo
read consent
if [ "$consent" != "DESTROY" ]; then
echo "No consent, aborting"
exit 0
fi
echo
echo "ABOUT TO DESTROY ALL OF STATE OF SNAPD"
echo
echo "Interrupt the script in 10 seconds to abort"
sleep 10 || exit
echo
echo "DESTROYING ALL STATE OF SNAPD"
if systemctl is-active --quiet snapd.service snapd.socket; then
snapd_was_active=yes
echo
echo "Stoping snapd..."
echo
(
set -x
systemctl stop snapd.socket snapd.service
)
else
echo "Skipping stopping snapd as systemctl reports it's inactive."
fi
echo
echo "Unmounting all snaps..."
echo
(
set -x
umount /var/lib/snapd/snaps/*.snap
)
echo
echo "Removing all support files and state..."
echo
(
set -x
rm -rvf /var/lib/snapd/*
)
echo
echo "Removing generated systemd units..."
echo
(
set -x
rm -vf /etc/systemd/system/snap-*.mount
rm -vf /etc/systemd/system/snap-*.service
rm -vf /etc/systemd/system/multi-user.target.wants/snap-*.mount
)
echo
echo "Removing generated executable wrappers..."
echo
(
set -x
rm -vrf /snap/*
)
if [ "$snapd_was_active" = "yes" ]; then
echo
echo "Starting snapd"
(
set -x
systemctl start snapd.socket
)
fi
Similar topics
» bleachbit linux disk clean space saver remove uneeded files to make space
» Emergancy Space On Linux Script
» Creating Space In An Emergency On Linux
» Space Fence Space Junk Tracker
» Remove and Delete a Linux User fast from the command line
» Emergancy Space On Linux Script
» Creating Space In An Emergency On Linux
» Space Fence Space Junk Tracker
» Remove and Delete a Linux User fast from the command line
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum