over 7 years ago

My target is to install ubuntu with lvmcache, use a ssd drive to speed up system io.

lvmcache pitfalls on ubuntu (2016/02)

  1. 14.04 lvm2 don't support lvmcache
  2. 15.04, 15.10 raid cause NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s! error on my machine by default, system always stucks right after boot
  3. Failed to boot with lvm2's new default setting cache-policy-smq lvmcache failed to boot: “device-mapper: cache-policy: unknown policy type”

UPDATE 2016/02/18 ubuntu 16.04 has kernel 4.4 to avoid the CPU#0 stuck problem. i am going with 16.04 now.

1. install 16.04 + raid + lvm

2. add lvmcache

Create cache-pool with mq policy until smq is well-supported.

thin-provisioning-tools is needed: it's contain /usr/sbin/cache_check

apt-get install thin-provisioning-tools
apt-get update
aptitude full-upgrade
dd if=/dev/zero bs=1M count=1000 of=/dev/sde
pvcreate /dev/sde
vgextend vg0 /dev/sde
lvcreate -L 480M -n cachemeta vg0 /dev/sde
lvcreate -L 475000M -n cachedata vg0 /dev/sde
lvconvert --type cache-pool --cachepolicy mq --chunksize 8192 --poolmetadata vg0/cachemeta --cachemode writeback vg0/cachedata --yes
lvconvert --type cache --cachepool vg0/cachedata vg0/root

HOOK=$(tempfile)
# Add a hook script to initramfs to add the right tools and modules
cat <<'EOF' > $HOOK
#!/bin/sh
PREREQ="lvm2"
prereqs()
{
  echo "$PREREQ"
}
case $1 in
prereqs)
  prereqs
  exit 0
  ;;
esac
if [ ! -x /usr/sbin/cache_check ]; then
  exit 0
fi
. /usr/share/initramfs-tools/hook-functions
copy_exec /usr/sbin/cache_check
manual_add_modules dm_cache dm_cache_mq dm_cache_smq dm_persistent_data dm_bufio
EOF

cp $HOOK /etc/initramfs-tools/hooks/lvmcache
chmod +x /etc/initramfs-tools/hooks/lvmcache

echo "dm_cache" >> /etc/initramfs-tools/modules
echo "dm_cache_mq" >> /etc/initramfs-tools/modules
echo "dm_cache_smq" >> /etc/initramfs-tools/modules
echo "dm_persistent_data" >> /etc/initramfs-tools/modules
echo "dm_bufio" >> /etc/initramfs-tools/modules

# Update initramfs

update-initramfs -u

Reboot now.

IF Boot failed: Use ubuntu 16.04 live CD to run boot-repair

16.04 xenial is required if you are using lvmcache

sudo -s
add-apt-repository ppa:yannubuntu/boot-repair && apt-get update
apt-get install -y boot-repair mdadm thin-provisioning-tools
boot-repair
← Build Nginx http2 + PageSpeed + Passenger on ubuntu 14.04
 
comments powered by Disqus