DAHDi卡无法虚拟化的曲线解决方案:LXC容器化
将Openvox D210语音卡装入ESXi主机直通给freepbx虚拟机后会不定时掉线,排查下来应该是虚拟机中断的问题,找遍全网也没有解决方案,只好曲线救国,将语音卡通过设备映射的方式映射给LXC容器内的freepbx。
主机安装debian 12系统
安装DKMS及驱动
apt install dahdi-firmware-nonfree dkms dahdi dahdi-dkms dahdi-linux
查看E1卡是否识别
lspci -vk
已安装驱动:
08:00.0 PCI bridge: PLX Technology, Inc. PEX8112 x1 Lane PCI Express-to-PCI Bridge (rev aa) (prog-if 00 [Normal decode])
Physical Slot: 1
Flags: bus master, fast devsel, latency 0, IRQ 128, NUMA node 0, IOMMU group 33
Bus: primary=08, secondary=09, subordinate=09, sec-latency=64
I/O behind bridge: [disabled]
Memory behind bridge: fbf00000-fbffffff [size=1M]
Prefetchable memory behind bridge: [disabled]
Capabilities: [40] Power Management version 2
Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [60] Express PCI-Express to PCI/PCI-X Bridge, MSI 00
Capabilities: [100] Power Budgeting <?>
09:00.0 Network controller: Digium, Inc. Device 1210 (rev 15)
Subsystem: Device 0005:0000
Flags: bus master, slow devsel, latency 64, IRQ 128, NUMA node 0, IOMMU group 33
Memory at fbff0000 (32-bit, non-prefetchable) [size=32K]
Kernel driver in use: wct4xxp
Kernel modules: wct4xxp
DAHDI驱动及固件
dahdi-dkms/stable,now 1:2.11.1.0.20170917~dfsg-7.4 all [installed,automatic]
dahdi-firmware-nonfree/stable,now 2.11.1.0.20170917-1 all [installed]
dahdi-linux/stable,now 1:2.11.1.0.20170917~dfsg-7.4 all [installed,automatic]
dahdi/stable,now 1:3.1.0-2 amd64 [installed]
dkms
注册dahdi服务
nano /etc/init.d/dahdi
#!/bin/sh
#
# dahdi This shell script takes care of loading and unloading \
# DAHDI Telephony interfaces
# chkconfig: 2345 9 92
# description: The DAHDI drivers allow you to use your linux \
# computer to accept incoming data and voice interfaces
#
# config: /etc/dahdi/init.conf
### BEGIN INIT INFO
# Provides: dahdi
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network $syslog
# Should-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: DAHDI kernel modules
# Description: dahdi - load and configure DAHDI modules
### END INIT INFO
initdir=/etc/init.d
# Don't edit the following values. Edit /etc/dahdi/init.conf instead.
DAHDI_CFG=/usr/sbin/dahdi_cfg
DAHDI_CFG_CMD=${DAHDI_CFG_CMD:-"$DAHDI_CFG"} # e.g: for a custom system.conf location
FXOTUNE=/usr/sbin/fxotune
# The default syncer Astribank. Usually set automatically to a sane
# value by xpp_sync(1) if you have an Astribank. You can set this to an
# explicit Astribank (e.g: 01).
XPP_SYNC=auto
# The maximal timeout (seconds) to wait for udevd to finish generating
# device nodes after the modules have loaded and before running dahdi_cfg.
DAHDI_DEV_TIMEOUT=20
# A list of modules to unload when stopping.
# All of their dependencies will be unloaded as well.
DAHDI_UNLOAD_MODULES="dahdi echo"
#
# Determine which kind of configuration we're using
#
system=redhat # assume redhat
if [ -f /etc/debian_version ]; then
system=debian
fi
if [ -f /etc/gentoo-release ]; then
system=debian
fi
if [ -f /etc/SuSE-release -o -f /etc/novell-release ]
then
system=debian
fi
# Source function library.
if [ $system = redhat ]; then
. $initdir/functions || exit 0
fi
DAHDI_MODULES_FILE="/etc/dahdi/modules"
[ -r /etc/dahdi/init.conf ] && . /etc/dahdi/init.conf
if [ $system = redhat ]; then
LOCKFILE=/var/lock/subsys/dahdi
fi
# recursively unload a module and its dependencies, if possible.
# where's modprobe -r when you need it?
# inputs: module to unload.
# returns: the result from
unload_module() {
module="$1"
line=`lsmod 2>/dev/null | grep "^$1 "`
if [ "$line" = '' ]; then return; fi # module was not loaded
set -- $line
# $1: the original module, $2: size, $3: refcount, $4: deps list
mods=`echo $4 | tr , ' '`
ec_modules=""
# xpp_usb keeps the xpds below busy if an xpp hardware is
# connected. Hence must be removed before them:
case "$module" in xpd_*) mods="xpp_usb $mods";; esac
for mod in $mods; do
case "$mod" in
dahdi_echocan_*)
ec_modules="$mod $ec_modules"
;;
*)
# run in a subshell, so it won't step over our vars:
(unload_module $mod)
;;
esac
done
# Now that all the other dependencies are unloaded, we can unload the
# dahdi_echocan modules. The drivers that register spans may keep
# references on the echocan modules before they are unloaded.
for mod in $ec_modules; do
(unload_module $mod)
done
rmmod $module
}
unload_modules() {
for module in $DAHDI_UNLOAD_MODULES; do
unload_module $module
done
}
# In (xpp) hotplug mode, the init script is also executed from the
# hotplug hook. In that case it should not attempt to loade modules.
#
# This function only retunrs false (1) if we're in hotplug mode and
# coming from the hotplug hook script.
hotplug_should_load_modules() {
if [ "$XPP_HOTPLUG_DAHDI" = yes -a "$CALLED_FROM_ATRIBANK_HOOK" != '' ]
then
return 1
fi
return 0
}
# In (xpp) hotplug mode: quit after we loaded modules.
#
# In hotplug mode, the main run should end here, whereas the rest of the
# script should be finished by the instance running from the hook.
# Note that we only get here if there are actually Astribanks on the
# system (otherwise noone will trigger the run of the hotplug hook
# script).
hotplug_exit_after_load() {
if [ "$XPP_HOTPLUG_DAHDI" = yes -a "$CALLED_FROM_ATRIBANK_HOOK" = '' ]
then
exit 0
fi
}
# Initialize the Xorcom Astribank (xpp/) using perl utiliites:
xpp_startup() {
if [ "$ASTERISK_SUPPORTS_DAHDI_HOTPLUG" = yes ]; then
aas_param='/sys/module/dahdi/parameters/auto_assign_spans'
aas=`cat "$aas_param" 2>/dev/null`
if [ "$aas" = 0 ]; then
echo 1>&2 "Don't wait for Astribanks (use Asterisk hotplug-support)"
return 0
fi
fi
# do nothing if there are no astribank devices:
if ! /usr/share/dahdi/waitfor_xpds; then return 0; fi
hotplug_exit_after_load
}
hpec_start() {
# HPEC license found
if ! echo /var/lib/digium/licenses/HPEC-*.lic | grep -v '\*' | grep -q .; then
return
fi
# dahdihpec_enable not installed in /usr/sbin
if [ ! -f /usr/sbin/dahdihpec_enable ]; then
echo -n "Running dahdihpec_enable: Failed"
echo -n "."
echo " The dahdihpec_enable binary is not installed in /usr/sbin."
return
fi
# dahdihpec_enable not set executable
if [ ! -x /usr/sbin/dahdihpec_enable ]; then
echo -n "Running dahdihpec_enable: Failed"
echo -n "."
echo " /usr/sbin/dahdihpec_enable is not set as executable."
return
fi
# dahdihpec_enable properly installed
if [ $system = debian ]; then
echo -n "Running dahdihpec_enable: "
/usr/sbin/dahdihpec_enable 2> /dev/null
elif [ $system = redhat ]; then
action "Running dahdihpec_enable: " /usr/sbin/dahdihpec_enable
fi
if [ $? = 0 ]; then
echo -n "done"
echo "."
else
echo -n "Failed"
echo -n "."
echo " This can be caused if you had already run dahdihpec_enable, or if your HPEC license is no longer valid."
fi
}
shutdown_dynamic() {
if ! grep -q ' DYN/' /proc/dahdi/* 2>/dev/null; then return; fi
# we should only get here if we have dynamic spans. Right?
$DAHDI_CFG_CMD -s
}
load_modules() {
# Some systems, e.g. Debian Lenny, add here -b, which will break
# loading of modules blacklisted in modprobe.d/*
unset MODPROBE_OPTIONS
modules=`sed -e 's/#.*$//' $DAHDI_MODULES_FILE 2>/dev/null`
#if [ "$modules" = '' ]; then
# what?
#fi
echo "Loading DAHDI hardware modules:"
modprobe dahdi
for line in $modules; do
if [ $system = debian ]; then
echo -n " ${line}: "
if modprobe $line 2> /dev/null; then
echo -n "done"
else
echo -n "error"
fi
elif [ $system = redhat ]; then
action " ${line}: " modprobe $line
fi
done
echo ""
}
# Make sure that either dahdi is loaded or modprobe-able
dahdi_modules_loadable() {
modinfo dahdi >/dev/null 2>&1 || lsmod | grep -q -w ^dahdi
}
if [ ! -x "$DAHDI_CFG" ]; then
echo "dahdi_cfg not executable"
exit 0
fi
RETVAL=0
# See how we were called.
case "$1" in
start)
if ! dahdi_modules_loadable; then
echo "No DAHDI modules on the system. Not starting"
exit 0
fi
if hotplug_should_load_modules; then
load_modules
fi
TMOUT=$DAHDI_DEV_TIMEOUT # max secs to wait
while [ ! -d /dev/dahdi ] ; do
sleep 1
TMOUT=`expr $TMOUT - 1`
if [ $TMOUT -eq 0 ] ; then
echo "Error: missing /dev/dahdi!"
exit 1
fi
done
xpp_startup
# Assign all spans that weren't handled via udev + /etc/dahdi/assigned-spans.conf
/usr/share/dahdi/dahdi_auto_assign_compat
if [ $system = debian ]; then
echo -n "Running dahdi_cfg: "
$DAHDI_CFG_CMD 2> /dev/null && echo -n "done"
echo "."
elif [ $system = redhat ]; then
action "Running dahdi_cfg: " $DAHDI_CFG_CMD
fi
RETVAL=$?
if [ "$LOCKFILE" != '' ]; then
[ $RETVAL -eq 0 ] && touch $LOCKFILE
fi
if [ -x "$FXOTUNE" ] && [ -r /etc/fxotune.conf ]; then
# Allowed to fail if e.g. Asterisk already uses channels:
$FXOTUNE -s || :
fi
# Do not try to call xpp_sync if there are no Astribank devices
# installed.
if test -e /sys/bus/astribanks; then
# Set the right Astribanks ticker:
LC_ALL=C xpp_sync "$XPP_SYNC"
fi
hpec_start
;;
stop)
# Unload drivers
#shutdown_dynamic # FIXME: needs test from someone with dynamic spans
echo -n "Unloading DAHDI hardware modules: "
if unload_modules; then
echo "done"
else
echo "error"
fi
if [ "$LOCKFILE" != '' ]; then
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
fi
;;
unload)
unload_modules
;;
restart|force-reload)
$0 stop
$0 start
;;
reload)
if [ $system = debian ]; then
echo -n "Rerunning dahdi_cfg: "
$DAHDI_CFG_CMD 2> /dev/null && echo -n "done"
echo "."
elif [ $system = redhat ]; then
action "Rerunning dahdi_cfg: " $DAHDI_CFG_CMD
fi
RETVAL=$?
;;
status)
if [ -d /proc/dahdi ]; then
/usr/sbin/lsdahdi
RETVAL=0
else
RETVAL=3
fi
;;
*)
echo "Usage: dahdi {start|stop|restart|status|reload|unload}"
exit 1
esac
exit $RETVAL
chmod 755 /etc/init.d/dahdi
ln -s /etc/init.d/dahdi /etc/rc2.d/dahdi
nano /etc/dahdi/system.conf
span=1,0,0,CCS,HDB3
span=2,0,0,CCS,HDB3
bchan=1-15,17-31,32-46,48-62
dchan=16,47
loadzone=cn
defaultzone=cn
echocanceller=oslec,1-15,17-31,32-46,48-62
nano /etc/dahdi/assigned-spans.conf
#
# Autogenerated by /usr/sbin/dahdi_span_assignments on Thu 11 May 2023 10:30:07 AM CST
# Map devices + local spans to span + base channel number
# Device: [] @Board_ID_Switch_0 /sys/devices/pci0000:00/0000:00:03.0/0000:08:00.0/0000:09:00.0/pci:0000:09:00.0
/sys/devices/pci0000:00/0000:00:03.0/0000:08:00.0/0000:09:00.0/pci:0000:09:00.0 1:1:1
/sys/devices/pci0000:00/0000:00:03.0/0000:08:00.0/0000:09:00.0/pci:0000:09:00.0 2:2:32
nano /etc/dahdi/modules
# -------------------------------------------------------------------------------;
# Do NOT edit this file as it is auto-generated by FreePBX. All modifications to ;
# this file must be done via the web gui. There are alternative files to make ;
# custom modifications. ;
# -------------------------------------------------------------------------------;
#
# Digium TE220: PCI-Express dual-port T1/E1/J1
# Digium TE420: PCI-Express quad-port T1/E1/J1
wct4xxp
# Digium TE436
# Digium TE236
wcte43x
# OpenVox D115E/DE115E/D130E/DE130E: PCI-Express Single-port T1/E1/J1
opvxd115
# Digium TE121: PCI-Express single-port T1/E1/J1
# Digium TE122: PCI single-port T1/E1/J1
wcte12xp
# Digium TE133: PCI-Express single-port T1/E1/J1 with hardware echocan
# Digium TE134: PCI single-port T1/E1/J1 with hardware echocan
wcte13xp
# Digium T100P: PCI single-port T1
# Digium E100P: PCI single-port E1
wct1xxp
# Digium TE110P: PCI single-port T1/E1/J1
wcte11xp
# Allo 1,2 and 4 port T1/E1/J1
#tor3e
# Rhino Single Span T1/E1/J1
r1t1
# Rhino Multi Span T1/E1/J1
rxt1
# Digium TDM800P/AEX800: up to 8 analog ports
# Digium TDM410P/AEX410: up to 4 analog ports
wctdm24xxp
# Digium A4A/A4B/A8A/A8B
wcaxx
# X100P - Single port FXO interface
# X101P - Single port FXO interface
wcfxo
# Digium TDM400P: up to 4 analog ports
wctdm
# OpenVox A2410P: up to 24 analog ports
opvxa24xx
# OpenVox A2410P: up to 12 analog ports
opvxa1200
# Rhino FXO
rcbfx
# OpenVox B100P: 1 NT/TE BRI ports
zaphfc
# Digium B233P: 2 NT/TE BRI ports pci-e
# Digium B234P: 2 NT/TE BRI ports
wcb4xxp
# Digium TC400B: G729 / G723 Transcoding Engine
wctc4xxp
# Xorcom Astribank Devices
xpp_usb
配置dadhi
touch /etc/dahdi/genconf_parameters
dahdi_span_assignments auto
dahdi_genconf
此报错不影响/usr/sbin/dahdi_genconf: Failed to open /etc/asterisk/dahdi-channels.conf: No such file or directory
查看dahdi通道情况
dahdi_cfg -vvv
查看内核驱动加载情况
dmesg | grep wct4xxp
[ 5.618494] wct4xxp 0000:09:00.0: 5th gen card with initial latency of 2 and 1 ms per IRQ
[ 5.618525] wct4xxp 0000:09:00.0: Firmware Version: c01a8000
[ 5.619282] wct4xxp 0000:09:00.0: FALC Framer Version: 2.1 or earlier
[ 5.619435] wct4xxp 0000:09:00.0: Found a Wildcard: Wildcard TE210P (5th Gen)
[ 5.661447] wct4xxp 0000:09:00.0: firmware: failed to load dahdi-fw-oct6114-064.bin (-2)
[ 5.661620] wct4xxp 0000:09:00.0: firmware: failed to load dahdi-fw-oct6114-064.bin (-2)
[ 5.661689] wct4xxp 0000:09:00.0: Direct firmware load for dahdi-fw-oct6114-064.bin failed with error -2
[ 5.661696] wct4xxp 0000:09:00.0: VPM450: firmware dahdi-fw-oct6114-064.bin not available from userspace
显示缺少dahdi-fw-oct6114-064.bin 此为回声消除固件
下载链接
dahdi-linux-complete\linux\drivers\dahdi\firmware\dahdi-fw-oct6114-064-1.05.01.tar.gz\dahdi-fw-oct6114-064-1.05.01.tar\ 找到文件
复制对应文件至/usr/lib/firmware/ 目录下
工作正常
dmesg | grep wct4xxp
[ 5.778379] wct4xxp 0000:09:00.0: 5th gen card with initial latency of 2 and 1 ms per IRQ
[ 5.778410] wct4xxp 0000:09:00.0: Firmware Version: c01a8000
[ 5.779172] wct4xxp 0000:09:00.0: FALC Framer Version: 2.1 or earlier
[ 5.779352] wct4xxp 0000:09:00.0: Found a Wildcard: Wildcard TE210P (5th Gen)
[ 5.842874] wct4xxp 0000:09:00.0: firmware: direct-loading firmware dahdi-fw-oct6114-064.bin
[ 14.413526] wct4xxp 0000:09:00.0: VPM450: hardware DTMF disabled.
[ 14.413532] wct4xxp 0000:09:00.0: VPM450: Present and operational servicing 2 span(s)
参考
https://documentation.xivo.solutions/en/2021.15/installation/xivo/hardware/echo_canceller.html
reboot
查看dadhi服务情况
systemctl status dahdi
systemctl enable dahdi
nano /etc/dahdi/system.conf
systemctl start dahdi
编辑配置文件
cp /etc/dahdi/system.conf /etc/dahdi/system.conf.bak
nano /etc/dahdi/system.conf
span=1,0,0,CCS,HDB3
span=2,0,0,CCS,HDB3
bchan=1-15,17-31,32-46,48-62
dchan=16,47
loadzone=cn
defaultzone=cn
echocanceller=oslec,1-15,17-31,32-46,48-62
安装lxc
apt install lxc libpam-cgfs
lxc-checkconfig
常用命令
lxc-create -n name -f config_file
lxc-version 用于显示系统LXC的版本号(可以通过此命令判断系统是否安装了lxc)
lxc-checkconfig 用于判断linux内核是否支持LXC
lxc-create用于创建一个容器
lxc-execute 用于在一个容器执行应用程序
lxc-start 用于在容器中执行给定命令
lxc-kill 发送信号给容器中的第一个用户进程(容器内部进程号为2的进程)
lxc-stop 用于停止容器中所有的进程
lxc-destroy 用于销毁容器
lxc-cgroup 用于获取或调整与cgroup相关的参数
lxc-info 用户获取一个容器的状态
lxc-monitor 监控一个容器状态的变换,当一个容器的状态变化时,此命令会在屏幕上打印出容器的状态
lxc-ls -f 列出当前系统所有的容器
lxc-start
lxc-attach -n
lxc-console
lxc-copy -n ubuntu1 -N clone_ubuntu1 复制容器
lxc-snapshot -n ubuntu1 创建快照
软关机:
lxc-stop -n
重启容器:
lxc-stop -n
例如我们要重启rstudio这个容器的话:
lxc-stop -n
如果无法正常重启,可以尝试硬关闭:
lxc-stop -n
如果要先尝试软关机再若180秒后依旧无反应的话再硬关闭则:
lxc-stop -n rstudio -k -t 180
ls /var/lib/lxc 容器目录
ls /usr/share/lxc/templates/ 查看当前模板
/etc/lxc/default.conf 默认容器模板
从镜像站创建lxc容器 这里需要创建debian11的容器因为dahdi的驱动还不支持debian12
lxc-create -t download -n
lxc-create -t download --name debian12 -- --server mirrors.tuna.tsinghua.edu.cn/lxc-images\
--dist debian \
--release bookworm \
--arch amd64 \
指定镜像
Distribution:
debian
Release:
bookworm
Architecture:
amd64
创建LXC 启用嵌套 (取消无特权模式--buqueding) 248 1 变成了 246 1 需注意
nano /var/lib/lxc/debian/mount_hook.sh
mkdir -p ${LXC_ROOTFS_MOUNT}/dev/dahdi
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/channel c 196 254
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/ctl c 196 0
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/pseudo c 196 255
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/timer c 196 253
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/transcode c 196 250
mkdir -p ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan
mkdir -p ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/001 c 246 1
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/002 c 246 2
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/003 c 246 3
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/004 c 246 4
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/005 c 246 5
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/006 c 246 6
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/007 c 246 7
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/008 c 246 8
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/009 c 246 9
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/010 c 246 10
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/011 c 246 11
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/012 c 246 12
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/013 c 246 13
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/014 c 246 14
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/015 c 246 15
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/016 c 246 16
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/017 c 246 17
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/018 c 246 18
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/019 c 246 19
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/020 c 246 20
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/021 c 246 21
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/022 c 246 22
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/023 c 246 23
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/024 c 246 24
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/025 c 246 25
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/026 c 246 26
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/027 c 246 27
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/028 c 246 28
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/029 c 246 29
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/030 c 246 30
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/001/031 c 246 31
mkdir -p ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/001 c 246 32
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/002 c 246 33
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/003 c 246 34
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/004 c 246 35
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/005 c 246 36
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/006 c 246 37
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/007 c 246 38
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/008 c 246 39
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/009 c 246 40
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/010 c 246 41
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/011 c 246 42
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/012 c 246 43
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/013 c 246 44
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/014 c 246 45
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/015 c 246 46
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/016 c 246 47
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/017 c 246 48
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/018 c 246 49
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/019 c 246 50
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/020 c 246 51
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/021 c 246 52
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/022 c 246 53
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/023 c 246 54
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/024 c 246 55
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/025 c 246 56
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/026 c 246 57
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/027 c 246 58
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/028 c 246 59
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/029 c 246 60
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/030 c 246 61
mknod -m 666 ${LXC_ROOTFS_MOUNT}/dev/dahdi/chan/002/031 c 246 62
chmod +x /var/lib/lxc/debian/mount_hook.sh
nano /var/lib/lxc/debian/config
lxc.cgroup2.devices.allow = a
lxc.autodev = 1
lxc.hook.autodev = /var/lib/lxc/debian/mount_hook.sh
chown 107:root /dev/dahdi/ -R
107为lxc内asterisk用户在HOST系统中的用户ID
按照教程在LXC容器中运行的debian11内安装freepbx,主机上安装驱动的操作也要做
debian11中安装FreePBX16
进入freepbx 手动安装dahdi扩展模块
LXC内遇到的问题解决方案:
如有如下报错需要,将当前内核版本文件夹内复制到/lib/modules/6.1.0-17-amd64
systemctl status dahdi
Jan 10 08:36:02 dahdi[233]: modprobe: FATAL: Module dahdi not found in directory /lib/modules/6.1.0-17-amd64
freepbx内dadhi页面显示报错DAHDi Doesn't appear to be running. Click the 'Restart DAHDi & Asterisk' button below
asterisk -rvvvv
重新载入dahdi模块
module unload chan_dahdi.so
module load chan_dahdi.so
拷贝文件到LXC内
/usr/lib/asterisk/modules/chan_dahdi.so
/usr/lib/libpri.so.1.4
/usr/lib/x86_64-linux-gnu/libss7.so.2.0
/usr/lib/x86_64-linux-gnu/libopenr2.so.3.1.2
ln -s /usr/lib/x86_64-linux-gnu/libopenr2.so.3.1.2 /usr/lib/x86_64-linux-gnu/libopenr2.so.3