From Fedora Project Wiki

No edit summary
No edit summary
 
(22 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Package bcache-tools test cases]]
[[Category:Package bcache-tools test cases]]
{{QA/Test_Case
{{QA/Test_Case
|description=/ on bcache (LVM)
|description=
This page describes a test case for bcache-tools: "/ on bcache using LVM"


Now we have a stable system with /home on LVM on bcache, we can go forward and have / on bcache. Consider thought that bcache is EXPERIMENTAL!
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.
 
Starting with a stable system with /home on LVM on bcache, we can go forward and have / on bcache. Consider thought that bcache is EXPERIMENTAL!
 
=== Prerequisites ===
 
This test requires the following test case as preparation: [[QA:Testcase_bcache-tools_home_on_bcache_(LVM)|/home on bcache (LVM)]]. Furthermore it requires the volume group BCACHE to have at least 2 GB free space!


|setup=
|setup=
If you haven't done so, you should first execute the use case [[QA:Testcase_bcache-tools_home_on_bcache_(LVM)|/home on bcache (LVM)]].
|actions=
To get / on bcache:
To get / on bcache:
# create a Logical Volume: <code>lvcreate -L 2G -n ROOTFS BCACHE</code>
# create a Logical Volume: <code>lvcreate -L 2G -n ROOTFS BCACHE</code>
Line 12: Line 23:
# copy your current root filesystem to /mnt: <code>cp -ax / /mnt</code>
# copy your current root filesystem to /mnt: <code>cp -ax / /mnt</code>
# edit /mnt/fstab so your root fs is mounted like: <code>LABEL=ROOTFS / ext4 defaults 1 1</code>
# edit /mnt/fstab so your root fs is mounted like: <code>LABEL=ROOTFS / ext4 defaults 1 1</code>
 
Now we have a duplicate root filesystem on /dev/BCACHE/ROOTFS. To use it we need to build a new initramfs:
 
# rename your current initramfs: <code>mv /boot/initramfs-`uname -r`.img /boot/initramfs-`uname -r`.img.sav</code>
# Open terminal
# build a new initramfs: <code>dracut -N</code>
# Switch to root user: <code>su -</code>
# if needed make a bachup of /home on your root filesystem.
# comment /home out in your /etc/fstab
# unmount /home: <code>umount /home</code>
# if needed restore your bachup to the /home directory
Now your /home is in your root filesystem. Next:
# create a new filesystem on /dev/bcache0: <code>mkfs -t ext4 -L ROOTFS /dev/bcache0</code>
# mount it: <code>mount /dev/bcache0 /mnt</code>
# copy your current root filesystem to /mnt: <code>cp -ax / /mnt</code>
# edit /mnt/fstab so your root fs is mounted like: <code>LABEL=ROOTFS / ext4 defaults 1 1</code>
Now we have a duplicate root filesystem on /dev/bcache0. To use it we need to build a new initramfs:
# rename your current initramfs: <code>mv /boot/initramfs...img /boot/initramfs...img.sav</code>
# build a new initramfs with <code>dracut -N</code>
Now reboot your system.
Now reboot your system.
# while in grub replace the root=UUID=... parameter in the "linux" line by: root=LABEL=ROOTFS
# while booting edit the default grub entry and replace the root=UUID=... parameter in the "linux" line by: root=LABEL=ROOTFS
# boot your system.
# remove any rd.lvm=0 occurrence
If all goes well, your system now boots fine and it's running on bcache!
# now start the modified grub entry
# Edit your /etc/grub2.cfg file..
If all goes well, your system now boots fine and it's running on LVM on bcache! Now we have to do some final housekeeping:
# .. duplicate the first "menuentry ... { ...}" (about 15 lines).
# update grub config: <code>grub2-mkconfig -o /boot/grub2/grub.cfg</code> for BIOS systems and <code>grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg</code> for UEFI systems
# Now change the first one and replace the root=UUID=... parameter in the "linux" line by root=LABEL=ROOTFS
# rename your current initramfs (again): <code>mv /boot/initramfs-`uname -r`.img /boot/initramfs-`uname -r`.img.sav</code>
# reboot again
# build a new initramfs with <i>only</i> the needed drivers included: <code>dracut</code>
|actions=
Now  your system should be ready!
# 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.
# apply updates: <code>yum update</code>. Specifically try to update the kernel, because it depens on the proper interaction between dracut, bcache-tools and util-linux,
# <code>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 root partition /dev/sda3 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/sda3</code>
# Make /dev/sda3 a bcache backing device: <code>make-bcache -B /dev/sda3</code>
# Note the fact that a new /dev/bcache2 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/bcache2: <code>echo <cset.uuid> > /sys/block/bcache2/bcache/attach</code>
There are three bcache devices now: /dev/bcache0, /dev/bcache1 and /dev/bcache2 each 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/bcache2 uses /dev/sda3 as a backing device.
# use "bcache-status -s" to see details about your bcache devices.
# Now add /dev/bcache2 to out volume group:\
## create a Physical Volume: <code>pvcreate /dev/bcache2</code>
## add it to our Volume Group: <code>vgextend BCACHE /dev/bcache2</code>
Now /dev/sda3 is an <b>cached</b> integral part of the volume group. You can allocate more space to / or /home.
}}
}}
--------------------------------------------------
Now we have a stable system with /home on LVM on bcache, we can go forward and have / on bcache. Consider thought that bcache is EXPERIMENTAL!
To get / on bcache:
* create a Logical Volume: lvcreate -L 2G -n ROOTFS BCACHE
* create a filesystem: mkfs -t ext4 -L ROOTFS /dev/BCACHE/ROOTFS
* mount it: mount /dev/BCACHE/ROOTFS /mnt
* copy your current root filesystem to /mnt: cp -ax / /mnt
* edit /mnt/fstab so your root fs is mounted like: LABEL=ROOTFS / ext4 defaults 1 1
Now we have a duplicate root filesystem on /dev/BCACHE/ROOTFS. To use it we need to build a new initramfs:
* rename your current initramfs: mv /boot/initramfs...img /boot/initramfs...img.sav
* create a new initramfs: dracut -N
Now reboot your system. Edit your default grub entry:
* replace the root=UUID=... parameter in the "linux" line by: root=LABEL=ROOTFS
* remove any rd.lvm=0 occurrence
* boot it.
If all goes well, your system now boots fine and it's running on bcache!
* Edit your /etc/grub2.cfg file..
* .. duplicate the first "menuentry ... { ...}" (about 15 lines).
* Now change the first one and replace the root=UUID=... parameter in the "linux" line by root=LABEL=ROOTFS
* reboot again
Now your system should boot fine.

