刷FreeBSD 论坛的时候,看到这样一招:使用pkg -r选项,往jail等虚拟机子系统里安装软件。jails - How to install a pkg offline into a jail? | The FreeBSD Forums
root@fbhost:~ # pkg
pkg: not enough arguments
Usage: pkg [-v] [-d] [-l] [-N] [-j <jail name or id>|-c <chroot path>|-r <rootdir>] [-C <configuration file>] [-R <repo config dir>] [-o var=value] [-4|-6] <command> [<args>]
For more information on available commands and options see 'pkg help'.
-r选项后面跟<rootdir> ,也就是是虚拟子系统的根目录,比如对下面的ubu这个虚拟子系统,根目录是是/usr/jails/jails/ubu
先列表看看运行的jail虚拟机子系统
root@fbhost:~ # jls
JID IP Address Hostname Path
18 10.0.0.2 fb12.my.domain /usr/jails/jails/fb12
21 10.0.0.3 ubu.my.domain /usr/jails/jails/ubu
看看ubu子系统里面有没有curl
root@fbhost:~ # jexec ubu curl csdn.net
jexec: execvp: curl: No such file or directory
看来是没有 ,本地是有的
root@fbhost:~ # curl
curl: try 'curl --help' or 'curl --manual' for more information
在jail子系统里安装curl
root@fbhost:~ # pkg -r /usr/jails/jails/ubu install curl
Updating FreeBSD repository catalogue...
pkg: No SRV record found for the repo 'FreeBSD'
Fetching meta.conf: 0%
FreeBSD repository is up to date.
All repositories are up to date.
The following 4 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
curl: 8.7.1
libnghttp2: 1.61.0
libpsl: 0.21.5
libssh2: 1.11.0_1,3
Number of packages to be installed: 4
The process will require 6 MiB more space.
2 MiB to be downloaded.
Proceed with this action? [y/N]: y
[1/4] Fetching libnghttp2-1.61.0.pkg: 100% 144 KiB 147.0kB/s 00:01
[2/4] Fetching libssh2-1.11.0_1,3.pkg: 100% 281 KiB 287.9kB/s 00:01
[3/4] Fetching libpsl-0.21.5.pkg: 100% 64 KiB 65.6kB/s 00:01
[4/4] Fetching curl-8.7.1.pkg: 100% 1 MiB 1.6MB/s 00:01
Checking integrity... done (0 conflicting)
[1/4] Installing libnghttp2-1.61.0...
[1/4] Extracting libnghttp2-1.61.0: 100%
[2/4] Installing libssh2-1.11.0_1,3...
[2/4] Extracting libssh2-1.11.0_1,3: 100%
[3/4] Installing libpsl-0.21.5...
[3/4] Extracting libpsl-0.21.5: 100%
[4/4] Installing curl-8.7.1...
[4/4] Extracting curl-8.7.1: 100%
现在再来看看jail里面是否装好了
root@fbhost:~ # jexec ubu curl csdn.net
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>
果然,ubu这个虚拟子系统里的curl已经装好了,pkg -r真的非常方便。因为Jail虚拟容器和PKG软件包管理系统都是FreeBSD的原生应用,所以它们之间配合非常默契,不用到jail子系统里,直接在host主机也能使用pkg向jail子系统安装各种软件。
标签:ubu,jails,100%,jail,pkg,FreeBSD,curl,子系统 From: https://blog.csdn.net/skywalk8163/article/details/139759427