From c3fa29ca201d3ab2686c53a0ed62a443e8a5a921 Mon Sep 17 00:00:00 2001 From: renlin Date: Sat, 8 Jul 2023 18:37:33 +0800 Subject: [PATCH 1/2] add logic to move etc/var mount logic into initramfs for both baremetal pxe mode and vm mode. --- files/etc.mount | 26 -------------------------- files/persist.mount | 24 ------------------------ files/var.mount | 26 -------------------------- scripts/00bootup/10-mount-etc.sh | 4 ++++ 4 files changed, 4 insertions(+), 76 deletions(-) delete mode 100644 files/etc.mount delete mode 100644 files/persist.mount delete mode 100644 files/var.mount create mode 100644 scripts/00bootup/10-mount-etc.sh diff --git a/files/etc.mount b/files/etc.mount deleted file mode 100644 index 7501f78a..00000000 --- a/files/etc.mount +++ /dev/null @@ -1,26 +0,0 @@ -## Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. - # KubeOS is licensed under the Mulan PSL v2. - # You can use this software according to the terms and conditions of the Mulan PSL v2. - # You may obtain a copy of Mulan PSL v2 at: - # http://license.coscl.org.cn/MulanPSL2 - # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - # IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - # PURPOSE. -## See the Mulan PSL v2 for more details. - -[Unit] -Description=etc Dir -DefaultDependencies=no -Conflicts=umount.target -Before=local-fs.target umount.target -Wants=persist.mount -After=persist.mount - -[Mount] -What=overlay -Where=/etc -Type=overlay -Options=upperdir=/persist/etc,lowerdir=/etc,workdir=/persist/etcwork - -[Install] -WantedBy=local-fs.target diff --git a/files/persist.mount b/files/persist.mount deleted file mode 100644 index edc46d2b..00000000 --- a/files/persist.mount +++ /dev/null @@ -1,24 +0,0 @@ -## Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. - # KubeOS is licensed under the Mulan PSL v2. - # You can use this software according to the terms and conditions of the Mulan PSL v2. - # You may obtain a copy of Mulan PSL v2 at: - # http://license.coscl.org.cn/MulanPSL2 - # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - # IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - # PURPOSE. -## See the Mulan PSL v2 for more details. - -[Unit] -Description=PERSIST Dir (/persist) -DefaultDependencies=no -Conflicts=umount.target -Before=local-fs.target umount.target - -[Mount] -What=/dev/disk/by-label/PERSIST -Where=/persist -Type=ext4 -Options=defaults - -[Install] -WantedBy=local-fs.target diff --git a/files/var.mount b/files/var.mount deleted file mode 100644 index 4343207d..00000000 --- a/files/var.mount +++ /dev/null @@ -1,26 +0,0 @@ -## Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. - # KubeOS is licensed under the Mulan PSL v2. - # You can use this software according to the terms and conditions of the Mulan PSL v2. - # You may obtain a copy of Mulan PSL v2 at: - # http://license.coscl.org.cn/MulanPSL2 - # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - # IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - # PURPOSE. -## See the Mulan PSL v2 for more details. - -[Unit] -Description=var Dir -DefaultDependencies=no -Conflicts=umount.target -Before=local-fs.target umount.target -Wants=persist.mount -After=persist.mount - -[Mount] -What=/persist/var -Where=/var -Type=node -Options=bind - -[Install] -WantedBy=local-fs.target diff --git a/scripts/00bootup/10-mount-etc.sh b/scripts/00bootup/10-mount-etc.sh new file mode 100644 index 00000000..ba9f8772 --- /dev/null +++ b/scripts/00bootup/10-mount-etc.sh @@ -0,0 +1,4 @@ +mount -t xfs /dev/disk/by-label/PERSIST /sysroot/persist +mount -t overlay -o upperdir=/sysroot/persist/etc,lowerdir=/sysroot/etc,workdir=/sysroot/persist/etcwork overlay /sysroot/etc + +mount --bind /sysroot/persist/var /sysroot/var \ No newline at end of file -- Gitee From 0cbfc5cd3dbd9eae6be7f17b2ccb0767fb27b01f Mon Sep 17 00:00:00 2001 From: renlin Date: Sat, 8 Jul 2023 18:47:10 +0800 Subject: [PATCH 2/2] adjust the mount type to ext4, instead of xfs, because current partion mode is ext4. --- scripts/00bootup/10-mount-etc.sh | 2 +- scripts/set_in_chroot.sh | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/00bootup/10-mount-etc.sh b/scripts/00bootup/10-mount-etc.sh index ba9f8772..65a1cdf4 100644 --- a/scripts/00bootup/10-mount-etc.sh +++ b/scripts/00bootup/10-mount-etc.sh @@ -1,4 +1,4 @@ -mount -t xfs /dev/disk/by-label/PERSIST /sysroot/persist +mount -t ext4 /dev/disk/by-label/PERSIST /sysroot/persist mount -t overlay -o upperdir=/sysroot/persist/etc,lowerdir=/sysroot/etc,workdir=/sysroot/persist/etcwork overlay /sysroot/etc mount --bind /sysroot/persist/var /sysroot/var \ No newline at end of file diff --git a/scripts/set_in_chroot.sh b/scripts/set_in_chroot.sh index 80b5a91b..b83cec55 100644 --- a/scripts/set_in_chroot.sh +++ b/scripts/set_in_chroot.sh @@ -6,7 +6,6 @@ if [ "$BOOT_MODE" = "legacy" ]; then else ln -s /usr/lib/systemd/system/boot-efi.mount /lib/systemd/system/local-fs.target.wants/boot-efi.mount fi -ln -s /usr/lib/systemd/system/etc.mount /lib/systemd/system/local-fs.target.wants/etc.mount str=`sed -n '/^root:/p' /etc/shadow | awk -F "root:" '{print $2}'` umask 0666 @@ -16,5 +15,13 @@ echo "root:"${ROOT_PWD}${str:1} > /etc/shadow cat /etc/shadow_bak >> /etc/shadow rm -rf /etc/shadow_bak -dracut -f -v --add bootup /initramfs.img --kver `ls /lib/modules` -rm -rf /usr/lib/dracut/modules.d/00bootup \ No newline at end of file +# move the 10-mount-etc.sh out +mv /usr/lib/dracut/modules.d/00bootup/10-mount-etc.sh / + +# make initramfs.img for baremetal PXE mode +dracut -f -v --add bootup /initramfs.img --include /10-mount-etc.sh /usr/lib/dracut/hooks/pre-pivot/10-mount-etc.sh --kver `ls /lib/modules` + +# make initramfs.img for vms +rm -f /boot/initramfs.img +dracut -f -v /boot/initramfs.img --include /10-mount-etc.sh /usr/lib/dracut/hooks/pre-pivot/10-mount-etc.sh --force --kver `ls /lib/modules` +rm -rf /usr/lib/dracut/modules.d/00bootup /10-mount-etc.sh \ No newline at end of file -- Gitee