laravel / homestead

MIT License
3.85k stars 1.45k forks source link

LVM changes in 20.04 #1415

Closed svpernova09 closed 4 years ago

svpernova09 commented 4 years ago

Looks like Ubuntu 20.04 ships with an LVM out of the box? It's at least acting differently than 18.04.

root@ubuntu-20:~# lvs
  LV     VG          Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   vgubuntu-20 -wi-ao---- <62.54g
  swap_1 vgubuntu-20 -wi-ao---- 980.00m
root@ubuntu-20:~#

Provisioning script from Settler

# Install LMM for database snapshots
apt-get install -y thin-provisioning-tools bc
git clone https://github.com/Lullabot/lmm.git /opt/lmm
sed -e 's/mysql/vgubuntu-20/' -i /opt/lmm/config.sh
ln -s /opt/lmm/lmm /usr/local/sbin/lmm

# Create a thinly provisioned volume to move the database to. We use 64G as the
# size leaving ~5GB free for other volumes.
mkdir -p /vgubuntu-20/master
sudo lvs
lvcreate -L 64G -T vgubuntu-20/thinpool

This is where we run into issues:

root@ubuntu-20:~# lvcreate -L 64G -T vgubuntu-20/thinpool
  Thin pool volume with chunk size 64.00 KiB can address at most 15.81 TiB of data.
  Volume group "vgubuntu-20" has insufficient free space (0 extents): 16 required.
root@ubuntu-20:~#

Now I'm running this on a Vagrant VM with this Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-20.04"
end

Is this because the VM I'm running on doesn't have the storage size that it would if I was using Packer? I wanted to check into this, going to work around it but would appreciate some help/guidance.

/cc @deviantintegral

deviantintegral commented 4 years ago

It seems likely to me that the initial disk size doesn't have anything left over.

More recently, I've been on a project that is all in on Docker, and because Docker for Mac is such a performance problem, I've still been using a vagrant VM. I ended up using the following to provision a separate disk, avoiding any problems with the base disk config at all:

  # Create a disk for zfs / docker container images.
  zfs_dir = "#{dir}/.vagrant"
  config.vm.provider "virtualbox" do |vb|
    zfs = File.join(zfs_dir, 'zfs.vdi')
    unless File.exists?(zfs)
      vb.customize ["createhd", "--filename", zfs, "--size", settings["vb"]["zfssize"] * 1024]
    end
    vb.customize ["storageattach", :id, "--storagectl", "SCSI", "--port", 2, "--device", 0, "--type", "hdd", "--medium", zfs]
  end

I wonder if there's any way to do this in a cross-provider fashion?

The one significant advantage of zfs is that it has built-in compression, which makes a huge difference for databases. Even for SSDs, you generally get improved performance with compression + reduced IO compared to uncompressed IO. It kind of makes me want to create a new version of lmm (in spirit, not implementation) with zfs snapshots.

Perhaps since this isn't "production", an even more robust solution would be to use a loopback device and disk image. I originally used the built in lvm setup with Ubuntu because it seemed to be more straightforward, but perhaps that's not the case.

svpernova09 commented 4 years ago

Think I've got it sorted out

20.04

vagrant@homestead:~$ df -h
Filesystem                               Size  Used Avail Use% Mounted on
udev                                     1.9G     0  1.9G   0% /dev
tmpfs                                    393M  1.5M  392M   1% /run
/dev/mapper/homestead--vg-root            54G  4.3G   47G   9% /
tmpfs                                    2.0G     0  2.0G   0% /dev/shm
tmpfs                                    5.0M     0  5.0M   0% /run/lock
tmpfs                                    2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/sda1                                511M  4.0K  511M   1% /boot/efi
/dev/mapper/homestead--vg-mysql--master   63G  237M   60G   1% /homestead-vg/master
vagrant                                  466G  316G  151G  68% /vagrant
tmpfs                                    393M   24K  393M   1% /run/user/124
home_vagrant_midsouthmakers              466G  316G  151G  68% /home/vagrant/midsouthmakers
tmpfs                                    393M  4.0K  393M   1% /run/user/1000
vagrant@homestead:~$

18.04

vagrant@homestead:~$ df -h
Filesystem                               Size  Used Avail Use% Mounted on
udev                                     1.9G     0  1.9G   0% /dev
tmpfs                                    394M  8.7M  386M   3% /run
/dev/mapper/homestead--vg-root            54G  5.6G   46G  11% /
tmpfs                                    2.0G   28K  2.0G   1% /dev/shm
tmpfs                                    5.0M     0  5.0M   0% /run/lock
tmpfs                                    2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mapper/homestead--vg-mysql--master   63G  262M   60G   1% /homestead-vg/master
vagrant                                  466G  299G  168G  65% /vagrant
home_vagrant_midsouthmakers              466G  299G  168G  65% /home/vagrant/midsouthmakers
tmpfs                                    394M     0  394M   0% /run/user/1000
vagrant@homestead:~$