From Fedora Project Wiki

No edit summary
No edit summary
 
(16 intermediate revisions by 2 users not shown)
Line 6: Line 6:
This page describes a test case for bcache-tools, Bcache is a Linux kernel block layer cache. It allows one or more fast disk drives such as flash-based solid state drives (SSDs) to act as a cache for one or more slower hard disk drives. The bcache-tools package contains the utilities for manipulating bcache
This page describes a test case for bcache-tools, Bcache is a Linux kernel block layer cache. It allows one or more fast disk drives such as flash-based solid state drives (SSDs) to act as a cache for one or more slower hard disk drives. The bcache-tools package contains the utilities for manipulating bcache


Testing covers not only bcache-tools but also the interaction between bcache-tools and other packages: kernel, util-linux, dracut and lvm2.
Testing covers not only bcache-tools but also the interaction between bcache-tools and other packages: kernel, util-linux and lvm2.


Once your fresh Fedora 20 system is running, we will "move" /home to a Logical Volume (LVM) on a bcache device. Because of the flexibility that LVM provides the approach is quite different from page 1.A, for example we'll start by using sda4!  
Once your fresh Fedora 20 system is running, we will "move" /home to a Logical Volume (LVM) on a bcache device. Because of the flexibility that LVM provides the approach is quite different from page 1.A, for example we'll start by using sda4!  
Line 24: Line 24:
##<code>wipefs -a /dev/sda4</code>
##<code>wipefs -a /dev/sda4</code>
##<code>wipefs -a /dev/sdb1</code>
##<code>wipefs -a /dev/sdb1</code>
# Next install bcache tools and lvm2: <code>yum install bcache-tools lvm2</code>
After any traces of previous bcache installations have been wiped:
# install bcache tools and lvm2: <code>yum install bcache-tools lvm2</code>
# If not present yet, create a /dev/sda4 partition as specified by the [[QA:Testcase_bcache-tools-prerequisites|prerequisites page]]
# reboot to be sure bcache-tools and the other software operate well
|actions=
|actions=
Now create an use the bcache devices:
Now create and use the bcache devices:
# Erase the old /home from /dev/sda2: <code>wipefs -a /dev/sda4</code>
# Make /dev/sda4 a bcache backing device: <code>make-bcache -B /dev/sda4</code>
# Make /dev/sda4 a bcache backing device: <code>make-bcache -B /dev/sda4</code>
# Erase any existing metadata from /dev/sdb1: <code>wipefs -a /dev/sdb1</code>
# Make /dev/sdb1 a bcache caching device: <code>make-bcache -C /dev/sdb1</code>
# Make /dev/sdb1 a bcache caching device: <code>make-bcache -C /dev/sdb1</code>
# Note the set uuid and attach /dev/sdb1 to /dev/sda2: <code>echo <set uuid> > /sys/block/bcache0/bcache/attach</code>
# Retrieve the cset.uuid from your /dev/sdb1 caching device: <code>bcache-super-show /dev/sdb1</code>
# Attach /dev/sdb1 to /dev/bcache0: <code>echo <cset.uuid> > /sys/block/bcache0/bcache/attach</code>
Now you have a bcache device: /dev/bcache0
Now you have a bcache device: /dev/bcache0
# use "bcache-status -s" to see details about your bcache device.
# use "bcache-status -s" to see details about your bcache device.
Line 40: Line 42:
This will be our new /home device. To use it first move the current /home to another mount point:
This will be our new /home device. To use it first move the current /home to another mount point:
# replace /home entry in your /etc/fstab: <code>LABEL=HOME /home ext4 defaults 1 2</code>
# replace /home entry in your /etc/fstab: <code>LABEL=HOME /home ext4 defaults 1 2</code>
# If needed copy your current /home to the new /home:
# If needed copy your current /home to the new /home, <b>because the next steps will destroy /dev/sda</b>:
## <code>mkdir /home.old</code>
## <code>mkdir /home.old</code>
## <code>umount /home</code>
## <code>umount /home</code>
Line 48: Line 50:
## <code>umount /home.old</code>
## <code>umount /home.old</code>
## <code>rmdir /home.old</code>
## <code>rmdir /home.old</code>
# build a new initramfs with <code>dracut -N</code>
Now you have a system with /home on LVM2 on bcache. Next we can reuse the old /home disk space:
Now you have a system with /home on LVM2 on bcache.
# First wipe all metadata: <code>wipefs -a /dev/sda2</code>
# Make /dev/sda2 a bcache backing device: <code>make-bcache -B /dev/sda2</code>
# Note the fact that a new /dev/bcache1 device is created
# Retrieve the cset.uuid from your /dev/sdb1 caching device: <code>bcache-super-show /dev/sdb1</code>
# Attach /dev/sdb1 also to /dev/bcache1: <code>echo <cset.uuid> > /sys/block/bcache1/bcache/attach</code>
There are two bcache devices now: /dev/bcache0 and /dev/bcache1 both using /dev/sdb1 as a caching device. The numbering of the bcache devices happens dynamically during boot, but until you reboot you can safely assume /dev/bcache0 uses /dev/sda4 as a backing device and /dev/bcache1 uses /dev/sda2 as a back device.
# use "bcache-status -s" to see details about your bcache devices.
# Now add /dev/bcache1 to out volume group:\
## create a Physical Volume: <code>pvcreate /dev/bcache1</code>
## add it to our Volume Group: <code>vgextend BCACHE /dev/bcache1</code>
Now /dev/sda2 is a <b>cached</b> integral part of the volume group. You can allocate all space to /home, but to allow some further testing <b>don't do that yet</b>!
# reboot your system to see if it boots OK.
# reboot your system to see if it boots OK.
# do some other testing if you like.
# <code>cd /home && wget http://dl.fedoraproject.org/pub/alt/stage/20-Beta-TC2/Fedora/x86_64/iso/Fedora-20-Beta-TC2-x86_64-DVD.iso</code>
|results=
|results=
# All steps complete without errors
# All steps complete without errors
# wget should have the same speed of all time
|optional=
The original /home partition is no longer used, so we can reclaim its disk space by adding it to the volume group:
# First wipe all metadata: <code>wipefs -a /dev/sda2</code>
# Make /dev/sda2 a bcache backing device: <code>make-bcache -B /dev/sda2</code>
# Note the fact that a new /dev/bcache1 device is created
# Retrieve the cset.uuid from your /dev/sdb1 caching device: <code>bcache-super-show /dev/sdb1</code>
# Attach /dev/sdb1 also to /dev/bcache1: <code>echo <cset.uuid> > /sys/block/bcache1/bcache/attach</code>
There are two bcache devices now: /dev/bcache0 and /dev/bcache1 both using /dev/sdb1 as a caching device. The numbering of the bcache devices happens dynamically during boot, but until you reboot you can safely assume /dev/bcache0 uses /dev/sda4 as a backing device and /dev/bcache1 uses /dev/sda2 as a back device.
# use "bcache-status -s" to see details about your bcache devices.
# Now add /dev/bcache1 to out volume group:\
## create a Physical Volume: <code>pvcreate /dev/bcache1</code>
## add it to our Volume Group: <code>vgextend BCACHE /dev/bcache1</code>
Now /dev/sda2 is an <b>cached</b> integral part of the volume group. You can allocate all space to /home, but to allow some further testing <b>don't do that yet</b>!
}}
}}

