I have to Backup my whole System, because my HDD is dying.

In $HOME there is a file .rsync.log which I cannot erase as my user or as root.

LANG=C rm -f /media/alex/3c68c336-bf8d-46f8-bc04-58d3e160f2b1/alex/.rsync.log 
rm: cannot remove '/media/alex/3c68c336-bf8d-46f8-bc04-58d3e160f2b1/alex/.rsync.log': Operation not permitted

I ran a filesystemcheck, but that didn't work.

LANG=C getfacl /media/alex/3c68c336-bf8d-46f8-bc04-58d3e160f2b1/alex/.rsync.log 
getfacl: Removing leading '/' from absolute path names
# file: media/alex/3c68c336-bf8d-46f8-bc04-58d3e160f2b1/alex/.rsync.log
# owner: alex
# group: alex


lsattr /media/alex/3c68c336-bf8d-46f8-bc04-58d3e160f2b1/alex/.rsync.log 
-----a-------e-- /media/alex/3c68c336-bf8d-46f8-bc04-58d3e160f2b1/alex/.rsync.log

Filesystem is ext4.

I need to get rid of this file before I make my backup from $HOME. How can I do so?

  • Removing a file has to do with permissions on the base directory, rather than with permissions on the file itself. – Satō Katsura Jun 8 '17 at 12:05
  • In my case not. I couldn't erase the file when I was running the broken System. And I have read and write acess there in my $HOME. And it was mounted correct. I checked this at once. – user192526 Jun 8 '17 at 12:12
  • @SatoKatsura, but the file/directory permissions don't usually limit root. – ilkkachu Jun 8 '17 at 12:14
  • @ilkkachu Ah, I missed the part about running as root. – Satō Katsura Jun 8 '17 at 12:16
$ lsattr /media/alex/.../.rsync.log 
-----a-------e-- /media/alex/.../.rsync.log

The a there is the append only flag, which does work a bit like the immutable flag in that it also prevents removing the file. Also for root:

# touch file.txt ; chattr +a file.txt ; lsattr file.txt ; rm file.txt
-----a-------e-- file.txt
rm: cannot remove `file.txt': Operation not permitted

A file with the 'a' attribute set can only be open in append mode for writing. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

chattr -a /media/alex/.../.rsync.log as root should get rid of it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy