On my system I don't have selinux set up, but I have a removeable disk containing an EXT4 filesystem from a machine that does use selinux. I need to change a file's context on that filesystem. chcon fails with "Operation not supported". Is there a way to achieve this?

2 Answers 2


You could run a Linux distribution with SELinux enabled, such as Fedora, in a virtual machine. Installing Fedora in a VM takes only a few minutes, not including the download time. Use VM software that supports USB passthrough (such as VirtualBox with the non-open-source extensions) and access the disk directly from the VM.


You could try to use setfattr to set the security.selinux attribute on the file directly, something like:

setfattr -n security.selinux -v "unconfined_u:object_r:foo_t:s0" /tmp/bar

To see the label, you can use getfattr -n security.selinux /tmp/bar

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .