18.13 Installing a Btrfs root File System

18.13.1 Setting up a New NFS Server
18.13.2 Configuring an Existing NFS Server
18.13.3 Setting up a New HTTP Server
18.13.4 Configuring an Existing HTTP Server
18.13.5 Setting up a Network Installation Server
18.13.6 Installing from a Network Installation Server
18.13.7 About the Installation root File System
18.13.8 Creating Snapshots of the root File System
18.13.9 Mounting Alternate Snapshots as the root File System
18.13.10 Deleting Snapshots of the root File System

For compatibility reasons, the default installation image of Oracle Linux boots the Red Hat compatible kernel to perform the installation. Oracle provides an alternative installation image (UEK Boot ISO) that supports the installation of Oracle Linux 6 Update 3 or later using the Unbreakable Enterprise Kernel (UEK) as the installation kernel. This installation method allows you to create a btrfs root file system.

As the UEK Boot ISO contains only the bootable installation image, you must set up a network installation server for the RPM packages. This server must have sufficient storage space to host the full Oracle Linux Release 6 Update 3 or later Media Pack DVD image (approximately 3.5 GB), and you must configure it to serve the image files using either NFS or HTTP to the target system on which you want to install Oracle Linux 6 Update 3 or later.

18.13.1 Setting up a New NFS Server

Note

This procedure assumes that you are setting up an Oracle Linux 6 system as an NFSv4 server. Using NFSv4 greatly simplifies firewall configuration as you need only configure a single rule for TCP port 2049.

To set up an NFS server:

  1. Install the nfs-utils package.

    # yum install nfs-utils
  2. Create the directory where you will copy the full Oracle Linux Release 6 Media Pack DVD image, for example /var/OSimage/OL6.5:

    # mkdir -p /var/OSimage/OL6.5
  3. Edit the configuration file, /etc/exports, as follows.

    1. Add an entry for the directory where you will copy the DVD image.

      The following example allows read-only access to the directory /var/OSimage/OL6.5 for any NFS client on the 192.168.1 subnet:

      /var/OSimage/OL6.5 192.168.1.0/24(ro)
    2. Save your changes to the file.

  4. Start the NFS server, and configure it to start after a reboot.

    # service rpcbind start
    # service nfs start
    # service nfslock start
    # chkconfig rpcbind on
    # chkconfig nfs on
    # chkconfig nfslock on
  5. If you have configured a firewall on your system, configure it to allow incoming NFSv4 requests from NFS clients.

    For example, use the following commands to configure iptables to allow NFSv4 connections and save the change to the firewall configuration:

    # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 2049 -j ACCEPT
    # service iptables save

18.13.2 Configuring an Existing NFS Server

To configure an existing NFS server:

  1. Create the directory where you will copy the full Oracle Linux Release 6 Media Pack DVD image, for example /var/OSimage/OL6.5:

    # mkdir -p /var/OSimage/OL6.5
  2. Use the exportfs command to export the directory.

    # exportfs -i -o options client:export_dir

    For example, to allow read-only access to the directory /var/OSimage/OL6.5 for any NFS client on the 192.168.1 subnet:

    # exportfs -i -o ro 192.168.1.0/24:/var/OSimage/OL6.5

18.13.3 Setting up a New HTTP Server

Note

These instructions assume that you are setting up an Oracle Linux 6 system as an Apache HTTP server.

To set up an HTTP server:

  1. Install the Apache HTTP server package.

    # yum install httpd
  2. Create the directory where you will copy the full Oracle Linux Release 6 Media Pack DVD image, for example /var/www/html/OSimage/OL6.5:

    # mkdir -p /var/www/html/OSimage/OL6.5
    Note

    If SELinux is enabled in enforcing mode on your system, create the directory under the /var/www/html directory hierarchy so that the httpd_sys_content_t file type is set automatically on all the files in the repository.

  3. Edit the HTTP server configuration file, /etc/httpd/conf/httpd.conf, as follows:

    1. Specify the resolvable domain name of the server in the argument to ServerName.

      ServerName server_addr:80

      If the server does not have a resolvable domain name, enter its IP address instead. For example, the following entry would be appropriate for an HTTP server with the IP address 192.168.1.100.

      ServerName 192.168.1.100:80
    2. If the directory to which you will copy the DVD image in not under /var/www/html, change the default setting of DocumentRoot.

      In this example, the DVD image will be copied to /var/www/html/OSimage/OL6.5 so the setting of DocumentRoot can remain unchanged.

      DocumentRoot "/var/www/html"
    3. Verify that the <Directory> setting points to the same setting as DocumentRoot.

      #
      # This should be changed to whatever you set DocumentRoot to.
      #
      <Directory "/var/www/html">
    4. If you want to be able to browse the directory hierarchy, verify that the Options directive specifies the Indexes option, for example:

      Options Indexes FollowSymLinks
      Note

      The Indexes option is not required for installation.

    5. Save your changes to the file.

  4. Start the Apache HTTP server, and configure it to start after a reboot.

    # service httpd start
    # chkconfig httpd on
  5. If you have enabled a firewall on your system, configure it to allow incoming HTTP connection requests on TCP port 80.

    For example, the following command configures iptables to allow incoming HTTP connection requests and saves the change to the firewall configuration:

    # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
    # service iptables save

