in ,

Use Proxmox to open the door to home servers


This article is the first in a series of articles and is free for all readers to read.If you are interested in this articleSubsequent partInterested, or would like to see more in-depth guides like this, considerBecome a minority memberto get more exclusive content.


introduction

“Self-deployment” is a topic that advanced players cannot avoid. In the context of increasingly high cloud service prices, self-deployment can achieve higher freedom and privacy at a lower cost.

But where to deploy it? In addition to traditional options such as cloud hosts and NAS, an obvious new hot spot in the past two years is mini hosts. This is because with the improvement of processor performance, mobile and low-power processors are sufficient for common computing tasks, and the overall cost is relatively low. As a result, more and more players choose to buy mini consoles as home service hubs.1

The next question is what system to install. Windows can run more programs for daily use and is more convenient to interact with, but the number of services that can be run is relatively less than on Linux; Linux is just the opposite.

So is there any solution that can run two or even more systems at the same time?

The easiest thing to think of is to install a virtual machine in an existing operating system, such as through Windows' built-in Hyper-V management tool, WSL 2, and third-party VMware Workstation. However, the common disadvantage of these Type-2 hypervisors is that the host system itself requires a considerable amount of resources, and Windows (especially the consumer-oriented version) is frequently updated, has poor stability, and has poor stability. Not a competent server system.

If you want to avoid these pitfalls, you can consider using a Type-1 hypervisor, also known as a virtualization management platform. If you imagine a computer as a house, a server virtualization platform is equivalent to dividing it into independent small rooms adapted to different needs. The virtualization management platform does not depend on the host operating system (it can be regarded as an operating system in itself) and is closer to the underlying hardware, so it runs more efficiently and is more stable.

Currently, the main virtualization management platforms on the market include VMware vSphere, Hyper-V and Proxmox. Among them, VMware ESXi, the core component of VMware vSphere, was once free to download, and because of VMware's ecology and brand name, it was once the first choice of some players. However, after Broadcom acquired VMware, it saw money and switched all VMware products to a subscription system. Proxmox, which is open source, has extensive community support, and has a friendly user interface, has become almost the only low-cost option for home users. This is the protagonist we are going to introduce today.

Below, this article will introduce the advantages and installation methods of Proxmox in sequence, and in subsequent articles demonstrate how to use Proxmox virtualization systems and programs as well as advanced settings on Proxmox, to fully let readers understand how to build a home service center from scratch. .

Install Proxmox

There are two official installation methods for Proxmox, one is to install through the official mirror, and the other is based on DebianOverlay installation. It is generally recommended to use method 1, which has fewer problems. The following is a simple demonstration of the steps.

Prepare

Generally choose the latest version

Before installation, you must first prepare (1) a computer on which Proxmox needs to be installed, (2) a USB flash drive of at least 8G, and (3) an official download from ProxmoxInstall image.Use an image burning tool (such as Etcher) Burn the image to the prepared USB flash drive.

Burn to U disk

Next, turn on virtualization in the computer's BIOS settings. Intel's is called Intel® Virtualization Technology for Directed I/O (VT-d) or VT-x; AMD's is called AMD-V. Other processors need to be set as needed based on specific circumstances. In addition, you need to turn off secure boot and change the boot order to USB disk priority.

You can enter this interface normally. If you have a graphics card, select Graphical. If not, select Terminal UI.

After restarting, enter the installation interface and select “Install Proxmox VE”. After agreeing to the user agreement, in the “Target Harddisk” step, you can consider clicking “Option” to expand more settings and make a simple adjustment. From top to bottom, they are:

  • File system: If your host has sufficient memory (usually greater than or equal to 32GB), you can choose zfsbtrfs Such a more secure file format, otherwise I recommend usingext4.about zfs You can refer to the introduction ofthis document
  • hdsize: You can simply understand whether to use the entire hard disk, which is usually the maximum size of the hard disk. If you know Linux commands and plan to leave some space for other uses, then you can flexibly adjust it according to your needs. The total capacity of subsequent swapsize+maxroot+minfree+maxvz is equal to hdsize.
  • swapsize: The size of swap space in Linux can be simply understood as how much hard disk space can be used as memory when memory is insufficient. The default is the size of installed memory, the minimum is 4 GB, the maximum is 8 GB, and cannot exceed hdsize/8. Can be set to 0 so that swap space will not be created.
  • maxroot: It can be simply understood as how much space is needed to install Proxmox. The maximum cannot exceed hdsize/4.
  • minfree: It can be simply understood as the snapshot storage space of the virtual machine hard disk. If the hard disk exceeds 128GB, minfree reserves 16GB by default, otherwise hdsize/8 is recommended.
  • maxvz: The maximum space of the data volume storing the virtual machine, which should be the option with the largest number here.

If using zfs For such a more secure and complex file system, you can refer to Proxmox'sdocumentMake more detailed adjustments.

Then set common settings such as region, time zone, keyboard keys, root password, etc. In the FQDN (domain name) step, if you do not plan to expose it to the public network (and it is best not to), you can choose a name casually.

