Skip to content

Commit

Permalink
custom anolis 8.6 dpu os
Browse files Browse the repository at this point in the history
Signed-off-by: Weitao Zhou <[email protected]>
  • Loading branch information
Weitao Zhou committed Jun 19, 2023
1 parent 94519b9 commit f51dfee
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 130 deletions.
55 changes: 35 additions & 20 deletions anolisos/8.6/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
from --platform=linux/arm64 rockylinux:8.6.20227707
from --platform=linux/arm64 registry.openanolis.cn/openanolis/anolisos:8.6
ADD qemu-aarch64-static /usr/bin/

WORKDIR /root/workspace
ADD install.sh .
ADD create_bfb .
ADD mlxbf-bootimages-3.9.3-12383.aarch64.rpm .
ADD mlxbf-bootimages-@[email protected] .


ENV RUN_FW_UPDATER=no

RUN dnf install -y epel-release "dnf-command(config-manager)" && \
dnf config-manager --set-enabled powertools && \
RUN dnf install -y anolis-experimental-release epel-release "dnf-command(config-manager)" && \
dnf config-manager --set-enabled PowerTools && \
dnf config-manager --set-enabled Experimental && \
sed -i 's#$releasever#8.6#' /etc/yum.repos.d/Anolis* && \
dnf module enable -y ruby:3.0 && dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo && \
dnf install --enablerepo=baseos -y passwd dracut-network dracut-tools dracut-squash bc bison flex \
dnf install --enablerepo=BaseOS -y passwd dracut-network dracut-tools dracut-squash bc bison flex \
pesign rsync re2c patchutils git annobin intltool dwarves groff \
kernel-rpm-macros libtool rpm-build rpm-sign automake meson cmake \
gcc-c++ cryptsetup ltrace lsof jq unzip sysstat nvme-cli uuid \
Expand All @@ -23,26 +26,38 @@ RUN dnf install -y epel-release "dnf-command(config-manager)" && \
python3-Cython python3-sphinx python3-twisted glib2-devel python36-devel elfutils-devel \
binutils-devel pciutils-devel openssl-devel libnl3-devel selinux-policy-devel numactl-devel \
unbound-devel libpcap-devel tcl-devel valgrind-devel iptables-devel libdb-devel libmnl-devel \
dmidecode edac-utils ipmitool libiscsi libsysfs llvm-libs redhat-lsb-core redhat-lsb-submod-security \
dmidecode edac-utils ipmitool libiscsi libsysfs llvm-libs mstflint \
system-lsb-submod-security system-lsb-core \
docker-ce docker-ce-cli container-selinux containerd.io

RUN dnf update -y

RUN dnf config-manager --nogpgcheck --add-repo https://linux.mellanox.com/public/repo/doca/1.5.1/rockylinux8.6/aarch64/

RUN dnf install -y kernel-4.18.0-372.26.1.el8_6 \
kernel-core-4.18.0-372.26.1.el8_6 \
kernel-cross-headers-4.18.0-372.26.1.el8_6 \
kernel-devel-4.18.0-372.26.1.el8_6 \
kernel-headers-4.18.0-372.26.1.el8_6 \
kernel-modules-4.18.0-372.26.1.el8_6 \
kernel-modules-extra-4.18.0-372.26.1.el8_6

RUN dnf install --nogpgcheck -y doca-runtime doca-tools doca-sdk
RUN dnf install -y kernel-5.10.134-13.an8 \
kernel-core-5.10.134-13.an8 \
kernel-devel-5.10.134-13.an8 \
kernel-headers-5.10.134-13.an8 \
kernel-modules-5.10.134-13.an8 \
kernel-modules-extra-5.10.134-13.an8

RUN wget https://www.mellanox.com/downloads/ofed/MLNX_OFED-@MLNX_OFED_VERSION@/MLNX_OFED_SRC-@[email protected] && \
tar xzf MLNX_OFED_SRC-@[email protected] && \
cd MLNX_OFED_SRC-@MLNX_OFED_VERSION@ && \
./install.pl -k 5.10.134-13.an8.aarch64 --kernel-sources /lib/modules/5.10.134-13.an8.aarch64/build \
--kernel-extra-args '--with-sf-cfg-drv --without-xdp --without-odp' \
--kernel-only --build-only && cd .. && \
find MLNX_OFED_SRC-@MLNX_OFED_VERSION@/RPMS -name '*rpm' -a ! -name '*debuginfo*rpm' -exec rpm -ihv '{}' \;