18.13.4 Configuring an Existing HTTP Server

To configure an existing Apache HTTP server:

  1. Under the DocumentRoot hierarchy that is defined in the HTTP server configuration file (/etc/httpd/conf/httpd.conf), create the directory where you will copy the full Oracle Linux Release 6 Media Pack DVD image, for example /var/www/html/OSimage/OL6.5:

    # mkdir -p /var/www/html/OSimage/OL6.5
  2. Edit the HTTP server configuration file, /etc/httpd/conf/httpd.conf, and add a <Directory> section, for example:

    <Directory "/var/www/html/OSimage/OL6.5">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    Place this section after the closing </Directory> statement for the <Directory DocumentRoot> section.

    Note

    The Indexes option is not required for installation. Specify this option if you want to be able to browse the directory hierarchy.

18.13.5 Setting up a Network Installation Server

Note

This procedure assumes that you have set up the system as an NFS or HTTP server.

To set up a network installation server:

  1. Download the full Oracle Linux Media Pack DVD image (for example, V41362-01.iso for x86_64 (64 bit) Oracle Linux Release 6 Update 5) from the Oracle Software Delivery Cloud at http://edelivery.oracle.com/linux.

  2. Mount the DVD image on a suitable mount point (for example, /mnt):

    # mount -t iso9660 -o loop V41362-01.iso mount_dir
  3. Use the following command to extract the contents of the DVD image into a directory (output_dir) whose contents are shareable using NFS or HTTP:

    # cp -a -T mount_dir output_dir

    For example, to copy the DVD image mounted on /mnt to /var/OSimage/OL6.5:

    # cp -a -T /mnt /var/OSimage/OL6.5

    or to /var/www/html/OSimage/OL6.5:

    # cp -a -T /mnt /var/www/html/OSimage/OL6.5
  4. Unmount the DVD image:

    # umount mount_dir
  5. Download the UEK Boot ISO image for the desired architecture (for example, V41364-01.iso for x86_64 (64 bit)).

  6. Mount the UEK Boot ISO image:

    # mount -t iso9660 -o loop V41364-01.iso
  7. Replace the contents of the images directory that you copied from the DVD image with the contents of the images directory from the UEK Boot ISO image:

    # rm -rf output_dir/images
    # cp -r mount_dir/images output_dir 

    For example, to replace /var/OSimage/OL6.5/images:

    # rm -rf /var/OSimage/OL6.5/images
    # cp -r /mnt/images /var/OSimage/OL6.5

    or to replace /var/www/html/OSimage/OL6.5/images:

    # rm -rf /var/www/html/OSimage/OL6.5/images
    # cp -r /mnt/images /var/www/html/OSimage/OL6.5
  8. If SELinux is enabled in enforcing mode on your system and you have configured the system as an HTTP server but you did not copy the DVD image to a directory under /var/www/html:

    1. Use the semanage command to define the default file type of the directory hierarchy as httpd_sys_content_t:

      # /usr/sbin/semanage fcontext -a -t httpd_sys_content_t "/var/OSimage(/.*)?"

    2. Use the restorecon command to apply the file type to the entire directory hierarchy.

      # /sbin/restorecon -R -v /var/OSimage
    Note

    The semanage and restorecon commands are provided by the policycoreutils-python and policycoreutils packages.

  9. Copy the UEK Boot ISO image to a suitable medium from which you can boot the target system on which you want to install Oracle Linux 6 Update 5.

  10. Unmount the UEK Boot ISO image:

    # umount mount_dir

18.13.6 Installing from a Network Installation Server

