The software described in this documentation is either in Extended Support or Sustaining Support. See https://www.oracle.com/us/support/library/enterprise-linux-support-policies-069172.pdf for more information.
Oracle recommends that you upgrade the software described by this documentation as soon as possible.

4.11.2 Converting the root File System

Caution

Before performing a root file system conversion, make a full system backup from which you can restore its state.

To convert an ext2, ext3, or ext4 root file system to btrfs:

  1. Run the mount command to determine the device that is currently mounted as the root file system, and the type of the file system.

    In the following example, the root file system is configured as an LVM logical volume lv_root in the volume group vg_hostol6, and the file system type is ext4. Using the ls -l command confirms that the mapped device corresponds to /dev/vg_hostol6/lv_root.

    # mount
    ...
    /dev/mapper/vg_hostol6-lv_root on / type ext4 (rw)
    ...
    # ls -l /dev/mapper/vg_hostol6-lv_root
    lrwxrwxrwx. 1 root root 7 Sep 14 14:00 /dev/mapper/vg_hostol6-lv_root -> ../dm-0
    # ls -l /dev/vg_hostol6/lv_root
    lrwxrwxrwx. 1 root root 7 Sep 14 14:00 /dev/vg_hostol6/lv_root -> ../dm-0

    In the next example, the root file system corresponds to the disk partition /dev/sda2:

    # mount
    ...
    /dev/sda2 on / type ext4 (rw)
    ...

  2. Shut down the system.

  3. Boot the system from an Oracle Linux 6 Update 3 or later UEK Boot ISO (which you can burn to CD or DVD if necessary). You can download the UEK Boot ISO from https://edelivery.oracle.com/linux.

    Note

    You must use the UEK Boot ISO. You cannot use the RHCK Boot ISO to perform the conversion.

  4. From the installation menu, select Rescue Installed System. When prompted, choose a language and keyboard, select Local CD/DVD as the installation media, select No to bypass starting the network interface, and select Skip to bypass selecting a rescue environment.

  5. Select Start shell to obtain a bash shell prompt (bash-4.1#) at the bottom of the screen.

  6. If the existing root file system is configured as an LVM volume, use the following command to start the volume group (for example, vg_hostol6):

    bash-4.1# lvchange -ay vg_hostol6

  7. Run the correct version of fsck (for example, fsck.ext3 or fsck.ext4) to check and correct the integrity of the file system.

    bash-4.1# fsck.extN -f device

    where device is the root file system device (for example, /dev/vg_hostol6/lv_root or /dev/sda2).

  8. Convert the file system to a btrfs file system.

    bash-4.1# btrfs-convert device

  9. Create a mount point (/mnt1) and mount the converted root file system on it.

    bash-4.1# mkdir /mnt1
    bash-4.1# mount -t btrfs device /mnt1

  10. Use the vi command to edit the file /mnt1/etc/fstab, and change the file system type of the root file system to btrfs, for example:

    /dev/mapper/vg_hostol6-lv_root  /       btrfs    defaults  1 1

  11. Create the file .autorelabel in the root of the mounted file system.

    bash-4.1# touch /mnt1/.autorelabel

    The presence of the .autorelabel file in / instructs SELinux to recreate the security attributes of all files on the file system.

    Note

    If you do not create the .autorelabel file, you might not be able to boot the system successfully. If you forget to create the file and the reboot fails, either disable SELinux temporarily by specifying selinux=0 to the kernel boot parameters, or run SELinux in permissive mode by specifying enforcing=0.

  12. Unmount the converted root file system.

    bash-4.1# umount /mnt1

  13. Remove the boot CD, DVD, or ISO, and reboot the system.