You Got A Question? Ask    GNOME Community!

Restoring a broken Fedora 20 installation on LVM Partition

This post was made with an older stylesheet

First, there isn’t a Fedora 20 release yet, but you can download a nightly build of it. Fedora 20 is branched out from Rawhide Release, and that means people who run Rawhide -possibly- have slightly different packages from F20, that are version-ed as Fedora 21.

Fedora 20 DHCP and SELINUX Bugs

Yesterday I booted my Fedora 20 box and I end up without Internet Connection. The bug was in DCHP package, but manually set up was also broken, so I couldn’t update my system and fix the issue. After I updated Fedora through a Live CD, I end up to a new bug that I couldn’t login to the system.

That was caused by a bug to SELINUX, and you need to disable it.

I usually avoid LVM Partitions as they cause troubles with Grub -specially in my case with lots of SSDs and OSs . When I firstly installed Fedora 20, Anaconda was buggy and it was impossible to set up custom partitions, so I end up with defaults, an LVM.

Well, I discovered tha LVM isn’t only tricky to configured it on Grub, but is also kinda hard to mount it :)

Mount a LVM Partition

The procedure to restore a broken installation, is to use live CD/DVD/USB, mount the Fedora Partition, Chroot to it, and trying to fix the issues as you were logged in to a normal installation. Note, that Fedora 20 Live CD hasn’t a repair option, so you have mount partition manually.

1. Boot in Live CD

First boot Fedora in Live Mode with a CD, open a Terminal and switch to Root with “su” -password is not required.

2. Read physical Drives

Pvs tool will print information about physical volumes.

# pvs
PV         VG     Fmt  Attr PSize  PFree
/dev/sda5  fedora lvm2 a--  19.58g    0

This is the only available partition so it will be probably be the one we need.

3. Get info of a logical drive

lvdisplay tool will give us a information about our logical drive. In this case “fedora”, but you have to adjust accordingly to your details.

# lvdisplay fedora
 --- Logical volume ---
  LV Path                /dev/fedora/swap
  LV Name                swap
  VG Name                fedora
  LV UUID                cFhs0Y-ZJ3K-jlKe-ac87-zOqF-ZASS-iGY876
  LV Write Access        read/write
  LV Creation host, time localhost, 2013-09-17 17:35:08 +0300
  LV Status              available
  # open                 2
  LV Size                7.77 GiB
  Current LE             1988
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/fedora/root
  LV Name                root
  VG Name                fedora
  LV UUID                GZj8jq-CRgK-np6P-Nwdl-NMTZ-AY3e-pBu3E1
  LV Write Access        read/write
  LV Creation host, time localhost, 2013-09-17 17:35:08 +0300
  LV Status              available
  # open                 1
  LV Size                11.82 GiB
  Current LE             3025
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

Check on LV Name and LV size and you will figure out what is the filesystem partition you need. In this case is the “/dev/fedora/root”.

4. Create a mount point

Traditionally mounted partitions were under /mnt. So lets create a folder under it and later on we will mount our filesystem there. I will call it “fedora”.

# mkdir /mnt/fedora

5. Scan Volume Groups
vgscan tool scan all disks for volume groups and rebuild caches. We run this with “–mknodes” option that also checks the LVM special files in /dev that are needed for active logical volumes and creates any missing ones and removes unused ones.

# vgscan --mknodes
  Reading all physical volumes.  This may take a while...
  Found volume group "fedora" using metadata type lvm2

6. Change Attrs of a Logical Drive

Now we will use the lvchange tool to change the attributes of our logical drive making them known to the kernel ready for use. We will use the “-ay” option in order to activate the logical volume.

#lvchange -a y /dev/fedora/root

7. Mount the LVM

Then we are ready to mount our LVM partition with the broken Fedora installation

# mount /dev/fedora/root /mnt/fedora

If you “cd” inside “/mnt/fedora”, you will able to see your filesystem and retrieve files. Do that to make sure you have the one you need!

8. Change Root

Just chroot in your mounted point.

# chroot /mnt/fedora

From here you can update your system with yum command or fix any other issues you might have.

# yum update

Restart and you will have all the updates! That fixed my DCHP issue but not the SELINUX.

SELINUX bug in Fedora 20 pre-alpha

When I reboot -after I had updated my system with the above method- I had this weird bug that was preventing me to login on my system. Every time I was entering my credentials it was keeping log me out! I didn’t Google for the bug, as I assumed was a SELINUX issue. And I was right ;)

I again mount my filesystem (Zzz..), and I disabled SELINUX

# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.

If you run a Rawhide or F20 pre-alpha this is the solution for the login bug.

The instruction for mounting LVM partions is from:

Sabayon wiki:

  We can't watch comments unless G+ provides an API or if you send a notification, e.g +World Of Gnome
     Sometimes is better to place your questions on GNOME Community
  • Luya Tshimbalanga

    When you encounter a SELinux issue, it is better to set it to permissive mode. In addition, have you submitted a bug report? SETroubleshoot should be triggered to propose suggestion including a bug report and writing a policy with detailed instruction.
    You can mount the drive containing broken Fedora installation directly from the LiveCD and simpy chroot from the terminal.

    • alex285

      No I haven’t submit a bug report, because I don’t know how to provide details on this issue, and because those kind of selinux bugs (blocking deamons) are easy traceable.

      Hmm, if you mean from “repair mode” in boot loader, it doesn’t exist. I couldn’t even mount it from “disks”. Maybe I missed something?

      • Luya Tshimbalanga

        You can still do, SELinux team is very responsive and can give you some tips.

        You are right, I forgot Live Media lacks rescue mode option. Alternately, you can use the netinstall.iso version featuring rescue mode, it is only less than 200MB.

  • Satyajit Sahoo

    Yeah. I also had that DHCP bug on my Fedora 20 (32-bit) and left without internet connection. I booted from my Ubuntu (64-bit), chrooted to the Fedora partition. Had to do the following to get internet access in the chroot environment.

    cd /media/satya/Fedora
    sudo mount –bind /dev dev
    sudo mount –bind /dev/pts dev/pts
    sudo mount –bind /sys sys
    sudo mount –bind /proc proc
    sudo cp /etc/resolv.conf /media/satya/Fedora/etc/resolv.conf

    sudo chroot .

    Then I tried to update through yum. But it was downloading 64-bit packages, even though my Fedora installation is 32-bit.

    I had to create a file /etc/rpm/platform with the content i686-redhat-linux

    Then I was able to update it finally :D