RUN cd /tmp && wget -r -np -nH --cut-dirs=3 -R "index.html*" https://linux.mellanox.com/public/repo/bluefield/@VERSION@/extras/SRPMS/
RUN mkdir -p /tmp/@VERSION@/extras/{SPECS,RPMS,SOURCES,BUILD} && \
for p in /tmp/@VERSION@/extras/SRPMS/*.src.rpm; do rpmbuild --rebuild -D "debug_package %{nil}" -D "KVERSION 5.10.134-13.an8.aarch64" --define "_topdir /tmp/@VERSION@/extras" $p;done && \
rpm -ivh --force /tmp/@VERSION@/extras/RPMS/aarch64/*.rpm

RUN dnf config-manager --add-repo https://linux.mellanox.com/public/repo/doca/2.0.2/rockylinux8.6/aarch64/ && \
dnf install --nogpgcheck -y doca-runtime-user doca-tools doca-sdk-user mft kmod-kernel-mft-mlnx

RUN /usr/sbin/update-pciids || true
RUN rpm -ihv --force mlxbf-bootimages-*.aarch64.rpm || true
RUN rpm -ihv --force ${WORKDIR}/mlxbf-bootimages-*.aarch64.rpm || true

RUN sed -i -e "s/signed/@IMAGE_TYPE@@CUSTOM_VERSION@/" /etc/mlnx-release
RUN sed -i -e "s/RockyLinux/@IMAGE_TYPE@_@CUSTOM_VERSION@/" /etc/mlnx-release

CMD ["/root/workspace/create_bfb", "-k", "4.18.0-372.26.1.el8_6.aarch64"]
CMD ["/root/workspace/create_bfb", "-k", "5.10.134-13.an8.aarch64"]
11 changes: 6 additions & 5 deletions anolisos/8.6/bfb-build
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ if ! (which docker > /dev/null 2>&1); then
exit 1
fi

DISTRO="rockylinux"
DISTRO="anolisos"
DISTRO_VERSION="8.6"
VERSION="3.9.3"
VERSION="3.9.3-12383"
MLNX_OFED_VERSION="23.04-1.1.3.0"
IMAGE_TYPE=${IMAGE_TYPE:-"prod"}
CUSTOM_VERSION="${DISTRO}_${DISTRO_VERSION}"

WDIR=/tmp/${DISTRO}${DISTRO_VERSION}.$$

Expand All @@ -52,13 +54,12 @@ wget -P $WDIR -r --no-verbose --no-directories -l1 --no-parent -A 'mlxbf-bootima
cp Dockerfile \
create_bfb \
install.sh \
build_rockylinux_bfb \
../../common/tools/qemu-aarch64-static \
$WDIR

cd $WDIR

sed -i -e "s/@IMAGE_TYPE@/$IMAGE_TYPE/;s/@CUSTOM_VERSION@/$CUSTOM_VERSION/" Dockerfile
sed -i -e "s/@MLNX_OFED_VERSION@/$MLNX_OFED_VERSION/g;s/@VERSION@/$VERSION/g;s/@IMAGE_TYPE@/$IMAGE_TYPE/g;s/@CUSTOM_VERSION@/$CUSTOM_VERSION/g" Dockerfile

docker build -t bfb_runtime_${DISTRO}${DISTRO_VERSION} -f Dockerfile .
docker run -t --rm --privileged -e container=docker \
Expand All @@ -71,4 +72,4 @@ docker run -t --rm --privileged -e container=docker \

readlink -f *.bfb

echo "Default root password is: rocky"
echo "Default root password is: anolis"
92 changes: 0 additions & 92 deletions anolisos/8.6/build_rockylinux_bfb

This file was deleted.

16 changes: 8 additions & 8 deletions anolisos/8.6/create_bfb
Original file line number Diff line number Diff line change
Expand Up @@ -256,29 +256,29 @@ cp -a /lib/firmware/mellanox/boot/capsule ./lib/firmware/mellanox/boot/
cp $CAPSULE ./lib/firmware/mellanox/boot/capsule/
mkdir -p mnt

mkdir -p rocky
mkdir -p anolis
# Tar the image
XZ_OPT="--threads=0 -9 --verbose" tar -cJp --exclude='./workspace' --exclude='./signing-local' --exclude='./signing-shared' --exclude='./var/run/docker.sock' \
--exclude='./root/workspace' --exclude='./tmp/*' --exclude='./run/*' --exclude='./sys/*' --exclude='./proc/*' --exclude='./dev/*' --exclude='./.dockerenv' \
--exclude='./root/rpmbuild' --exclude='./root/.rpmmacros' --exclude='./root/.bash_history' --exclude='./var/tmp/*rpm' --exclude='./bin/qemu-aarch64-static' \
--exclude='./usr/bin/qemu-aarch64-static' --exclude='./usr/bin/qemu-arm-static' --exclude='./var/lib/yum/*' --exclude='./var/cache/yum/*' -f "./rocky/image.tar.xz" -C / .
install -m 0755 ${SDIR}/install.sh ./rocky/install.sh
--exclude='./usr/bin/qemu-aarch64-static' --exclude='./usr/bin/qemu-arm-static' --exclude='./var/lib/yum/*' --exclude='./var/cache/yum/*' -f "./anolis/image.tar.xz" -C / .
install -m 0755 ${SDIR}/install.sh ./anolis/install.sh

mkdir scripts
cat > scripts/install-rocky.sh << EOF
cat > scripts/install-anolis.sh << EOF
#!/bin/sh
echo
echo "=================================" | tee /dev/kmsg
echo "Installing Rocky Linux. Please wait..." | tee /dev/kmsg
echo "Installing Anolis OS. Please wait..." | tee /dev/kmsg
echo "=================================" | tee /dev/kmsg
modprobe -a mlxbf_tmfifo dw_mmc_bluefield mmc_block virtio_console ${bootctl_module} 2>&1 | tee /dev/kmsg
modprobe -a mlx5_ib ib_uverbs 2>&1 | tee /dev/kmsg
sleep 5
/bin/sh /rocky/install.sh
/bin/sh /anolis/install.sh
if [ \$? -eq 0 ]; then
echo "===================================" | tee /dev/kmsg
echo "Installation finished. Rebooting..." | tee /dev/kmsg
Expand All @@ -287,12 +287,12 @@ if [ \$? -eq 0 ]; then
reboot -f
else
echo "========================" | tee /dev/kmsg
echo "Failed to install Rocky Linux" | tee /dev/kmsg
echo "Failed to install Anolis OS" | tee /dev/kmsg
echo "========================" | tee /dev/kmsg
fi
EOF

sed -i -e "s@source_conf /etc/conf.d@&\nbash -x /scripts/install-rocky.sh@" init
sed -i -e "s@source_conf /etc/conf.d@&\nbash -x /scripts/install-anolis.sh@" init

# Make initramfs
find . | cpio -H newc -o | gzip -9 > $initramfs
Expand Down
10 changes: 5 additions & 5 deletions anolisos/8.6/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ if [ -e /etc/bf.cfg ]; then
fi
fi

distro="Rocky Linux"
distro="Anolis OS"

function_exists()
{
Expand Down Expand Up @@ -300,7 +300,7 @@ if (lspci -n -d 15b3: | grep -wq 'a2dc'); then
sed -i -e "s/0x01000000/0x13010000/g" /mnt/etc/default/grub
fi

chroot /mnt grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg
chroot /mnt grub2-mkconfig -o /boot/efi/EFI/anolis/grub.cfg

kdir=$(/bin/ls -1d /mnt/lib/modules/4.18* /mnt/lib/modules/4.19* /mnt/lib/modules/4.20* /mnt/lib/modules/5.4* 2> /dev/null)
kver=""
Expand All @@ -313,7 +313,7 @@ else
kver=$(/bin/ls -1 /mnt/lib/modules/ | head -1)
fi

echo rocky | chroot /mnt passwd root --stdin
echo anolis | chroot /mnt passwd root --stdin

if [ `wc -l /mnt/etc/hostname | cut -d ' ' -f 1` -eq 0 ]; then
echo "localhost" > /mnt/etc/hostname
Expand Down Expand Up @@ -451,7 +451,7 @@ bfbootmgr --cleanall > /dev/null 2>&1

mount -t efivarfs none /sys/firmware/efi/efivars
/bin/rm -f /sys/firmware/efi/efivars/Boot* > /dev/null 2>&1
efibootmgr -c -d /dev/mmcblk0 -p 1 -l "\EFI\rocky\grubaa64.efi" -L $distro
efibootmgr -c -d /dev/mmcblk0 -p 1 -l "\EFI\anolis\grubaa64.efi" -L $distro
umount /sys/firmware/efi/efivars

BFCFG=`which bfcfg 2> /dev/null`
Expand Down Expand Up @@ -486,7 +486,7 @@ if [ -n "$BFCFG" ]; then
fi

echo
echo "ROOT PASSWORD is \"rocky\""
echo "ROOT PASSWORD is \"anolis\""
echo

if function_exists bfb_post_install; then
Expand Down

0 comments on commit f51dfee

Please sign in to comment.