2
df -h

Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G   12K  1.9G   1% /dev
tmpfs           391M  1.2M  389M   1% /run
/dev/sda6        19G   17G  597M  97% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            2.0G  352K  2.0G   1% /run/shm
none            100M   64K  100M   1% /run/user
/dev/sda4       372G   35G  338G  10% /media/shreya/FED815A3D8155AEB
/dev/sda5       453M   36M  390M   9% /media/shreya/c76b5210-3463-43b2-8b4a-8f5b62fdd868

I was trying to upgrade to ubuntu 16.04 from ubuntu 14.04 but it was aborted due to insuffficient disk space. I wish to free disk space in / which has used 97% as per the disk space usage above. I have tried sudo apt-get clean and sudo apt-get autoremove, but nothing has helped.

peterh
  • 4,914
  • 13
  • 29
  • 44
user3591497
  • 53
  • 1
  • 1
  • 3
  • Possible duplicate of [No free disk space](https://serverfault.com/questions/132998/no-free-disk-space) – peterh Jul 26 '17 at 18:55

2 Answers2

5

Take a look at /boot. Ubuntu has the tendency to clog this directory with old kernels. If there are some, you can look what can be cleaned up with

sudo dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | \
  cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get --dry-run remove

If you are satisfied with the result you can delete them with this command:

sudo dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | \
  cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get -y purge

This will also remove all kernel related files in other directories (for the spcific versions). On machines that are running for a longer time this usually frees up some gigabytes for me.

Apart from that ... /tmp is always a good place to clean up. du -hs /* will show which directory uses how much space. To get a good overview I prefer the non-standard tool durep.

Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
  • Thanks with these commands i was able to remove files in /boot and get this disk usage to 92%. I did du -hs /* and /bin and /etc have taken a lot of space after /boot. What files can be deleted from both bin and etc? 9.6M /bin 37M /boot 4.0K /cdrom 12K /dev 15M /etc – user3591497 Jul 14 '17 at 10:46
  • Again The upgrade was aborted ..The upgrade has aborted. The upgrade needs a total of 2,580 M free space on disk '/'. Please free at least an additional 1,095 M of disk space on '/'. Empty your trash and remove temporary packages of former installations using 'sudo apt-get clean'. What else can be deleted, I have deleted log files in /var/log as well.. – user3591497 Jul 14 '17 at 11:13
5

Try to use this command to get top 20 largest files:

du -max / | sort -rn | head -20

To remove obsoleted packages (as well as old kernels):

apt-get autoremove

Check those directories:

/var/tmp
/tmp
/var/spool/mail
/var/log

Check home directories, remove unused files.

NeilWang
  • 371
  • 4
  • 12