Latest revision as of 23:33, 13 October 2013


Description

This page describes a test case for bcache-tools; "/home on bcache using LVM".

This page describes a test case for bcache-tools, Bcache is a Linux kernel block layer cache. It allows one or more fast disk drives such as flash-based solid state drives (SSDs) to act as a cache for one or more slower hard disk drives. The bcache-tools package contains the utilities for manipulating bcache

Testing covers not only bcache-tools but also the interaction between bcache-tools and other packages: kernel, util-linux and lvm2.

Once your fresh Fedora 20 system is running, we will "move" /home to a Logical Volume (LVM) on a bcache device. Because of the flexibility that LVM provides the approach is quite different from page 1.A, for example we'll start by using sda4!

Prerequisites

The prerequisites for running the bcache-tools testcases can be found on this page

In this test case we'll need /dev/sda4 to build a new Volume Group on bcache.

Setup

Do the following steps:

  1. Open terminal
  2. Switch to root user: su -

First of all we have to make sure no traces of bcache superblocks are left on /dev/sda4 and /dev/sdb1. So before installing bcache-tools do the following:

  1. update util-linux to the latest version (2.24 is required): yum update util-linux
  2. Wipe whatever is on the two partitions:
    1. wipefs -a /dev/sda4
    2. wipefs -a /dev/sdb1

