En instalaciones ‘frescas’ con Debian me está ocurriendo que cuando creo un proyecto de Vagrant con una Debian 8 por defecto la carpeta /vagrant no se sincroniza correctamente.
vagrant init debian/jessie64
La verdad que es un chasco estar trabajando en una instalación y de repente ver que has perdido el contenido al reiniciar la máquina vagrant por que no te aseguraste que estaba sincronizando correctamente…
Vagrant usa 4 tipos disintos para sincronizar directorios, por defecto deja al propio vagrant que decida que quiere hacer y si no es capaz de usar el driver propio de Vagrant, usa rsync. En el caso de la instalación fresca de Debian, he encontrado que el problema está en un fichero de mi proyecto
./vagrant/machines/default/virtualbox/synced_folders {"rsync":{"/vagrant":{"type":"rsync","guestpath":"/vagrant","hostpath":"/home/jorge/projects/vagrant/data","disabled":false,"owner":"vagrant","group":"vagrant"}}}
Como vemos aquí está forzando a usar rsync cuando yo no quiero, prefiero que use el propio driver de Debian. Así que directamente eliminando este fichero y reinciniando la máquina vagrant debería comenzar a sincronizar correctamente. Peeeeero no funciona, el fichero se vuelve a crear, así que tendremos que ir a la configuración principal, a ver que encontramos, vamos a ver que hay por ahí…
Si echamos un vistazo a ~/.vagrant vemos lo siguiente:
. ./data ./data/lock.dotlock.lock ./data/machine-index ./data/machine-index/index.lock ./data/machine-index/index ./data/fp-leases ./boxes ./boxes/debian-VAGRANTSLASH-jessie64 ./boxes/debian-VAGRANTSLASH-jessie64/8.4.0 ./boxes/debian-VAGRANTSLASH-jessie64/8.4.0/virtualbox ./boxes/debian-VAGRANTSLASH-jessie64/8.4.0/virtualbox/box.ovf ./boxes/debian-VAGRANTSLASH-jessie64/8.4.0/virtualbox/metadata.json ./boxes/debian-VAGRANTSLASH-jessie64/8.4.0/virtualbox/Vagrantfile ./boxes/debian-VAGRANTSLASH-jessie64/8.4.0/virtualbox/debian-jessie-disk1.vmdk ./boxes/debian-VAGRANTSLASH-jessie64/metadata_url ./tmp ./rgloader ./rgloader/loader.rb ./setup_version ./insecure_private_key ./gems ./gems/ruby ./gems/ruby/2.1.0
Y si curioseamos el fichero Vagarnt de jessie64 vemos esto :
# The contents below were provided by the Packer Vagrant post-processor Vagrant.configure("2") do |config| config.vm.base_mac = "0800271EC67E" end # The contents below (if any) are custom contents provided by the # Packer template during image build. Vagrant.configure("2") do |config| config.vm.synced_folder \ ".", "/vagrant", type: "rsync" end
Vemos aquí que hay un preset para definir el tipo de sincronización a rsync, no tengo muy claro si es una configuración por defecto o se fuenza a que la imagen se configure así , por lo que tendríamos dos caminos o bien lo cambiamos en ./vagrant/machines/default/virtualbox/synced_folders de nuestro proyecto o cambiarlo en ~/.vagrant/boxes/debian-VAGRANTSLASH-jessie64/8.4.0/virtualbox/Vagrantfile, que es lo que voy a probar, me cargo esta linea, reiniciamos
Vale ahora hay otro problema …. ( todo esto con una versión fresca de Debian )
Failed to mount folders in Linux guest. This is usually because the "vboxsf" file system is not available. Please verify that the guest additions are properly installed in the guest and can work properly. The command attempted was: mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant The error output from the last command was: stdin: is not a tty mount: unknown filesystem type 'vboxsf'
Esto parece ser que es por que me faltan las ‘guest-utils‘ así que las instalo
$ sudo apt-get install virtualbox-guest-dkms [sudo] password for jorge: Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: lockfile-progs Use 'apt-get autoremove' to remove it. The following extra packages will be installed: libnotify-bin virtualbox-guest-utils virtualbox-guest-x11 The following NEW packages will be installed: libnotify-bin virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11 0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded. Need to get 1,939 kB of archives. After this operation, 12.2 MB of additional disk space will be used. Do you want to continue? [Y/n] Get:1 http://ftp.es.debian.org/debian/ jessie/main libnotify-bin amd64 0.7.6-2 [22.7 kB] Get:2 http://ftp.es.debian.org/debian/ jessie/contrib virtualbox-guest-utils amd64 4.3.36-dfsg-1+deb8u1 [387 kB] Get:3 http://ftp.es.debian.org/debian/ jessie/contrib virtualbox-guest-dkms all 4.3.36-dfsg-1+deb8u1 [498 kB] Get:4 http://ftp.es.debian.org/debian/ jessie/contrib virtualbox-guest-x11 amd64 4.3.36-dfsg-1+deb8u1 [1,030 kB] Fetched 1,939 kB in 2s (756 kB/s) Selecting previously unselected package libnotify-bin. (Reading database ... 170777 files and directories currently installed.) Preparing to unpack .../libnotify-bin_0.7.6-2_amd64.deb ... Unpacking libnotify-bin (0.7.6-2) ... Selecting previously unselected package virtualbox-guest-utils. Preparing to unpack .../virtualbox-guest-utils_4.3.36-dfsg-1+deb8u1_amd64.deb ... Unpacking virtualbox-guest-utils (4.3.36-dfsg-1+deb8u1) ... Selecting previously unselected package virtualbox-guest-dkms. Preparing to unpack .../virtualbox-guest-dkms_4.3.36-dfsg-1+deb8u1_all.deb ... Unpacking virtualbox-guest-dkms (4.3.36-dfsg-1+deb8u1) ... Selecting previously unselected package virtualbox-guest-x11. Preparing to unpack .../virtualbox-guest-x11_4.3.36-dfsg-1+deb8u1_amd64.deb ... Unpacking virtualbox-guest-x11 (4.3.36-dfsg-1+deb8u1) ... Processing triggers for man-db (2.7.0.2-5) ... Processing triggers for systemd (215-17+deb8u4) ... Setting up libnotify-bin (0.7.6-2) ... Setting up virtualbox-guest-utils (4.3.36-dfsg-1+deb8u1) ... Setting up virtualbox-guest-dkms (4.3.36-dfsg-1+deb8u1) ... Loading new virtualbox-guest-4.3.36 DKMS files... First Installation: checking all kernels... Building only for 4.5.0 Building initial module for 4.5.0 Error! Bad return status for module build on kernel: 4.5.0 (x86_64) Consult /var/lib/dkms/virtualbox-guest/4.3.36/build/make.log for more information. Setting up virtualbox-guest-x11 (4.3.36-dfsg-1+deb8u1) ... update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults Processing triggers for systemd (215-17+deb8u4) ... Processing triggers for libc-bin (2.19-18+deb8u4) ...
Pero ahora tenemos otro problema… no compilan las guest-utils con mi kernel 4.5 … vamos a echar un vistazo
CC [M] /var/lib/dkms/virtualbox-guest/4.3.36/build/vboxsf/vfsmod.o CC [M] /var/lib/dkms/virtualbox-guest/4.3.36/build/vboxsf/dirops.o CC [M] /var/lib/dkms/virtualbox-guest/4.3.36/build/vboxsf/lnkops.o /var/lib/dkms/virtualbox-guest/4.3.36/build/vboxsf/lnkops.c: In function ‘sf_get_link’: /var/lib/dkms/virtualbox-guest/4.3.36/build/vboxsf/lnkops.c:79:5: error: implicit declaration of function ‘VbglR0SfReadLink’ [-Werror=implicit-function-declaration] rc = VbglR0SfReadLink(&client_handle, &sf_g->map, sf_i->path, PATH_MAX, path); ^ cc1: some warnings being treated as errors scripts/Makefile.build:258: recipe for target '/var/lib/dkms/virtualbox-guest/4.3.36/build/vboxsf/lnkops.o' failed make[2]: *** [/var/lib/dkms/virtualbox-guest/4.3.36/build/vboxsf/lnkops.o] Error 1 scripts/Makefile.build:407: recipe for target '/var/lib/dkms/virtualbox-guest/4.3.36/build/vboxsf' failed make[1]: *** [/var/lib/dkms/virtualbox-guest/4.3.36/build/vboxsf] Error 2 Makefile:1391: recipe for target '_module_/var/lib/dkms/virtualbox-guest/4.3.36/build' failed make: *** [_module_/var/lib/dkms/virtualbox-guest/4.3.36/build] Error 2 make: Leaving directory '/usr/src/linux-headers-4.5.0'
Googleando un poco veo que es un bug reportado y tengo dos opciones o pasar de esta forma de sincronizar carpetas o bien bajarme una versión actual y parcheada de VirtualBox … me lo voy a pensar 😀
Deja una respuesta