香橙派5 Plus 上安装PVE虚拟机
约 637 字 预计阅读 2 分钟
次阅读
- 配置网络
/etc/network/interfaces
1
2
3
4
5
6
7
|
auto lo
iface lo inet loopback
auto enP3p49s0
iface enP3p49s0 inet static
address 192.168.10.69/24
gateway 192.168.10.1
|
1
2
|
127.0.0.1 localhost.localdomain localhost
192.168.10.69 opi5plus.pvetest.com opi5plus
|
1
2
3
4
5
|
fdisk /dev/nvme0n1
mkfs -t ext4 /dev/nvme0n1
mkdir -p /mnt/nvme0n1
mount -t ext4 /dev/nvme0n1 /mnt/nvme0n1
echo /dev/nvme0n1 /mnt/nvme0n1 ext4 defaults 1 2 >> /etc/fstab
|
1
|
qm importdisk 100 /mnt/nvme0n1/template/iso/openwrt.img sn570
|
1
2
3
4
5
|
# 找到文件
/etc/apt/apt.conf.d/proxy.conf
# 写入
Acquire::http::Proxy "<http://192.168.10.68:7890/>";
Acquire::https::Proxy "<http://192.168.10.68:7890/>";
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# Debian 12
echo "deb <https://mirrors.apqa.cn/proxmox/debian/pve> bookworm port">/etc/apt/sources.list.d/pveport.list
# Debian 11
echo "deb <https://mirrors.apqa.cn/proxmox/debian/pve> bullseye port">/etc/apt/sources.list.d/pveport.list
# apt-key
curl <https://mirrors.apqa.cn/proxmox/debian/pveport.gpg> -o /etc/apt/trusted.gpg.d/pveport.gpg
# fix path
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# install
apt update && apt install -y proxmox-ve
|
1
2
3
4
5
|
# 查询
hostnamectl
# 改
hostnamectl set-hostname opi5plus
|
1
2
3
4
5
6
7
8
9
10
|
# vmdk -> qcow2
qemu-img convert -O qcow2 openwrt.vmdk openwrt.qcow2
# import
qm importdisk 101 openwrt.qcow2 nvme0n1 --format=qcow2
#qm importdisk <vmid> <images-name> <storage pool> --format=<disk-fs>
# vmid:vm的id 例如102
# images-name:磁盘镜像的名字
# storage pool: 存储磁盘镜像的位置,一般写存储的名称,如pve01data
# disk-fs: 磁盘镜像格式 raw/vmdk/qcow2
|
1
2
3
4
5
6
7
8
9
10
11
12
|
pct create 102 \\
/mnt/nvme0n1/template/cache/openwrt-22.03.5-armvirt-64-default-rootfs.tar.gz \\
--rootfs sn570:4 \\
--ostype unmanaged \\
--hostname OpenWrt \\
--arch arm64 \\
--cores 1 \\
--memory 2048 \\
--swap 0 \\
-net0 bridge=vmbr1,name=eth0
/mnt/nvme0n1/template/cache/openwrt-22.03.5-armvirt-64-default-rootfs.tar.gz
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# conf
nano /etc/pve/lxc/102.conf
# modify
# openwrt.common.conf是PVE自带的openwrt配置文件示例,内含一些基本设置
lxc.include: /usr/share/lxc/config/openwrt.common.conf
# /dev/ppp pppoe拨号等功能需要用到
lxc.cgroup.devices.allow: c 108:0 rwm
# 钩子脚本,用于添加 /dev/ppp等设备
hookscript: local:snippets/hookscript.pl
# 将主机的网卡enp4s0分配给容器使用,根据自己的实际情况更改
# enP4p65s0 enP3p49s0
lxc.net.1.type: phys
lxc.net.1.link: enP4p65s0
lxc.net.1.flags: up
# 钩子脚本
mkdir /var/lib/vz/snippets
cp /usr/share/pve-docs/examples/guest-example-hookscript.pl /var/lib/vz/snippets/hookscript.pl
nano /var/lib/vz/snippets/hookscript.pl
# 36行修改为
# Second phase 'post-start' will be executed after the guest
# successfully started.
system("lxc-device add -n $vmid /dev/ppp");
system("lxc-device add -n $vmid /dev/net/tun");
print "$vmid started successfully.\\n";
# 修改文件支持unmanaged
nano /usr/share/perl5/PVE/LXC/Setup.pm
# 翻到最后修改为
sub unified_cgroupv2_support {
my ($self) = @_;
return if !$self->{plugin}; # unmanaged
$self->protected_call(sub {
$self->{plugin}->unified_cgroupv2_support();
});
}
|