debian12.9或ubuntu,vagrant离线安装插件vagrant-libvirt,20250601
系统盘:
https://mirror.lzu.edu.cn/debian-cd/12.9.0/amd64/iso-dvd/debian-12.9.0-amd64-DVD-1.iso
需要的依赖包,无需安装ruby( sudo apt install -y ruby-full ruby-dev rubygems,后来发现不安装会有编译警告,还是安装吧 ) ,无需安装 zlib1g-dev liblzma-dev libxml2-dev libxslt-dev ,curl也不需要安装:
apt install -y iptables; apt install --print-uris -y libvirt-daemon-system libvirt-clients qemu-kvm libvirt-dev virtinst | tee ~/bbb.log;
grep -oE "'https?://[^ ]+" /root/bbb.log > /download_urls_filtered_virt.txt
cd /tmp&&(
cat /download_urls_filtered_virt.txt | xargs -I {} sh -c 'wget -4 --no-check-certificate {} && echo 0.1'
)dpkg -i *.deb;wget https://releases.hashicorp.com/vagrant/2.4.5/vagrant_2.4.5-1_amd64.deb&&dpkg -i vagrant_2.4.5-1_amd64.deb;apt install --print-uris -y build-essential | tee ~/bbb2.log;
grep -oE "'https?://[^ ]+" /root/bbb2.log > /download_urls_filtered_build-essential.txt
cd /tmp&&(
ls -la;
cat /download_urls_filtered_build-essential.txt | xargs -I {} sh -c 'wget -4 --no-check-certificate {} && echo 0.1'
)dpkg -i *.deb;
root@debian129:/mnt# dpkg -l build-essential patch zlib1g-dev liblzma-dev libxml2-dev libxslt-dev iptables curl gcc make ruby ruby-dev ruby-libvirt libvirt-daemon-system libvirt-clients qemu-kvm libvirt-dev virtinst vagrant clang qemu
dpkg-query: no packages found matching zlib1g-dev
dpkg-query: no packages found matching liblzma-dev
dpkg-query: no packages found matching libxml2-dev
dpkg-query: no packages found matching libxslt-dev
dpkg-query: no packages found matching clang
dpkg-query: no packages found matching qemu
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=====================-===============-============-=========================================================================
ii build-essential 12.9 amd64 Informational list of build-essential packages
un curl <none> <none> (no description available)
ii gcc 4:12.2.0-3 amd64 GNU C compiler
ii iptables 1.8.9-2 amd64 administration tools for packet filtering and NAT
ii libvirt-clients 9.0.0-4+deb12u2 amd64 Programs for the libvirt library
ii libvirt-daemon-system 9.0.0-4+deb12u2 amd64 Libvirt daemon configuration files
ii libvirt-dev:amd64 9.0.0-4+deb12u2 amd64 development files for the libvirt library
ii make 4.3-4.1 amd64 utility for directing compilation
ii patch 2.7.6-7 amd64 Apply a diff file to an original
un qemu-kvm <none> <none> (no description available)
ii ruby 1:3.1 amd64 Interpreter of object-oriented scripting language Ruby (default version)
un ruby-dev <none> <none> (no description available)
ii ruby-libvirt 0.7.1-1.1+b3 amd64 Ruby bindings for libvirt
ii vagrant 2.4.5-1 amd64 Vagrant is a tool for building and distributing development environments.
ii virtinst 1:4.1.0-2 all utilities to create and edit virtual machines
root@debian129:/mnt#
root@xx:~# curl -4kLO https://rubygems.org/gems/vagrant-libvirt-0.12.2.gem% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed
100 133k 100 133k 0 0 1861k 0 --:--:-- --:--:-- --:--:-- 1873k
root@xx:~# ls -al *.gem
-rw-r--r-- 1 root root 136192 Jun 1 14:48 vagrant-libvirt-0.12.2.gem
root@xx:~# md5sum vagrant-libvirt-0.12.2.gem
62114243fcced1be21349735aaa0c791 vagrant-libvirt-0.12.2.gem
root@xx:~#
mkdir -p /root/ppp;
cd /root/ppp;export PATH="/opt/vagrant/embedded/bin:$PATH" ;
export http_proxy="http://192.168.111.1:12334" ;
export https_proxy=$http_proxy ;
gem fetch --verbose vagrant-libvirt;root@debian129:~/ppp# gem fetch --verbose vagrant-libvirt
Fetching vagrant-libvirt-0.12.2.gem
Downloaded vagrant-libvirt-0.12.2
root@debian129:~/ppp# ls -al
total 152
drwxr-xr-x 2 root root 4096 Jun 1 22:56 .
drwx------ 16 root root 12288 Jun 1 22:55 ..
-rw-r--r-- 1 root root 136192 Jun 1 22:56 vagrant-libvirt-0.12.2.gem
root@debian129:~/ppp# gem install --verbose ./vagrant-libvirt-0.12.2.gem 2>&1 | tee -a ~/vvruby.log ;
#联网下载,国内需要走http代理grep -oE "https?://[^ ]+" /root/vvruby.log | grep -E "\.gem" | grep -v -E "\.rz" | awk '{printf "%02d-%s\n", NR, $0}' > /root/urls_with_numbers.txtroot@debian129:~/ppp# cat ~/urls_with_numbers.txt
01-https://index.rubygems.org/gems/nokogiri-1.18.8-x86_64-linux-gnu.gem
02-https://index.rubygems.org/gems/diffy-3.4.3.gem
03-https://index.rubygems.org/gems/xml-simple-1.1.9.gem
04-https://index.rubygems.org/gems/mime-types-data-3.2025.0527.gem
05-https://index.rubygems.org/gems/mime-types-3.7.0.gem
06-https://index.rubygems.org/gems/formatador-1.1.0.gem
07-https://index.rubygems.org/gems/excon-1.2.7.gem
08-https://index.rubygems.org/gems/builder-3.3.0.gem
09-https://index.rubygems.org/gems/fog-core-2.6.0.gem
10-https://index.rubygems.org/gems/ruby-libvirt-0.8.4.gem
11-https://index.rubygems.org/gems/fog-xml-0.1.5.gem
12-https://index.rubygems.org/gems/multi_json-1.15.0.gem
13-https://index.rubygems.org/gems/fog-json-1.2.0.gem
14-https://index.rubygems.org/gems/fog-libvirt-0.13.2.gem
root@debian129:~/ppp# while IFS= read -r line; donumber=$(echo "$line" | cut -d'-' -f1)url=$(echo "$line" | cut -d'-' -f2-)filename="$number-$(basename "$url")"wget -O "/root/ppp/$filename" "$url"
done < /root/urls_with_numbers.txtcd /opt/vagrant/embedded/lib/ruby/gems/3.3.0/cache/;ls -al ;
cp ./racc-1.7.3.gem /root/ppp/ ;ls -al -ltr --time-style=full-iso /opt/vagrant/embedded/gems/cache/;cd /root/ppp;
gem list | grep libvirt;
gem generate_index --verbose ;root@debian129:~/ppp# gem list | grep libvirt;
fog-libvirt (0.13.2)
ruby-libvirt (0.8.4)
vagrant-libvirt (0.12.2)
root@debian129:~/ppp# root@debian129:~/ppp# gem generate_index --verbose ;
Fetching rubygems-generate_index-1.1.3.gem
Fetching compact_index-0.15.0.gem
Generating Marshal quick index gemspecs for 0 gems
Complete
Generated Marshal quick index gemspecs: 0.000s
Generating specs index
Generated specs index: 0.000s
Generating latest specs index
Generated latest specs index: 0.000s
Generating prerelease specs index
Generated prerelease specs index: 0.000s
Generating compact index files for 0 gems
1/2: /names
2/2: /versions
Complete
Generated compact index files: 0.000s
Compressing indices
Compressed indices: 0.000s
Moving index into production dir .
mkdir -p ./quick
rm -rf ./quick/Marshal.4.8
mv -f /tmp/gem_generate_index20250601-1555-6y67ma/quick/Marshal.4.8 ./quick/Marshal.4.8
rm -rf ./specs.4.8
mv -f /tmp/gem_generate_index20250601-1555-6y67ma/specs.4.8 .
rm -rf ./specs.4.8.gz
mv -f /tmp/gem_generate_index20250601-1555-6y67ma/specs.4.8.gz .
rm -rf ./latest_specs.4.8
mv -f /tmp/gem_generate_index20250601-1555-6y67ma/latest_specs.4.8 .
rm -rf ./latest_specs.4.8.gz
mv -f /tmp/gem_generate_index20250601-1555-6y67ma/latest_specs.4.8.gz .
rm -rf ./prerelease_specs.4.8
mv -f /tmp/gem_generate_index20250601-1555-6y67ma/prerelease_specs.4.8 .
rm -rf ./prerelease_specs.4.8.gz
mv -f /tmp/gem_generate_index20250601-1555-6y67ma/prerelease_specs.4.8.gz .
rm -rf ./info
mv -f /tmp/gem_generate_index20250601-1555-6y67ma/info .
rm -rf ./names
mv -f /tmp/gem_generate_index20250601-1555-6y67ma/names .
rm -rf ./versions
mv -f /tmp/gem_generate_index20250601-1555-6y67ma/versions .
root@debian129:~/ppp# tar -czf /root/gem.tar.gz .root@debian129:~# tar -tvf /root/gem.tar.gz
drwxr-xr-x root/root 0 2025-06-01 21:10 ./
drwxr-xr-x root/root 0 2025-06-01 21:10 ./info/
-rw-r--r-- root/root 102912 2025-06-01 20:49 ./10-ruby-libvirt-0.8.4.gem
-rw-r--r-- root/root 12288 2025-06-01 20:49 ./05-xml-simple-1.1.9.gem
-rw-r--r-- root/root 168960 2025-06-01 20:49 ./01-mime-types-data-3.2025.0527.gem
-rw-r--r-- root/root 24 2025-06-01 21:10 ./prerelease_specs.4.8.gz
-rw-r--r-- root/root 171008 2025-06-01 20:49 ./07-excon-1.2.7.gem
-rw-r--r-- root/root 17920 2025-06-01 20:49 ./04-diffy-3.4.3.gem
-rw-r--r-- root/root 13824 2025-06-01 20:49 ./06-formatador-1.1.0.gem
-rw-r--r-- root/root 5 2025-06-01 21:10 ./names
-rw-r--r-- root/root 24 2025-06-01 21:10 ./latest_specs.4.8.gz
-rw-r--r-- root/root 11264 2025-06-01 20:49 ./11-fog-xml-0.1.5.gem
-rw-r--r-- root/root 4 2025-06-01 21:10 ./prerelease_specs.4.8
-rw-r--r-- root/root 42 2025-06-01 21:10 ./versions
-rw-r--r-- root/root 4 2025-06-01 21:10 ./specs.4.8
-rw-r--r-- root/root 31744 2025-06-01 20:49 ./14-fog-libvirt-0.13.2.gem
-rw-r--r-- root/root 8704 2025-06-01 20:49 ./13-fog-json-1.2.0.gem
-rw-r--r-- root/root 24 2025-06-01 21:10 ./specs.4.8.gz
-rw-r--r-- root/root 30208 2025-06-01 20:49 ./08-builder-3.3.0.gem
-rw-r--r-- root/root 22016 2025-06-01 20:49 ./12-multi_json-1.15.0.gem
-rw-r--r-- root/root 41984 2025-06-01 20:49 ./02-mime-types-3.7.0.gem
-rw-r--r-- root/root 4073472 2025-06-01 20:49 ./03-nokogiri-1.18.8-x86_64-linux-gnu.gem
-rw-r--r-- root/root 64000 2025-06-01 21:10 ./racc-1.7.3.gem
drwxr-xr-x root/root 0 2025-06-01 21:10 ./quick/
drwxr-xr-x root/root 0 2025-06-01 21:10 ./quick/Marshal.4.8/
-rw-r--r-- root/root 47104 2025-06-01 20:49 ./09-fog-core-2.6.0.gem
-rw-r--r-- root/root 4 2025-06-01 21:10 ./latest_specs.4.8
-rw-r--r-- root/root 136192 2025-06-01 20:49 ./vagrant-libvirt-0.12.2.gem
-rw-r--r-- root/root 136192 2025-06-01 20:49 ./15-vagrant-libvirt-0.12.2.gem
root@debian129:~#
root@debian129:~# ls -al -ltr --time-style=full-iso /opt/vagrant/embedded/lib/ruby/gems/3.3.0/cache
total 6768
-rw-r--r-- 1 root root 75264 2025-04-09 17:23:04.000000000 +0800 typeprof-0.21.9.gem
-rw-r--r-- 1 root root 94208 2025-04-09 17:23:04.000000000 +0800 test-unit-3.6.1.gem
-rw-r--r-- 1 root root 53248 2025-04-09 17:23:04.000000000 +0800 rss-0.3.1.gem
-rw-r--r-- 1 root root 104448 2025-04-09 17:23:04.000000000 +0800 rexml-3.3.9.gem
-rw-r--r-- 1 root root 1043968 2025-04-09 17:23:04.000000000 +0800 rbs-3.4.0.gem
-rw-r--r-- 1 root root 84992 2025-04-09 17:23:04.000000000 +0800 rake-13.1.0.gem
-rw-r--r-- 1 root root 64000 2025-04-09 17:23:04.000000000 +0800 racc-1.7.3.gem
-rw-r--r-- 1 root root 11264 2025-04-09 17:23:04.000000000 +0800 prime-0.1.2.gem
-rw-r--r-- 1 root root 15360 2025-04-09 17:23:04.000000000 +0800 power_assert-2.0.3.gem
-rw-r--r-- 1 root root 17408 2025-04-09 17:23:04.000000000 +0800 net-smtp-0.5.1.gem
-rw-r--r-- 1 root root 14336 2025-04-09 17:23:04.000000000 +0800 net-pop-0.1.2.gem
-rw-r--r-- 1 root root 155136 2025-04-09 17:23:04.000000000 +0800 net-imap-0.4.19.gem
-rw-r--r-- 1 root root 17920 2025-04-09 17:23:04.000000000 +0800 net-ftp-0.3.4.gem
-rw-r--r-- 1 root root 95744 2025-04-09 17:23:04.000000000 +0800 minitest-5.20.0.gem
-rw-r--r-- 1 root root 27136 2025-04-09 17:23:04.000000000 +0800 matrix-0.4.2.gem
-rw-r--r-- 1 root root 99328 2025-04-09 17:23:04.000000000 +0800 debug-1.9.2.gem
drwxr-xr-x 9 root root 4096 2025-05-31 23:16:31.900803083 +0800 ..
-rw-r--r-- 1 root root 168960 2025-05-31 23:24:33.768609905 +0800 mime-types-data-3.2025.0527.gem
-rw-r--r-- 1 root root 41984 2025-05-31 23:24:34.820743161 +0800 mime-types-3.7.0.gem
-rw-r--r-- 1 root root 4073472 2025-05-31 23:24:37.865130974 +0800 nokogiri-1.18.8-x86_64-linux-gnu.gem
-rw-r--r-- 1 root root 17920 2025-05-31 23:24:38.381197052 +0800 diffy-3.4.3.gem
-rw-r--r-- 1 root root 12288 2025-05-31 23:24:38.957270868 +0800 xml-simple-1.1.9.gem
-rw-r--r-- 1 root root 13824 2025-05-31 23:24:39.417329960 +0800 formatador-1.1.0.gem
-rw-r--r-- 1 root root 171008 2025-05-31 23:24:40.273440033 +0800 excon-1.2.7.gem
-rw-r--r-- 1 root root 30208 2025-05-31 23:24:41.101546728 +0800 builder-3.3.0.gem
-rw-r--r-- 1 root root 47104 2025-05-31 23:24:43.941914419 +0800 fog-core-2.6.0.gem
-rw-r--r-- 1 root root 102912 2025-05-31 23:24:44.585998178 +0800 ruby-libvirt-0.8.4.gem
-rw-r--r-- 1 root root 11264 2025-05-31 23:24:44.826029400 +0800 fog-xml-0.1.5.gem
-rw-r--r-- 1 root root 22016 2025-05-31 23:24:45.406104976 +0800 multi_json-1.15.0.gem
-rw-r--r-- 1 root root 8704 2025-05-31 23:24:45.630134186 +0800 fog-json-1.2.0.gem
-rw-r--r-- 1 root root 31744 2025-05-31 23:24:45.950175913 +0800 fog-libvirt-0.13.2.gem
-rw-r--r-- 1 root root 136192 2025-05-31 23:24:52.223000364 +0800 vagrant-libvirt-0.12.2.gem
drwxr-xr-x 2 root root 4096 2025-05-31 23:24:52.223000364 +0800 .
root@debian129:~#
tar -xf /root/gem.tar.gz -C /mnt/;
cd /mnt ; # 这一步必须的CHECKPOINT_DISABLE=1 vagrant plugin install --debug vagrant-libvirt --plugin-clean-sources --plugin-source file:///mnt/CHECKPOINT_DISABLE=1 vagrant plugin list --debug
root@debian129:~# cat ~/.vagrant.d/plugins.json
{"version":"1","installed":{"vagrant-libvirt":{"ruby_version":"3.3.8","vagrant_version":"2.4.5","gem_version":"","require":"","sources":["file:///root/"],"installed_gem_version":"0.12.2","env_local":false}}}root@debian129:~#
root@debian129:~# sudo systemctl status libvirtd
* libvirtd.service - Virtualization daemonLoaded: loaded (/lib/systemd/system/libvirtd.service; enabled; preset: enabled)Active: inactive (dead) since Sun 2025-06-01 21:22:13 CST; 1h 3min agoDuration: 2min 104ms
TriggeredBy: * libvirtd-ro.socket* libvirtd-admin.socket* libvirtd.socketDocs: man:libvirtd(8)https://libvirt.orgMain PID: 2570 (code=exited, status=0/SUCCESS)CPU: 182msJun 01 21:20:13 debian129 systemd[1]: Starting libvirtd.service - Virtualization daemon...
Jun 01 21:20:13 debian129 systemd[1]: Started libvirtd.service - Virtualization daemon.
Jun 01 21:20:13 debian129 libvirtd[2570]: libvirt version: 9.0.0, package: 9.0.0-4+deb12u2 (Debian)
Jun 01 21:20:13 debian129 libvirtd[2570]: hostname: debian129
Jun 01 21:20:13 debian129 libvirtd[2570]: <E6><97><A0><E6><B3><95><E6><89><93><E5><BC><80> tty /dev/kvm: <E6><B2><A1><E6><9C><89><E9><82><A3><E4><B8><AA><E6><96><87><E4><BB><B6><E6><88><96><E7><E5><BD><95>
Jun 01 21:22:13 debian129 systemd[1]: libvirtd.service: Deactivated successfully.
root@debian129:~#
vagrant plugin install --debug vagrant-libvirt ;报错如下:
Building native extensions. This could take a while...
Building native extensions. This could take a while...cc1: note: unrecognized command-line option '-Wno-self-assign' may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option '-Wno-parentheses-equality' may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option '-Wno-constant-logical-operand' may have been intended to silence earlier diagnostics
原因,需要安装: apt install -y ruby-libvirt ;
ruby-libvirt依赖于ruby包,所以还是要安装ruby
The following additional packages will be installed:libruby libruby3.1 libyaml-0-2 rake ruby ruby-net-telnet ruby-rubygems ruby-sdbm ruby-webrick ruby-xmlrpc ruby3.1 rubygems-integration zip
Suggested packages:ri ruby-dev bundler
The following NEW packages will be installed:libruby libruby3.1 libyaml-0-2 rake ruby ruby-libvirt ruby-net-telnet ruby-rubygems ruby-sdbm ruby-webrick ruby-xmlrpc ruby3.1 rubygems-integration zip
0 upgraded, 14 newly installed, 0 to remove and 121 not upgraded.
Need to get 6916 kB of archives.
After this operation, 29.4 MB of additional disk space will be used.
root@debian129:~# dpkg -l ruby-dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
un ruby-dev <none> <none> (no description available)
root@debian129:~# dpkg -L ruby-dev
dpkg-query: package 'ruby-dev' is not installed
Use dpkg --contents (= dpkg-deb --contents) to list archive files contents.
root@debian129:~#
系统安装的gcc版本如下:
root@debian129:~# update-alternatives --display gcc
update-alternatives: error: no alternatives for gcc
root@debian129:~# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 12.2.0-14+deb12u1' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/reproducible-path/gcc-12-12.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/reproducible-path/gcc-12-12.2.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Debian 12.2.0-14+deb12u1)
root@debian129:~#