Delete a corrupted file

Some months ago I took a picture and the phone rebooted in the meanwhile.
Today I just checked why my camera folder was no longer indexed in gallery (I had problems from that day) and I realized that I have a 0B size picture file corrupted, struck in the file system, that cannot be deleted from UI (built in filemanager, File Browser app…).
Is there a way to delete that file / solve the corruption (like with fsck)?

You can try via terminal (need to enable developer tools via settings) or you might try the filesystem check and repair as option if the recovery mode (you’ll find docs on zendesk).

Have you tried to delete from terminal as root? What are the permissions of the file?

Sorry for the long silence… yes, I logged via terminal with devel-su privileges (I’m stuck with the old “/home/nemo” structure, no encription) and whenever I try to perform any command against the file (ls -l, rm…) the output reads i.e.:

“rm: cannot remove ‘filename.jpg’: File or directory not existing”
“ls: cannot access ‘filename.jpg’: File or directory not existing”

But the file remnants (or whatever it is) you can see it from the file browser app. It appears with a normal filename, with 0 Bytes dimension, “void” icon, privileges “?---------” and no creation date (I’ll post a picture later on).
Even via PC with MTP it cannot be deleted.
NOTE: ls on the parent folder shows the filename as well…

Hi you could try this:

rm -i ./*filename.jpg*

There might be special characters in it. But be sure that you only delete that corrupted file. -i ask to confirm before removing. Also do it as root.

Or move other content somewhere else and then try delete directory. After make same named dir and move back other content.

Doubt this helps, but could give it try.

You might want to ssh into your phone and use autocomplete ( key) to select the file. Depending on the font settings, it can be hard to distinguish e.g. between “O” and “0” etc.

The ?--------- makes me think there is indeed substantial corruption.

Probably need debugfs to solve it.

It might also help to pipe /dev/null into the file, or copy another picture into it, and try to delete it then

Sorry to all, I had just posted the wrong message there… probably when I tried I was missing something. The actual output is:

“rm: cannot remove ‘filename.jpg’: Input/output error”

Same for ls.
Introduction of “./” doesn’t change it.
For debugfs, could you give me an hint of how to use it?
NOTE1: Maybe I found something with “dmesg”, let me see how to post it.
NOTE2: Indeed there’s some fs error, dmesg posted quite many times the following:
EXT4-fs error (device dm-1): ext4_iget:4042: inode #1940: comm harbour-file-br: bad extra_isize (65663 != 256)
Related to several other comm like lipstick, pool, sh, rm, ls…

Is your system working otherwise? Then I probably wouldn’t bother.

If not…

This has happened to me when I connect a USB drive with a touchy connector. Force unmount, close encrypted volumes if applicable, unplug … or a hard reboot.

I have also experienced similar things with a shitty offbrand laptop battery.

Or an ageing hard drive. Or an unclean shutdown.

You should probablyalso do a filesystem check with fsck.

But first of all you will need command line access via ssh.

Start here.

2 Likes

There is also this how-to, explaining how to connect via ssh: SSH How-to: type CLI terminal commands into your phone from your Linux computer

But the problem is that we cannot run fsck on a mounted filesystem.
And I know now way of unmounting it as the UI relies on users needing /home to be mounted.
So, the remaining solution is to use the recovery image, I guess.

1 Like

This is for my XA2 but it is probably similar with other devices.
To boot in recovery:

  • If you don’t have it, download the package suiting your phone here: https://shop.jolla.com/downloads/
  • Unzip it somewhere.
  • Power off your phone
  • Hold Volume-UP key while plugging your phone
  • On the PC, run:

fastboot boot /some_path_where_you_uncmpressed_your_download/hybris-recovery.img

  • When the phone has booted (tiny characters on the screen talking about telnet), on the PC, type:

telnet 10.42.66.66

Choice 3), “y”, input your lock code.

  • The shell now opens. Open the encrypted partition by typing:

cryptsetup luksOpen /dev/sailfish/home myhome

  • Input your lock code again
  • Type:

chroot /rootfs

  • Run fsck.ext4 with the options you like on /dev/mapper/myhome
  • By the way, perhaps try to remove the file you had problems with.
  • Exit the chroot with CTRL-D
  • Close the encrypted partition with:

cryptsetup luksClose myhome

CTRL-D to exit the shell and you are back to the main menu. Choice 2 and unplug to reboot the phone.

3 Likes