Tip: Autorelabel a VM

Somehow I managed to mess up a RHEL 6 Alpha machine’s SELinux configuration so seriously that I could no longer log in:

$ ssh root@192.168.122.242
root@192.168.122.242's password: 
Unable to get valid context for root
Last login: Wed Jan  6 18:34:46 2010
Connection to 192.168.122.242 closed.

However this is easy to fix with guestfish. Important: before you do this, make sure the guest is shut off.

# guestfish -i RHEL6Alpha

Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.

Type: 'help' for help with commands
      'quit' to quit the shell

><fs> ls /
.autofsck
bin
boot
dev
etc
home
lib
lib64
lost+found
media
mnt
opt
proc
root
sbin
selinux
srv
sys
tmp
usr
var
><fs> touch /.autorelabel
><fs> sync
><fs> exit

It’ll fix the SELinux labels for you when it boots. Lo and behold I can log in again.

About these ads

5 Comments

Filed under Uncategorized

5 responses to “Tip: Autorelabel a VM

  1. Stephen Smoogen

    I didn’t know RHEL_6 would work on the alpha.. its good to see something will :).

  2. Dan Walsh

    A potential easier solution would be

    sh “/sbin/setfiles -q /etc/selinux/targeted/contexts/files/file_contexts /”

  3. So RHEL6 is finally in alpha! phew

    I thought it was becoming friends with Duke Nukem

  4. Bucky

    An easier solution still:

    echo SELINUX=disabled > /etc/selinux/config

    Oooh! What I said!

  5. fred

    There is a RHEL 6 Alpha? Were can I get one for myself?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s