Questo contenuto non è disponibile nella lingua selezionata.
50.2.2. Relabeling a File System
The recommended method for relabeling a file system is to reboot the machine. This allows the init
process to perform the relabeling, ensuring that applications have the correct labels when they are started and that they are started in the right order. If you relabel a file system without rebooting, some processes may continue running with an incorrect context. Manually ensuring that all the daemons are restarted and running in the correct context can be difficult.
touch /.autorelabel
reboot
init.rc
checks for the existence of /.autorelabel
. If this file exists, SELinux performs a complete file system relabel (using the /sbin/fixfiles -f -F relabel
command), and then deletes /.autorelabel
.
It is possible to relabel a file system using the fixfiles
command, or to relabel based on the RPM database:
fixfiles
command:
fixfiles relabel
fixfiles -R <packagename> restore
fixfiles
to restore contexts from packages is safer and quicker.
Warning
fixfiles
on the entire file system without rebooting may make the system unstable.
fixfiles relabel
prompts for approval to empty /tmp/
because it is not possible to reliably relabel /tmp/
. Since fixfiles
is run as root, temporary files that applications are relying upon are erased. This could make the system unstable or behave unexpectedly.