pve lxc部署OMV(openmediavault)

前言:

最近闲来无事,把家里吃灰的J4125工控机,装到了星际魔盒的机箱里,因为菜,大力出奇迹弄断一个sata口,所以只有一个sata可以用了,就这样将就吧。

开始:

pve安装就不记录了,网上很多保姆教程,这里就记录lxc安装omv的记录,方便以后查找使用。
首先下载ct模板,这里我用的debian11
添加openmediavault软件源,因为我可能后续要使用docker,所以要记得开启特权容器,嵌套

安装密钥

apt-get install --yes gnupg
wget --quiet --output-document=- https://packages.openmediavault.org/public/archive.key | gpg --dearmor --yes --output "/usr/share/keyrings/openmediavault-archive-keyring.gpg"

添加软件包存储库:

cat <<EOF >> /etc/apt/sources.list.d/openmediavault.list
deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://packages.openmediavault.org/public shaitan main
# deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://downloads.sourceforge.net/project/openmediavault/packages shaitan main
## Uncomment the following line to add software from the proposed repository.
# deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://packages.openmediavault.org/public shaitan-proposed main
# deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://downloads.sourceforge.net/project/openmediavault/packages shaitan-proposed main
## This software is not part of OpenMediaVault, but is offered by third-party
## developers as a service to OpenMediaVault users.
# deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://packages.openmediavault.org/public shaitan partner
# deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://downloads.sourceforge.net/project/openmediavault/packages shaitan partner
EOF

安装

export LANG=C.UTF-8
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
apt-get update
apt-get --yes --auto-remove --show-upgraded \
    --allow-downgrades --allow-change-held-packages \
    --no-install-recommends \
    --option DPkg::Options::="--force-confdef" \
    --option DPkg::Options::="--force-confold" \
    install openmediavault

网络配置:

omv-confdbadm populate

直通硬盘

  • 确定硬盘id和关系:
ls -al /dev/sd*
#或者
ls -al /dev/disk/by-label 

我只有一个机械硬盘,所以只得出:

brw-rw---- 1 root disk 8, 0 Dec 19 11:16 /dev/sda1
# ls -al /dev/sda1
brw-rw---- 1 root disk 8, 1 Dec 19 11:16 /dev/sda1

得到值:sda=> 8,0 sda1=>8,1

  • 绑定硬盘:
    编辑lxc配置文件
    nano /etc/pve/lxc/100.conf
    增加如下:
lxc.cgroup.devices.allow: b 8:0 rwm
lxc.cgroup.devices.allow: b 8:1 rwm
  • 设置自动挂载脚本:
    nano /var/lib/lxc/100/mount-hook.sh其中100修改为你的lxcID
#!/bin/sh
mknod -m 777 ${LXC_ROOTFS_MOUNT}/dev/sda b 8 0
mknod -m 777 ${LXC_ROOTFS_MOUNT}/dev/sda1 b 8 1

赋予执行权限:chmod +x /var/lib/lxc/100/mount-hook.sh
编辑lxc配置文件,添加:

lxc.autodev: 1
lxc.hook.autodev: /var/lib/lxc/100/mount_hook.sh
  • 完成以后,所有配置内容:
arch: amd64
cores: 4
features: fuse=1,mount=nfs;cifs,nesting=1
hostname: OpenMediaVault
memory: 4096
ostype: debian
name=eth0,bridge=vmbr0,hwaddr=C2:95:7C:A4:ED:98,ip=dhcp,ip6=auto,type=veth
rootfs: local:100/vm-101-disk-0.raw,size=30G
swap: 0
tags: 10.10.10.123
lxc.cgroup2.devices.allow: b 8:0 rwm
lxc.cgroup2.devices.allow: b 8:1 rwm
lxc.autodev: 1
lxc.hook.autodev: /var/lib/lxc/100/mount_hook.sh

直通网卡

修改配置文件:nano /etc/pve/lxc/100.conf,增加网卡直通

lxc.net.0.type: phys
lxc.net.0.link: enp3s0
lxc.net.0.ipv4.address: 10.10.10.123/24
lxc.net.0.ipv4.gateway: 10.10.10.10
lxc.net.0.flags: up

插上网卡,开启容器,Enjoy😃

后记:

基本上就这些了,omv webui自行挂载磁盘,这些东西,百度很多,就不记录了

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容