Idea-Inspire

腾讯云轻量服务器安装FreeBSD

Reference: 2.4 Tencent Cloud Lightweight Cloud and other servers dd Installing FreeBSD | FreeBSD MFGA

腾讯云轻量服务器默认只支持Debian、Ubuntu、CentOS以及Windows Server等镜像,并不原生支持FreeBSD。不过通过VNC等方式,可以用手动安装FreeBSD系统。

注意,安装FreeBSD可能会导致当前服务器中所有数据被删除,所以务必先备份关键数据再进行!!!

安装步骤

  1. 修改Grub,引导进入mfslinux

  2. 在mfslinux中,加载并引导mfsBSD,mfsBSD是完全运行在内存中的精简FreeBSD系统

  3. 在mfsBSD中,安装freeBSD

以下教程基于腾讯云轻量服务器原版Ubuntu 22.04镜像,使用不同镜像可能会导致启动盘有一定差异,注意下文高亮部分。

Step 0:卸载腾讯云监控、云盾

systemctl stop tat_agent
systemctl disable tat_agent
rm -f /etc/systemd/system/tat_agent.service
rm -rf /usr/local/qcloud/
rm -rf /usr/local/sa/
reboot

Step 1:引导mfslinux

# 建立文件夹存放mfslinux
mkdir /boot/mfslinux

# 下载
cd /tmp
wget https://mfsbsd.vx.sk/files/iso/mfslinux/mfslinux-0.1.9-dd4a135.iso
mount ./mfslinux-0.1.9-dd4a135.iso /mnt
cp /mnt/isolinux/vmlinuz /mnt/isolinux/initramfs.igz /boot/mfslinux

之后有两种方式,一是VNC下启动Grub,手动引导mfslinux,具体参考Reference链接。此处直接修改Grub启动项,添加mfslinux到Grub中,并自动引导mfslinux。

# 文本编辑器打开
nano /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'Boot mfslinux' {
set root='hd0,gpt2'
linux /boot/mfslinux/vmlinuz
initrd /boot/mfslinux/initramfs.igz
}

注意,腾讯云Ubuntu 22.04的镜像硬盘使用的是GPT格式,所以此处root地址为hd0,gpt2,如果使用其他镜像,使用MBR硬盘模式,则此处应为hd0,msdos1

# 更新Grub项目
update-grub
# 修改默认启动
sed -i 's/GRUB_DEFAULT=0/GRUB_DEFAULT=2/g' /etc/default/grub
# 再次更新Grub项目
update-grub
reboot

Step 2:引导mfsBSD

重启片刻之后,可以通过SSH登陆到mfslinux,用户名root,密码mfsroot。如果长时间无法连上,可以通过VNC方式登陆服务器进行问题排查。

假设已经正常连接到mfslinux之后,

cd /tmp
wget https://mfsbsd.vx.sk/files/images/13/amd64/mfsbsd-se-13.0-RELEASE-amd64.img
dd if=mfsbsd-se-13.0-RELEASE-amd64.img of=/dev/vda
reboot

重启后等待片刻,也可以通过SSH登陆到mfsBSD,用户名密码同上。

Step 3:安装FreeBSD

正常进入mfsBSD之后,只需要下载FreeBSD的manifest就可以正常安装了,

# 下载manifest
mkdir -p /usr/freebsd-dist
cd /usr/freebsd-dist
fetch http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/13.0-RELEASE/MANIFEST

# 安装FreeBSD
bsdinstall

需要注意的是,zfs需要大量的内存,并且需要支持UEFI启动。对于小服务器,建议使用UFS自动安装并且选择MBR格式硬盘。