It will automatically restart after the installation is complete. If you can see the web management interface by accessing the IP address specified during installation (default is port 8086) in the LAN, it means the installation is successful.

Install a virtual machine in Proxmox

After going through the installation steps, you can finally start to officially install virtual machines and containers in Proxmox.

Before that, let's lay down some basic knowledge – there are two conspicuous buttons “Create Virtual Machine” and “Create CT” (LXC Container) in the upper right corner of the Proxmox management interface. What's the difference between them?

As mentioned earlier, if you imagine a computer as a house, Proxmox can divide it into independent small rooms that adapt to different needs.

Virtual machine: What is isolated in this way is a fully functional “suite” with its own kitchen, bathroom, living room and other facilities, which is not shared with other rooms at all. In other words, each virtual machine has its own operating system, which completely simulates the hardware equipment and software in an independent computer; the isolation of the virtual machine is better, and the operations and applications inside the virtual machine will not affect other operations. Virtual machines, but they also occupy relatively host resources.

The virtual machine has an independent BIOS, graphics card, SCSI controller, etc. It looks like what a computer should have.

LXC container: This method is divided more like an open office space in a building. Although each space looks independent, it will share public facilities such as corridors and bathrooms. Although each container can run different applications and services, the containers all share the basic components of the host operating system. There is no need to copy the operating system for each container. The operating efficiency is also more efficient and resource-saving than virtual machines.

LXC containers have only the most basic “performance” limitations

Therefore, non-Linux systems such as Windows and BSD are best run in virtual machines, while Linux distributions or Linux-based software such as Ubuntu and Docker can run in LXC containers.

Example: Installing a Windows 11 virtual machine

The following will take the familiar Windows 11 as an example to introduce the virtual machine installation process in Proxmox.

Prepare

Remember to download the multi-language version of Windows 11

From Microsoft official websitedownload Windows 11 official image2if you want to experience better virtualization performance in Windows, my suggestion is to start fromOpen source communityDownload the ISO version of Virtio's Windows driver.Then upload the downloaded file to a place where the ISO image can be stored, usually called localto facilitate calling during subsequent installation.

like this

Set up a virtual machine

Then “Create a virtual machine”, confirm the installed “node”, fill in the numerically unique “VM ID” and the “name” that cannot have spaces or special characters, and then “next step”.

In the “Operating System” step, find the Windows 11 image file just uploaded to local in “Use CD/DVD Disc Image File (ISO)”, and select “Microsoft Windows” and “11/ 2022”, check “Add additional driver for VirtIO driver” and find the VirtIO driver image file just uploaded to local.

Next, under “Graphics Card”, you can choose the best-performing “VirtIO-GPU” and “VirtIO SCSI single”. If you plan to let Proxmox automatically manage it later3 Windows, then you can also hook the “Qemu agent”. Because the default installation of Windows 11 requires UEFI and TPM, we also confirmed that the model is the newer “q35” and uses “OVMF (UEFI)” as the BIOS. Add “EFI storage” and “TPM storage” to “local-lvm”. .

The next step is to add “hard disk”. Because you want to create the most modern Windows 11, you should give priority to “SCSI” in “Bus/Device”. Specifically, there are the following differences between the options. Other options need to be moved to Proxmox Official documentation

  • SATA: A disk controller that replaced IDE since 2003, allowing higher throughput and more device connections. But the maintenance situation in the Proxmox project may not be as good as the following 2.
  • SCSI: A server hardware connector originally designed in 1985 that can connect up to 14 other pieces of hardware. VirtIO SCSI single is the best in terms of performance. In addition, checking “IO Thread” can help further improve performance.

The “cache” setting is also relatively complicated, but if you want to have both security and performance, it is recommended to use no cache; if you want better hard disk performance, and accept that it will only appear under extreme circumstances risk of data loss, then please choose Write Back. Specifically, the meaning of each option is as follows:

  • No cache: Do not use the host's cache (usually memory), but use the cache on the hard disk. All read and write operations interact directly with the physical storage device without going through the host's cache system. Avoid data corruption as much as possible and try to ensure data integrity. In addition, if your hard disk storage destination in Proxmox is the ZFS file system, please also select no cache.
  • Direct Sync: neither uses the host's cache nor the cache on the hard disk. Every write operation is immediately synchronized to the physical storage device. Choose this when you need to completely avoid data corruption and ensure data integrity, especially when you want to build a storage system (such as NAS) that does not include a UPS backup power supply.
  • Write through: Use the host's cache, but not the cache on the hard disk. Each write operation is immediately synchronized to the physical storage device and written to the host's cache, but the write is not considered complete until it is completely written to the physical storage device. The security is equivalent to “no cache”, but Write through can obtain data directly from the memory when reading, and the read performance is relatively better; while “no cache” relies on the cache on the hard disk, and the write performance is relatively better.
  • Write back: Use the host's cache and also use the cache on the hard disk. The write operation will be reported as completed when it is written to the host's cache, but it may be writing to the hard disk (even the cache on the hard disk may not be completed). At this time, a power outage will cause data loss. The virtual machine also needs to send a flush command later to ensure that the data has been safely written to the hard disk. Write back (unsafe) skips the flush instruction, so Write back (unsafe) should not be used in virtual machines that store important data.

