2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-09-02 00:08:24 +00:00
Files
confluent/confluent_osdeploy/utils/start_root.c
Jarrod Johnson cfa16237e1 Dismantle initramfs by default in EL9/EL10 diskless
If debugssh is not requsted, the initramfs is not needed.

Do not unshare the mount namespace, leave the kernel relevant namespace 'normal'

Remove some initramfs content to free up some memory.
2025-07-29 14:26:43 -04:00

21 lines
780 B
C

#include <unistd.h>
#include <stdio.h>
#include <sys/mount.h>
#define __USE_GNU
#include <sched.h>
#include <string.h>
int main(int argc, char* argv[]) {
if (argc < 2 || strcmp(argv[1], "-s")) {
unshare(CLONE_NEWNS);
}
mount("/dev", "/sysroot/dev", NULL, MS_MOVE, NULL);
mount("/proc", "/sysroot/proc", NULL, MS_MOVE, NULL);
mount("/sys", "/sysroot/sys", NULL, MS_MOVE, NULL);
mount("/run", "/sysroot/run", NULL, MS_MOVE, NULL);
if (chdir("/sysroot") < 0) { fprintf(stderr, "Unable to chdir!\n"); }
mount("/sysroot", "/", NULL, MS_MOVE, NULL);
if (chroot(".") < 0) { fprintf(stderr, "Failed to chroot!\n"); }
if (chdir("/") < 0) { fprintf(stderr, "Unable to chdir after chroot!\n"); }
execl("/sbin/init", "/sbin/init", NULL);
}