Proxmox 笔记

Posted by API Caller on October 25, 2019

安装

6.0

制作启动U盘

Using UNetbootin or Rufus does not work.

Etcher 来制作.

换源

1
2
3
4
5
6
7
8
9
10
cat > /etc/apt/sources.list << EOF
deb https://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb https://mirrors.aliyun.com/debian-security stretch/updates main
deb-src https://mirrors.aliyun.com/debian-security stretch/updates main
deb https://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
EOF
1
2
3
4
5
6
7
8
mv /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.bak

# wget https://mirrors.ustc.edu.cn/proxmox/debian/proxmox-ve-release-6.x.gpg -O /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg

# deb http://download.proxmox.wiki/debian/pve buster pve-no-subscription
cat > /etc/apt/sources.list.d/pve-install-repo.list << EOF
deb https://mirrors.ustc.edu.cn/proxmox/debian/pve buster pve-no-subscription
EOF

装 vim

真复杂

1
2
3
4
5
6
7
8
9
apt-get update
apt-get dist-upgrade -y

apt-get purge vim-common* -y
apt-get purge vim-tiny* -y

apt-get install libtinfo5 --allow-remove-essential -y
apt-get install vim -y
apt-get install ncurses-base -y

挂载SSD

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 分区
fdisk /dev/sda
# ...

# 格式化
mkfs.ext4 /dev/sda1

# 挂载
mkdir /mnt/sda
mount /dev/sda1 /mnt/sda

# vim 
# /dev/sda1 /mnt/sda ext4 defaults 0 0

# 数据中心 - 添加 - 目录 - 全选

macOS

准备镜像

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
# 下载 BaseSystem.dmg, 可以在非 macOS 上
curl -O https://raw.githubusercontent.com/thenickdude/OSX-KVM/master/fetch-macOS.py
python3 fetch-macOS.py

#  #    ProductID    Version    Build   Post Date  Title
#  1    061-26578    10.14.5  18F2059  2019-10-14  macOS Mojave
#  2    061-26589    10.14.6   18G103  2019-10-14  macOS Mojave
#  3    061-32950    10.15.1   19B77a  2019-10-17  macOS Catalina Beta
#  4    041-91758    10.13.6    17G66  2019-10-19  macOS High Sierra
#  5    061-36794      10.15   19A603  2019-10-21  macOS Catalina
#  6    041-88800    10.14.4  18E2034  2019-10-23  macOS Mojave
#  7    041-90855    10.13.5   17F66a  2019-10-23  Install macOS High Sierra Beta

# Choose a product to download (1-7): 2


# dmg 转为 iso
hdiutil convert BaseSystem.dmg -format RdWr -o Mojave-installer.iso
mv Mojave-installer.iso.img Mojave-installer.iso

# 如果非 macOS 可以通过以下方式转换:
# dmg2img BaseSystem.dmg Mojave-installer.iso
# Or use qemu-img from the qemu-utils package
# qemu-img convert BaseSystem.dmg -O raw Mojave-installer.iso



开启文件服务器

1
2
3
4
5
# 开启 apache 服务
sudo apachectl start  

# 进入目录启动文件服务器
python -m SimpleHTTPServer 
1
2
3
# 下载 clover
curl -O https://github.com/thenickdude/OSX-KVM/releases/download/clover-r5070/clover-r5070.iso.gz
gzip -d clover-r5070.iso.gz

俩 .iso 都拷贝到 /var/lib/vz/template/iso 目录下.

获取 OSK authentication key

使用以下代码读取 mac 设备的 OSK authentication key

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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// cat > smc_read.c << EOF

/*
 * smc_read.c: Written for Mac OS X 10.5. Compile as follows:
 *
 * gcc -Wall -o smc_read smc_read.c -framework IOKit
 */

#include <stdio.h>
#include <IOKit/IOKitLib.h>

typedef struct {
    uint32_t key;
    uint8_t  __d0[22];
    uint32_t datasize;
    uint8_t  __d1[10];
    uint8_t  cmd;
    uint32_t __d2;
    uint8_t  data[32];
} AppleSMCBuffer_t;

int
main(void)
{
    io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault,
                               IOServiceMatching("AppleSMC"));
    if (!service)
        return -1;

    io_connect_t port = (io_connect_t)0;
    kern_return_t kr = IOServiceOpen(service, mach_task_self(), 0, &port);
    IOObjectRelease(service);
    if (kr != kIOReturnSuccess)
        return kr;

    AppleSMCBuffer_t inputStruct = { 'OSK0', {0}, 32, {0}, 5, }, outputStruct;
    size_t outputStructCnt = sizeof(outputStruct);

    kr = IOConnectCallStructMethod((mach_port_t)port, (uint32_t)2,
             (const void*)&inputStruct, sizeof(inputStruct),
             (void*)&outputStruct, &outputStructCnt);
    if (kr != kIOReturnSuccess)
        return kr;

    int i = 0;
    for (i = 0; i < 32; i++)
        printf("%c", outputStruct.data[i]);

    inputStruct.key = 'OSK1';
    kr = IOConnectCallStructMethod((mach_port_t)port, (uint32_t)2,
             (const void*)&inputStruct, sizeof(inputStruct),
             (void*)&outputStruct, &outputStructCnt);
    if (kr == kIOReturnSuccess)
        for (i = 0; i < 32; i++)
            printf("%c", outputStruct.data[i]);

    printf("\n");

    return IOServiceClose(port);
}

// EOF
1
2
gcc -o smc_read smc_read.c -framework IOKit
./smc_read

是固定的, Mojave 的是 ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc

创建虚拟机

修改 /etc/pve/qemu-server/100.conf 文件, 其中 100 为 VM ID

开机跳四叶草

https://mackie100projects.altervista.org/download-clover-configurator/

分辨率问题

  • 关机后再开机需要 Reset Bios, 否则分辨率不正常.
  • 也可以命令行来开机:
    1
    2
    
    qm start 100
    qm reset 100
    

显卡直通

1
2
3
4
5
6
7
vim /etc/default/grub

# GRUB_CMDLINE_LINUX_DEFAULT="quiet"
# 👇
# GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on video=efifb:off"

update-grub
1
2
3
4
5
6
7
8
vim /etc/modules

# vfio
# vfio_iommu_type1
# vfio_pci
# vfio_virqfd

update-initramfs -u -k all