8

Ubuntu 20.04

When I tried to log in I got an error message. I tried to get a screen shot but it froze up.

When I restarted, all looks well and I'm prompted to enter my password. It appears to log in but just cycles back to the log in screen.

I accessed my hard drive using an Ubuntu stick and I see that my hard drive has zero bytes free. I suspect there is not enough memory to accomplish the login.

I can access all of my files and I would like to delete some but the "move to trash" option is disabled.

How can I access the hard drive as admin through my Ubuntu stick and delete some files?

76767676
  • 171
  • You cannot move the files to the trash because there is no space. If you rightclick a file and hold the shift key you can delete the file. – Joepie Es May 12 '22 at 19:47
  • Thanks guiverc, indeed I 'believe' it is 20.04 and missed the extra bits. I'll try to edit. – 76767676 May 13 '22 at 15:51

3 Answers3

8

To be able to delete files from the Ubuntu installation stick:

  1. Boot the installer then select "Try Ubuntu"
  2. Once the GUI boots, locate the terminal.
  3. Locate the location of your Hard Drive with the Ubuntu installation by running fdisk -l.
  4. Once you have located the location of your hard drive with Ubuntu installed, run cd /path-to-hdd/
  5. Depending on where the file you want to delete is located, you will want to cd to the directory of it. To delete a file, run rm myfile. To delete a directory, run rm -r mydir/

I hope this helps.

EDIT: If you are asked to run these commands as root, add sudo at the beginning of the commands. If it requires a password (I don't think it will), view this page.

Logan
  • 472
  • Okay. Sorry, I got a little bit confused with the command on IBM... I'll edit this. I know the rm command, but not the other options. – Logan May 12 '22 at 19:03
  • Thanks Jeff, I appreciate your help. I got as far as step 4. From fdisk -l I see: /dev/mmcblk0pw 1050624 (start) 61069311 (end) 60018688 (sectors) 28.6g (size) Linux filesystem (Type). However, when I run cd /path-to-hdd/ (cd/dev/mmcblk0ps) it returns the error cd/dev/mmcblk0ps: Not a directory – 76767676 May 12 '22 at 19:59
  • 2
    You should mount the partition, cd to its mountpoint and then identify files and directories. See for example lsblk -fm in a very wide terminal window. – sudodus May 13 '22 at 09:13
6

I have worked with Linux (and other UNIXes) for some 20+ years, and this is a scenario I come across often enough.

Firstly, there is no need to reinstall - I have never had to, and I can't really imagine why it would be necessary. A full root filesystem just means you can't store any more data, but what is already there is OK; there may be some data that got corrupted - eg in a database - but I haven't seen that often enough to remember it. In your case, you can't log in because your shell or desktop manager needs to store some data and can't; you just need to free up some space.

The thing to do is, get to a command line - if you can boot up from a live distribution, like the others say, do that, open a terminal and mount the filesystems you need to work on, if hasn't already happened. First find the disk devices (use df to list what is already mounted):

# df
Filesystem                                     1K-blocks        Used   Available Use% Mounted on
tmpfs                                           26379228        3284    26375944   1% /run
/dev/nvme1n1p4                                 863630096   744645468    75040948  91% /
tmpfs                                          131896140           4   131896136   1% /dev/shm
...

fdisk -l

... Disk /dev/loop7: 55.52 MiB, 58212352 bytes, 113696 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/nvme1n1: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors Disk model: Samsung SSD 970 EVO Plus 1TB
Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 2217FDA8-ADEA-49F9-B6A0-A7A26460B6FA

Device Start End Sectors Size Type /dev/nvme1n1p1 34 32767 32734 16M Microsoft reserved /dev/nvme1n1p2 32768 195381657 195348890 93.1G Microsoft basic data /dev/nvme1n1p3 195383296 196431871 1048576 512M EFI System /dev/nvme1n1p4 196431872 1953523711 1757091840 837.8G Linux filesystem ...

Ignore the /dev/loop ones, they are the manifestations of the idiotic snap thing that plagues Ubuntu. For each of the ones marked Linux filesystem, create a mount point somewhere and mount it:

# mkdir /myroot
# mount /dev/nvme1n1p4 /myroot

I suspect you have everything on just one partition, apart from the EFI partition, if you're using that. So, what often happens is that either /tmp or /var fills up, and since everything is on the same partition, you root filesystem runs out of space. Here's what I usually do:

Find out where all the space has gone; for that use du (in the following I run as root, 'cause I'm hardcore (aka stupid), but you can use sudo in front of all the commands instead, except for the cd commands):

# cd /
# du -sk etc home lib* mnt opt root snap tmp usr var | sort -n

Why shouldn't you put sudo in font of cd? Because sudo cd /some/directory executes in a sub-shell, and when the command is done, you will be back where you started.

du shows how much space is used, and -sk says to sum up in KB; normally you would use is like du -sk *, but I find it often hangs in certain sub-directories in the root, so I tend to avoid those. The | sort -n part takes the output and sorts it numerically, so you will see the biggest sinners at the bottom. Say you've found out it is /var:

# cd /var
# du -sk * | sort -n
  • and so on. In this case you'll probably find that it is /var/log that has grown too large, and you can generally delete some of the files in there without problems. Another place you can delete from is /tmp, BTW.

Then to delete, use rm:

# # In /var/log:
# ls
alternatives.log       btmp            lastlog
alternatives.log.1     btmp.1              openvpn
alternatives.log.2.gz  cups            private
alternatives.log.3.gz  dist-upgrade        speech-dispatcher
alternatives.log.4.gz  dmesg               syslog
alternatives.log.5.gz  dmesg.0             syslog.1
alternatives.log.6.gz  dmesg.1.gz          syslog.2.gz
...

The files that end in .gz are older, compressed log files that can normally be discarded - but be careful, try first with ls to see what you will be removing:

# ls *gz
# rm *gz

Always use ls when you think of deleting things with any sort of wildcard or regular expression!

Once you've finished this exercise, you should have freed up plenty of space, and next time you install a Linux system, remember to place things like /var, /opt and /tmp (as well as the ones you found were too large) on separate partitions. You may still run out of space, but at least it is likely to be less hassle.

j4nd3r53n
  • 308
3

There are different ways to create space:

  1. Select a file and press shift + del. That will delete the file. You cannot move the files to the wastebin because there is no space.

  2. Or you can go to the location, rightclick and choose the option open in terminal and use the rm command.

  3. Or you can cut and paste to another disk/partition.

  4. Or you can go to the location, rightclick and choose the option move to wastebin but holding the shift key it changes to delete and select that.

Joepie Es
  • 1,460