To install a target system from a network installation server:

  1. Boot the target system using the UEK Boot ISO.

  2. Select Install or upgrade an existing system, press Tab, and enter askmethod as an additional parameter on the boot command line:

    > vmlinuz initrd=initrd.img askmethod
  3. On the Installation Method screen, select either NFS directory or URL depending on whether you configured your installation server to use NFS or HTTP respectively.

  4. After configuring the network settings, enter the settings for the NFS or HTTP installation server.

    For installation using NFS, enter the path of the full DVD image, for example /var/OSimage/OL6.5.

    For installation using HTTP, enter the URL of the full DVD image, for example http://192.168.1.100/OSimage/OL6.5.

  5. The default disk layout creates a btrfs root file system.

    Note

    You cannot configure a bootable partition, such as /boot, as a btrfs file system.

18.13.7 About the Installation root File System

The mounted root file system is a snapshot (named install) of the root file system taken at the end of installation. To find out the ID of the parent of the root file system subvolume, use the following command:

# btrfs subvolume list /
ID 258 top level 5 path install 

In this example, the installation root file system subvolume has an ID of 5. The subvolume with ID 258 (install) is currently mounted as /. Figure 18.1, “Layout of the root File System Following Installation” illustrates the layout of the file system:

Figure 18.1 Layout of the root File System Following Installation

The diagram illustrates the layout of the example root file system with the top level subvolume (ID 5) containing the root file system as it existed after installation and the subvolume install (ID 258) containing the currently active root file system.


The top-level subvolume with ID 5 records the contents of the root file system file system at the end of installation. The default subvolume (install) with ID 258 is currently mounted as the active root file system.

The mount command shows the device that is currently mounted as the root file system:

# mount
/dev/mapper/vg_btrfs-lv_root on / type btrfs (rw)
...

To mount the installation root file system volume, you can use the following commands:

# mkdir /instroot
# mount -o subvolid=5 /dev/mapper/vg_btrfs-lv_root /instroot

If you list the contents of /instroot, you can see both the contents of the installation root file system volume and the install snapshot, for example:

# ls /instroot
bin   cgroup  etc   install  lib64  misc  net  proc  sbin     srv  tmp  var
boot  dev     home  lib      media  mnt   opt  root  selinux  sys  usr

The contents of / and /instroot/install are identical as demonstrated in the following example where a file (foo) created in /instroot/install is also visible in /:

# touch /instroot/install/foo
# ls /
bin   cgroup  etc  home      lib    media  mnt  opt   root  selinux  sys  usr 
boot  dev     foo  instroot  lib64  misc   net  proc  sbin  srv      tmp  var
# ls /instroot/install
bin   cgroup  etc  home      lib    media  mnt  opt   root  selinux  sys  usr 
boot  dev     foo  instroot  lib64  misc   net  proc  sbin  srv      tmp  var
# rm -f /foo
# ls /
bin   cgroup  etc   instroot  lib64  misc  net  proc  sbin     srv  tmp  var
boot  dev     home  lib       media  mnt   opt  root  selinux  sys  usr
# ls /instroot/install
bin   cgroup  etc   instroot  lib64  misc  net  proc  sbin     srv  tmp  var
boot  dev     home  lib       media  mnt   opt  root  selinux  sys  usr

18.13.8 Creating Snapshots of the root File System

To take a snapshot of the current root file system:

  1. Mount the top level of the root file system on a suitable mount point.

    # mount -o subvolid=5 /dev/mapper/vg_btrfs-lv_root /mnt
  2. Change directory to the mount point and take the snapshot. In this example, the install subvolume is currently mounted as the root file system system.

    # cd /mnt
    # btrfs subvolume snapshot install root_snapshot_1
    Create a snapshot of 'install' in './root_snapshot_1'
  3. Change directory to / and unmount the top level of the file system.

    # cd /
    # umount /mnt 

    The list of subvolumes now includes the newly created snapshot.

    # btrfs subvolume list / 
    ID 258 top level 5 path install
    ID 260 top level 5 path root_snapshot_1

18.13.9 Mounting Alternate Snapshots as the root File System

If you want to roll back changes to your system, you can mount a snapshot as the root file system by specifying its ID as the default subvolume, for example:

# btrfs subvolume set-default 260 /

Reboot the system for the change to take effect.

18.13.10 Deleting Snapshots of the root File System

To delete a snapshot:

  1. Mount the top level of the file system, for example:

    # mount -o subvolid=5 /dev/mapper/vg_btrfs-lv_root /mnt
  2. Change directory to the mount point and delete the snapshot.

    # cd /mnt
    # btrfs subvolume delete install
    Delete subvolume '/mnt/install'
  3. Change directory to / and unmount the top level of the file system.

    # cd /
    # umount /mnt 

    The list of subvolumes now does not include install.

    # btrfs subvolume list / 
    ID 260 top level 5 path root_snapshot_1