lmm icon indicating copy to clipboard operation
lmm copied to clipboard

Love this idea, but getting `df: '': No such file or directory Logical volume name "" is invalid.`

Open ryancwalsh opened this issue 5 years ago • 7 comments

Thank you so much for developing this tool.

I've never created snapshots before and am having trouble following these steps: https://laravel.com/docs/7.x/homestead#database-snapshots

I was wondering if you could please let me know why this is happening?

sudo lmm status
Active snapshot:

Database snapshots:
  master

2.70% used by MySQL databases.
sudo lmm branch beforeImports
df: '': No such file or directory
  Logical volume name "" is invalid.
  Run `lvcreate --help' for more information.
mount: /homestead-vg/beforeImports: special device /dev/homestead-vg/mysql-beforeImports does not exist.
mount: /homestead-vg/beforeImports: special device /dev/homestead-vg/mysql-beforeImports does not exist.
mount: /homestead-vg/prod-YYYY-MM-DD: special device /dev/homestead-vg/mysql-prod-YYYY-MM-DD does not exist.
mount: /homestead-vg/beforeImports: special device /dev/homestead-vg/mysql-beforeImports does not exist.
sudo lmm checkout master
is the currently active database.
Setting /homestead-vg/master as the active database.
rm: cannot remove '/var/lib/mysql': Is a directory
ln: failed to create symbolic link '/var/lib/mysql/master': File exists

More details here: https://stackoverflow.com/questions/60623570/how-can-i-get-the-laravel-7-homestead-database-snapshots-working

Thanks in advance! I'm so excited because I think database snapshots will feel like a major leap forward in my dev process.

ryancwalsh avatar Mar 10 '20 18:03 ryancwalsh

Can you please post your Homestead.yml and any other changes you've made? Following the issue template helps.

Since it's been a while, I set up a completely fresh install and was able to branch databases with both MySQL and mariadb.

deviantintegral avatar Mar 10 '20 20:03 deviantintegral

@deviantintegral Thank you so much for looking into this.

I don't see a template at https://github.com/Lullabot/lmm/issues/new but maybe I'm looking in the wrong place.

I wanted to avoid doing a vagrant destroy since those have always caused surprising problems for me, but I agree that starting fresh will narrow down the variables. I'll poke around and let you know. Thanks.

ryancwalsh avatar Mar 10 '20 20:03 ryancwalsh

@deviantintegral vagrant destroy was the nightmare I feared. Lots of corruption and getting stuck. "backup: true" didn't work. I had to nuke everything.

So I believe I'm starting completely fresh, and I took the opportunity to upgrade: Virtualbox 6.1.4 (upgraded just now), Homestead v10.4.0 (upgraded just now), Windows 10, Vagrant 2.2.7.

My Homestead.yaml is below, and I needed to comment out the elasticsearch lines to get it to work because at first it threw this:

    vboxHomestead: Building dependency tree...
    vboxHomestead: Reading state information...
    vboxHomestead: E
    vboxHomestead: :
    vboxHomestead: Version '7' for 'elasticsearch' was not found
    vboxHomestead: update-rc.d: error: unable to read /etc/init.d/elasticsearch
    vboxHomestead: sed: can't read /etc/elasticsearch/elasticsearch.yml: No such file or directory
    vboxHomestead: Failed to enable unit: Unit file elasticsearch.service does not exist.
    vboxHomestead: Failed to start elasticsearch.service: Unit elasticsearch.service not found.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Homestead.yaml:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
hostname: vboxHomestead
name: vboxHomestead

backup: true

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

features:
    #- elasticsearch:
    #    version: 7
    - mysql8: true
    - webdriver: true

folders:
    - map: c:/code/acellemail
      to: /home/vagrant/Code/acellemail
      
sites:
    - map: acelle.test
      to: /home/vagrant/Code/acellemail/public
      schedule: true
          
databases:
    - homestead
    
networks:
    - type: "public_network"
      ip: "192.168.1.119"
      bridge: "Realtek RTL8811AU Wireless LAN 802.11ac USB 2.0 Network Adapter"

https://laravel.com/docs/7.x/homestead#database-snapshots and https://github.com/Lullabot/lmm don't clarify what "Import a database into the default master lmm branch." means or how to do that first step.

But this is the first thing I try in a completely fresh box:

$ vagrant ssh
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-88-generic x86_64)

Thanks for using
 _                               _                 _
| |                             | |               | |
| |__   ___  _ __ ___   ___  ___| |_ ___  __ _  __| |
| '_ \ / _ \| '_ ` _ \ / _ \/ __| __/ _ \/ _` |/ _` |
| | | | (_) | | | | | |  __/\__ \ ||  __/ (_| | (_| |
|_| |_|\___/|_| |_| |_|\___||___/\__\___|\__,_|\__,_|

* Homestead v10.3.0 released
* Settler v9.2.0 released

29 packages can be updated.
27 updates are security updates.


vagrant@vboxHomestead:~$ sudo lmm status
Active snapshot:

Database snapshots:
  master

2.68% used by MySQL databases.

Since Step 1 said "Import a database into the default master lmm branch." I figured maybe "master" is default and there is nothing for me to do. So I proceed to try to create branches but get this error:

vagrant@vboxHomestead:~$ sudo lmm branch freshVirtualBoxHomesteadInstallation2019-03-10
df: '': No such file or directory
  Logical volume name "" is invalid.
  Run `lvcreate --help' for more information.
mount: /homestead-vg/freshVirtualBoxHomesteadInstallation2019-03-10: special device /dev/homestead-vg/mysql-freshVirtualBoxHomesteadInstallation2019-03-10 does not exist.

vagrant@vboxHomestead:~$ sudo lmm branch freshB
df: '': No such file or directory
  Logical volume name "" is invalid.
  Run `lvcreate --help' for more information.
mount: /homestead-vg/freshVirtualBoxHomesteadInstallation2019-03-10: special device /dev/homestead-vg/mysql-freshVirtualBoxHomesteadInstallation2019-03-10 does not exist.
mount: /homestead-vg/freshB: special device /dev/homestead-vg/mysql-freshB does not exist.

So then by poking around at https://github.com/Lullabot/lmm/tree/master/commands I figured maybe I should:

vagrant@vboxHomestead:~$ sudo lmm checkout master
is the currently active database.
Setting /homestead-vg/master as the active database.
rm: cannot remove '/var/lib/mysql': Is a directory

So I'm very confused. Any ideas? Thanks so much!

ryancwalsh avatar Mar 10 '20 23:03 ryancwalsh

I totally missed the repo this was in, thinking it was Homestead where there's an issue template. A total aside, but in general your vagrant machines should be easy to tear down and build up, as that's the best way to get updates. We add steps in after.sh to import databases and the like on a first up.

- mysql8: true -> I wonder if that's the problem. I've tested with both the default mysql release and mariadb, but not mysql8. Running that now!

deviantintegral avatar Mar 13 '20 17:03 deviantintegral

Yes, that's the problem: https://github.com/laravel/homestead/blob/ba2f7f589c85b44af80d3e3468c1679c5c262cdf/scripts/features/mysql8.sh#L25

We symlink the existing directory into a separate lvm volume for branching; the rm call there ends up putting the data directory back on the root volume. For now, the easiest workaround if you want a newer database server is to switch to mariadb.

deviantintegral avatar Mar 13 '20 18:03 deviantintegral

Okay, thanks. I don't think I was using mysql8 for any particular reason. I see that on my production server I'm only using mysqld Ver 5.7.29-0ubuntu0.18.04.1 for Linux on x86_64 ((Ubuntu)) anyway.

I'll try removing that line in Homestead later. Thanks.

ryancwalsh avatar Mar 13 '20 19:03 ryancwalsh

I finally got my data converted from MySQL 8 to 5.7 (even though docs said this downgrade was unsupported).

lmm now seems to work:

vagrant@vboxHomestead:~/Code/myproject$ sudo lmm status
Active snapshot: /homestead-vg/master

Database snapshots:
  master

3.07% used by MySQL databases.
vagrant@vboxHomestead:~/Code/myproject$ sudo lmm branch
Usage: branch [-d] <snapshot name>
vagrant@vboxHomestead:~/Code/myproject$ sudo lmm branch afterJsonImport
  Using default stripesize 64.00 KiB.
  WARNING: Sum of all thin volume sizes (128.00 GiB) exceeds the size of thin pool homestead-vg/thinpool (64.00 GiB).
  WARNING: You have not turned on protection against thin pools running out of space.
  WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
  Logical volume "mysql-afterJsonImport" created.
vagrant@vboxHomestead:~/Code/myproject$ sudo lmm status
Active snapshot: /homestead-vg/master

Database snapshots:
  afterJsonImport
  master

3.09% used by MySQL databases.

Then because of those warnings, I ran sudo vim /etc/lvm/lvm.conf and then added thin_pool_autoextend_threshold = 70. Thanks!

ryancwalsh avatar Mar 17 '20 14:03 ryancwalsh