After any traces of previous bcache installations have been wiped:

  1. install bcache tools and lvm2: yum install bcache-tools lvm2
  2. If not present yet, create a /dev/sda4 partition as specified by the prerequisites page
  3. reboot to be sure bcache-tools and the other software operate well

How to test

Now create and use the bcache devices:

  1. Make /dev/sda4 a bcache backing device: make-bcache -B /dev/sda4
  2. Make /dev/sdb1 a bcache caching device: make-bcache -C /dev/sdb1
  3. Retrieve the cset.uuid from your /dev/sdb1 caching device: bcache-super-show /dev/sdb1
  4. Attach /dev/sdb1 to /dev/bcache0: echo <cset.uuid> > /sys/block/bcache0/bcache/attach

Now you have a bcache device: /dev/bcache0

  1. use "bcache-status -s" to see details about your bcache device.
  2. create a Physical Volume: pvcreate /dev/bcache0
  3. create a Volume Group: vgcreate BCACHE /dev/bcache0
  4. create a Logical Volume: lvcreate -L 2G -n HOME BCACHE
  5. create a filesystem: mkfs -t ext4 -L HOME /dev/BCACHE/HOME

This will be our new /home device. To use it first move the current /home to another mount point:

  1. replace /home entry in your /etc/fstab: LABEL=HOME /home ext4 defaults 1 2
  2. If needed copy your current /home to the new /home, because the next steps will destroy /dev/sda:
    1. mkdir /home.old
    2. umount /home
    3. mount /dev/sda2 /home.old
    4. mount /home
    5. cp -ax /home.old/* /home
    6. umount /home.old
    7. rmdir /home.old

Now you have a system with /home on LVM2 on bcache. Next we can reuse the old /home disk space:

  1. First wipe all metadata: wipefs -a /dev/sda2
  2. Make /dev/sda2 a bcache backing device: make-bcache -B /dev/sda2
  3. Note the fact that a new /dev/bcache1 device is created
  4. Retrieve the cset.uuid from your /dev/sdb1 caching device: bcache-super-show /dev/sdb1
  5. Attach /dev/sdb1 also to /dev/bcache1: echo <cset.uuid> > /sys/block/bcache1/bcache/attach

There are two bcache devices now: /dev/bcache0 and /dev/bcache1 both using /dev/sdb1 as a caching device. The numbering of the bcache devices happens dynamically during boot, but until you reboot you can safely assume /dev/bcache0 uses /dev/sda4 as a backing device and /dev/bcache1 uses /dev/sda2 as a back device.

  1. use "bcache-status -s" to see details about your bcache devices.
  2. Now add /dev/bcache1 to out volume group:\
    1. create a Physical Volume: pvcreate /dev/bcache1
    2. add it to our Volume Group: vgextend BCACHE /dev/bcache1

Now /dev/sda2 is a cached integral part of the volume group. You can allocate all space to /home, but to allow some further testing don't do that yet!

  1. reboot your system to see if it boots OK.
  2. cd /home && wget http://dl.fedoraproject.org/pub/alt/stage/20-Beta-TC2/Fedora/x86_64/iso/Fedora-20-Beta-TC2-x86_64-DVD.iso

Expected Results

  1. All steps complete without errors
  2. wget should have the same speed of all time

Optional

The original /home partition is no longer used, so we can reclaim its disk space by adding it to the volume group:

  1. First wipe all metadata: wipefs -a /dev/sda2
  2. Make /dev/sda2 a bcache backing device: make-bcache -B /dev/sda2
  3. Note the fact that a new /dev/bcache1 device is created
  4. Retrieve the cset.uuid from your /dev/sdb1 caching device: bcache-super-show /dev/sdb1
  5. Attach /dev/sdb1 also to /dev/bcache1: echo <cset.uuid> > /sys/block/bcache1/bcache/attach

There are two bcache devices now: /dev/bcache0 and /dev/bcache1 both using /dev/sdb1 as a caching device. The numbering of the bcache devices happens dynamically during boot, but until you reboot you can safely assume /dev/bcache0 uses /dev/sda4 as a backing device and /dev/bcache1 uses /dev/sda2 as a back device.

  1. use "bcache-status -s" to see details about your bcache devices.
  2. Now add /dev/bcache1 to out volume group:\
    1. create a Physical Volume: pvcreate /dev/bcache1
    2. add it to our Volume Group: vgextend BCACHE /dev/bcache1

Now /dev/sda2 is an cached integral part of the volume group. You can allocate all space to /home, but to allow some further testing don't do that yet!