How to make a file or folder undeletable? [duplicate]

There is not such thing that "root" can't delete. Is like telling God that he cannot do or undo something. root can put your machine topsidedown and make 1+1=3 if it likes and you can't do anything to prevent it. So, you can't prevent root from deleting whatever file he likes, just can't. Nor NTFS, nor ext2/3/4, nor HSF+, nor FAT16/32/64 not any other filesystem ruled by the OS.

The long and boring answer

Unless nobody else has root access to your system, this is impossible. But then there are ways that make users going a step beyond to delete the file, one of these is chattr:

chattr changes the file attributes on a Linux file system.

[...]

A file with the i attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

So, if nobody has root access or capacity to boot using another operative system then the file is undeletable, otherwise any user can (and will) delete your file. The same if the filesystem is formatted and/or firmware techniques to remove data of the disks.

How to do it?

Create the file:

$ touch deletemeifyoucan

Protect it:

$ sudo chattr +i deletemeifyoucan 
[sudo] password for braiam: 

Try to remove it

$ rm deletemeifyoucan
rm: remove write-protected regular empty file ‘deletemeifyoucan’? y
rm: cannot remove ‘deletemeifyoucan’: Operation not permitted

Now try with root:

$ sudo rm deletemeifyoucan 
rm: cannot remove ‘deletemeifyoucan’: Operation not permitted

Unprotect it:

$ sudo chattr -i deletemeifyoucan 

Is gone:

$ rm deletemeifyoucan 
$ #POOF!