Product SiteDocumentation Site

Common Operations

This section includes common operations you might have to perform when following various instructions in this guide.

A.1. Setting up a chroot from a live image

To operate on a Fedora installation that will not boot, you must use a chroot. The process initially uses a Fedora live image, but sets up an environment that uses the files, executables, and libraries from the installed system.
The Fedora Netinstall image has a system recovery option that will set up the chroot for a Fedora system automatically. Use the instructions here for a live image.
Be consistent about your booting methods. If you have Fedora installed Fedora in UEFI mode, boot the live image in the same way.
Procedure A.1. Creating chroot of a Fedora installation
  1. Boot a Fedora live image and open a root terminal window.
  2. Create a directory to work in.
    # mkdir /mnt/sysimage
  3. List the available partitions. We'll use this list to identify all the partitions your Fedora installation needs.
               # blkid
                /dev/sda1: LABEL="WINRE_DRV" UUID="C812A5BC12A5AFBC" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="3f4f9bb5-6551-4411-9cea-d06dd1d10aff" /dev/sda2: LABEL="SYSTEM_DRV" UUID="32A7-BBCC" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="f540b7b9-782a-48d2-89b4-4f0a720121cf" /dev/sda3: LABEL="LRS_ESP" UUID="F2C1-30B7" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="cdbadfc7-e84b-4fe0-935c-28419b0082f7" /dev/sda4: PARTLABEL="Microsoft reserved partition" PARTUUID="bb3d61f2-652b-4793-a8e9-8b42e819f6bb" /dev/sda5: LABEL="Windows8_OS" UUID="7898C3F398C3ADC6" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="111e1bb0-dafd-439b-8af3-9d6b86bff9e9" /dev/sda6: LABEL="LENOVO" UUID="16E2DDF6E2DDD9D7" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="45dc466a-929d-4862-91ed-396afe2e4f59" /dev/sda7: LABEL="PBR_DRV" UUID="40A4E1E7A4E1E000" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="29b2cac6-ff56-4cf2-b62e-d04230a72294" /dev/sda8: UUID="5958dcb4-dfeb-4f6c-ba07-8b2ada8b1602" TYPE="ext4" PARTUUID="cacf80f0-3376-443d-bfb5-5d3fe689885e" /dev/sda9: UUID="PRueOy-TXAC-mKDV-NRLC-k4gt-C63H-D0zfYd" TYPE="LVM2_member" PARTUUID="555251b9-438f-4f16-9011-754620526ebe" /dev/mapper/fedora-swap: UUID="28d71a2c-1b34-4115-aa19-083373ec4d8a" TYPE="swap" /dev/mapper/fedora-root: UUID="125425e2-dd7b-46e9-8c64-6d2c5b192c76" TYPE="ext4" /dev/mapper/fedora-home: UUID="1cec1d42-8750-4746-bd36-145c1ebb2d89" TYPE="ext4" 
  4. Identify Fedora's root partition.
    # mount /dev/sda8 /mnt/sysimage
    # cat /mnt/sysimage/etc/fedora-release
     cat: /mnt/sysimage/etc/fedora-release: No such file or directory 
    # ls /mnt/sysimage
     config-3.17.7-300.fc21.x86_64 config-3.17.8-300.fc21.x86_64 config-3.19.0-0.rc5.git2.1.fc22.x86_64 efi elf-memtest86+-5.01 extlinux grub2 initramfs-0-rescue-39995d7d26a74b1784e7bd9a7bfefdf1.img initramfs-3.17.7-300.fc21.x86_64.img initramfs-3.17.8-300.fc21.x86_64.img initramfs-3.19.0-0.rc5.git2.1.fc22.x86_64.img initrd-plymouth.img lost+found memtest86+-5.01 vmlinuz-0-rescue-39995d7d26a74b1784e7bd9a7bfefdf1 vmlinuz-3.17.7-300.fc21.x86_64 vmlinuz-3.17.8-300.fc21.x86_64 vmlinuz-3.19.0-0.rc5.git2.1.fc22.x86_64 
    # umount /dev/sda8
    /dev/sda8 wasn't the root partition, since it did not contain the /etc/fedora-release file, but we did find other things inside. The vmlinuz and initramfs files are the kernels and initramfs, and they always live on /boot. Remember that for later.
    # mount /dev/mapper/fedora-root /mnt/sysimage
    # cat /mnt/sysimage/etc/fedora-release
    Fedora release 21 (Twenty One)
    That's the Fedora root partition, so we will leave it mounted there. Because the other filesystems use mount points inside the root partition, we mount it first.
  5. Next, identify and mount the /boot partition. We found it as /dev/sda8 already, but we can confirm by checking Fedora's /etc/fstab, the file that tells the system where to mount filesystems.
    #  grep boot /etc/fstab
     UUID=5958dcb4-dfeb-4f6c-ba07-8b2ada8b1602 /boot ext4 defaults 1 2 UUID=32A7-BBCC /boot/efi vfat umask=0077,shortname=winnt 0 0 
    /etc/fstab uses Universally Unique Identifiers to identify partitions. This makes sure that the right partitions get mounted in the right place, even if drive orders change. The UUID listed for /boot matches what blkid reports for /dev/sda8, so we know we have the right partition.
    # mount /dev/sda8 /mnt/sysimage/boot
  6. If this is a UEFI installation, mount the EFI system partition next. In this example, we found it in the previous step, and can match the UUID with blkid output. You can confirm by looking at the contents once mounted.
    # mount /dev/sda2 /mnt/sysimage/boot/efi
    # ls /mnt/sysimage/boot/efi
     /boot/efi/BOOTSECT.BAK /boot/efi/EFI: BOOT fedora Microsoft 
  7. Next mount the virtual filesystems that the system uses to communicate with processes and devices. These are always the same, so we can do it in one command.
    #for dir in /dev /proc /sys; do mount --bind $dir /mnt/sysimage/$dir ; done
  8. Enter the chroot to continue, and begin working on your Fedora installation.
    # chroot /mnt/sysimage
  9. When you are finished, use the exit command to leave the chroot.