Latest revision as of 23:33, 13 October 2013


Description

This page describes a test case for bcache-tools: "/ on bcache using LVM"

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.

Starting with a stable system with /home on LVM on bcache, we can go forward and have / on bcache. Consider thought that bcache is EXPERIMENTAL!

Prerequisites

This test requires the following test case as preparation: /home on bcache (LVM). Furthermore it requires the volume group BCACHE to have at least 2 GB free space!

Setup

If you haven't done so, you should first execute the use case /home on bcache (LVM).

How to test

To get / on bcache:

  1. create a Logical Volume: lvcreate -L 2G -n ROOTFS BCACHE
  2. create a filesystem: mkfs -t ext4 -L ROOTFS /dev/BCACHE/ROOTFS
  3. mount it: mount /dev/BCACHE/ROOTFS /mnt
  4. copy your current root filesystem to /mnt: cp -ax / /mnt
  5. edit /mnt/fstab so your root fs is mounted like: LABEL=ROOTFS / ext4 defaults 1 1

Now we have a duplicate root filesystem on /dev/BCACHE/ROOTFS. To use it we need to build a new initramfs:

  1. rename your current initramfs: mv /boot/initramfs-uname -r.img /boot/initramfs-uname -r.img.sav
  2. build a new initramfs: dracut -N

Now reboot your system.

  1. while booting edit the default grub entry and replace the root=UUID=... parameter in the "linux" line by: root=LABEL=ROOTFS
  2. remove any rd.lvm=0 occurrence
  3. now start the modified grub entry

If all goes well, your system now boots fine and it's running on LVM on bcache! Now we have to do some final housekeeping:

  1. update grub config: grub2-mkconfig -o /boot/grub2/grub.cfg for BIOS systems and grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg for UEFI systems
  2. rename your current initramfs (again): mv /boot/initramfs-uname -r.img /boot/initramfs-uname -r.img.sav
  3. build a new initramfs with only the needed drivers included: dracut

Now your system should be ready!

  1. reboot your system to see if it boots OK
  2. apply updates: yum update. Specifically try to update the kernel, because it depens on the proper interaction between dracut, bcache-tools and util-linux,
  3. 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 root partition /dev/sda3 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/sda3
  2. Make /dev/sda3 a bcache backing device: make-bcache -B /dev/sda3
  3. Note the fact that a new /dev/bcache2 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/bcache2: echo <cset.uuid> > /sys/block/bcache2/bcache/attach

There are three bcache devices now: /dev/bcache0, /dev/bcache1 and /dev/bcache2 each 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/bcache2 uses /dev/sda3 as a backing device.

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

Now /dev/sda3 is an cached integral part of the volume group. You can allocate more space to / or /home.