If your virtual machine hard disk is about to be placed in an SSD (for example, my local-lvm is an SSD), please also check “Discard”. This option tells the virtual machine that the hard disk is an SSD to enable the trim command. At this step, it is best to check the “Advanced” option in the lower right corner and check the “SSD Emulation” option.

Freely allocate the number of “Cores” in the CPU settings, drag down the “Category” to the bottom and select “Host”4; Memory can also be allocated freely; the network is selected to be bridged to the previously set “vmbr0”, and the model selects the best-performing “VirtIO (paravirtualization)”. If there is a need for VLAN adjustment, you can also enter the “VLAN” value here , and finally complete it.

If you have other hardware that you want to add or adjust, such as connecting a USB flash drive to a virtual machine, you can make additional adjustments through “Hardware”. Then start the virtual machine to enter the installation steps.

Other details to note

Don't panic, it can be solved by loading the driver.

If you use Virtio-related options like me, you need to load the SCSI driver and network card driver before installing Windows. Otherwise, you will not be able to find the hard disk during installation, or you will be stuck in the welcome interface and cannot enter the system. Specifically, when you click “Install” > “Enter/Skip Serial Number” > “Select the desired version” > “Agree to User Instructions” > “Custom Installation”, no drive will be visible.

Drivers need to be selected one by one and installed one by one.

You need to click “Load Driver” > “Browse”, find the CD where the Virtio driver is located, find the SCSI driver “vioscsi”, the network card driver “NetKVM”, find the “amd64” folder under “w11”, and finally click OK. When you see this driver on the driver installation interface, you only need to click “Next” to complete the installation.

After the installation is completed and you enter the system, remember to find “virtio-win-gt-x64” and “virtio-win-guest-tools” in the CD where the Virtio driver is located to complete the installation of other necessary drivers and auxiliary programs.

Remember to install the driver and Proxmox agent

Install LXC container and run Docker

Compared with being directly installed on a Proxmox physical machine, LXC containers running Docker are not only safer, can directly control the resources that can be used, and can also package and backup the entire package to enhance security, and LXC containers and hosts share a set of architectures, and the performance overhead is close at zero. So running Docker in an LXC container is the most correct way. In addition, other Linux programs can be run directly in the LXC container, and the dependence on Docker can also be much smaller.

Prepare

Go to the storage area in Proxmox where “CT templates” can be stored, generally called local, click “Template” to download the system template that suits you. I personally prefer Debian Stable, which is famous for its stability, so the following content will also use Debian 12 as an example. You can choose other distributions according to your own preferences.

Set up LXC container

Then “Create CT”, just like the virtual machine, confirm whether the installed “node” is the one you want, fill in the numerically unique “VM ID” and the “name” without spaces or special characters. Check “Unprivileged Containers” and “Nesting”. “Nesting” refers to nested virtualization, and other virtualization software can be used in the virtual environment.

After setting the “Password” or “SSH Public Key”, you can proceed to the next step “Template”. The template part is also very simple. Just find the template you just downloaded and select it.

The other settings will not be described here. You can flexibly accompany your children according to your needs, and finally just click “Finish”.

Then, go to the “Options” of this LXC container and enable the “Button” “FUSE” to meet the needs of installing Docker. Generally speaking, other Linux programs do not need to enable these two options.

Setup steps within the container

Nothing will be displayed when entering the password.You can also use other software to ssh into the LXC container

After setting up the container, it can be used root Log in to the container with the password or SSH private key you just set. Enter as usual:

apt clean && apt update #清除 apt 缓存,并更新 apt 缓存

#替换清华 Debian 镜像 https://mirrors.tuna.tsinghua.edu.cn/help/debian/

apt install -y fuse-overlayfs #安装 fuse-overlayfs 组件

ln -s /usr/bin/fuse-overlayfs /usr/local/bin/fuse-overlayfs #在两个文件夹之间创建软连接

Then follow Docker Official documentationInstall Docker, domestic users can also use itTsinghua UniversityDocker image installation.

#删除有的 Docker 相关内容
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do apt-get remove $pkg; done 

#安装必要下载 PGP 密钥所需要的依赖
apt-get install ca-certificates curl gnupg lsb-release
 
# 添加 Docker 的 GPG 公钥
install -m 0755 -d /etc/apt/keyrings 
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg

# 将 Docker 官方源添加到 apt 库中
echo \
  "deb (arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg) https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  tee /etc/apt/sources.list.d/docker.list > /dev/null

# 安装 Docker
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# 启用 Docker 守护服务
systemctl enable docker

After the installation is complete, you can usedocker run hello-worldTest whether Docker is installed properly. Finally, you can run other applications you want to run in Docker. For example, I run AdGuard Home and HomeBridge in the LXC container at home.

Tips after success

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

Microsoft Outlook Flaw Exploited by Russia's APT28 to Hack Czech, German Entities

0day Issue 2 – Updated Chapter 7: Explanation of the Principles of Windows Service Vulnerabilities