网上很多教程,大部分过时了,成功之后分享一下。
首先是解决USB启动的过程,方法很简单
官方说明
我使用的是推荐方法,下载官方烧卡工具(Mac M1 貌似1.6.1版本有问题,1.5版本可以用),选择Misc utility images -> Bootloader -> usb 写入备份sd卡.插入设备,接屏幕,等待闪烁稳定屏幕变绿。
ubuntu server 固件
此新固件不要替换启动文件。
烧录系统到SSD。
然后是非官方镜像无法自动解压启动文件下的vmlinuz 需要zcat 一下
zcat vmlinuz > vmlinux
然后修改一下pi4配置(config.txt)
[pi4]
max_framebuffers=2
dtoverlay=vc4-fkms-v3d
boot_delay
kernel=vmlinux
initramfs initrd.img followkernel
新建一个脚本 auto_decompress_kernel(不执行这几部 系统重启之后就废了 亲测)
#!/bin/bash -e
#Set Variables
BTPATH=/boot/firmware
CKPATH=$BTPATH/vmlinuz
DKPATH=$BTPATH/vmlinux
#Check if compression needs to be done.
if [ -e $BTPATH/check.md5 ]; then
if md5sum --status --ignore-missing -c $BTPATH/check.md5; then
echo -e "\e[32mFiles have not changed, Decompression not needed\e[0m"
exit 0
else echo -e "\e[31mHash failed, kernel will be compressed\e[0m"
fi
fi
#Backup the old decompressed kernel
mv $DKPATH $DKPATH.bak
if [ ! $? == 0 ]; then
echo -e "\e[31mDECOMPRESSED KERNEL BACKUP FAILED!\e[0m"
exit 1
else echo -e "\e[32mDecompressed kernel backup was successful\e[0m"
fi
#Decompress the new kernel
echo "Decompressing kernel: "$CKPATH".............."
zcat $CKPATH > $DKPATH
if [ ! $? == 0 ]; then
echo -e "\e[31mKERNEL FAILED TO DECOMPRESS!\e[0m"
exit 1
else
echo -e "\e[32mKernel Decompressed Succesfully\e[0m"
fi
#Hash the new kernel for checking
md5sum $CKPATH $DKPATH > $BTPATH/check.md5
if [ ! $? == 0 ]; then
echo -e "\e[31mMD5 GENERATION FAILED!\e[0m"
else echo -e "\e[32mMD5 generated Succesfully\e[0m"
fi
#Exit
exit 0
在/ect/apt/apt.conf.d/目录中创建一个脚本,并将其命名为999_decompress_rpi_kernel 。这里我ssd usb接入ubuntu系统,可以看到目录,据说可以在第一次启动后也可以。
DPkg::Post-Invoke {"/bin/bash /boot/firmware/auto_decompress_kernel"; };
然后
sudo chmod +x 999_decompress_rpi_kernel
方法源自官网论坛
附:
cn.ports.ubuntu.com
ubuntu 官方国内镜像速度非常慢,坑