Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.kernel > #73214
| From | Romain Perier <romain.perier@gmail.com> |
|---|---|
| Newsgroups | linux.debian.kernel |
| Subject | Re: recommended way to find out whether one is "within" the initramfs? |
| Date | 2021-10-06 19:00 +0200 |
| Message-ID | <D5iqS-22h-9@gated-at.bofh.it> (permalink) |
| References | <D5huP-1sM-27@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hey, Le mer. 6 oct. 2021 à 17:57, Christoph Anton Mitterer <calestyo@scientia.net> a écrit : > > Hey. > > I've just wondered whether there is recommended way to find out whether > one is currently "within" the initramfs (i.e. early boot) as generated > by Debians initramfs-tools, or not? > > I'd have probably done something like checking for: > if [ -f /conf/initramfs.conf ] && [ -f /scripts/init-top/ORDER ] && [ ! -e /usr/bin/dpkg ]; then > echo within initramfs > else > echo not within initramfs > fi > > Or are /conf/initramfs.conf and /scripts/init-top/ORDER not necessarily > included? > > The check for dpkg (which shouldn't be present in the initramfs, unless > someone includes it for whichever reason) would have been to rule out > the cases where someone created the other files in his normal > userspace. > > > Any better ideas? :D Quickly, few ideas (perhaps not the perfect ones): 1. Check for what is currently mounted as "/" ? (which technically should differ between initramfs or real rootfs) 2. Check if your binaries are running inside a klibc or busybox context (both are supported via an initramfs) ? 3. Check if systemd is running ? (so you have started userspace processes part of your real rootfs) > > > Thanks, > Chris. > Regards, Romain
Back to linux.debian.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
recommended way to find out whether one is "within" the initramfs? Christoph Anton Mitterer <calestyo@scientia.net> - 2021-10-06 18:00 +0200
Re: recommended way to find out whether one is "within" the initramfs? Romain Perier <romain.perier@gmail.com> - 2021-10-06 19:00 +0200
Re: recommended way to find out whether one is "within" the initramfs? Christoph Anton Mitterer <calestyo@scientia.net> - 2021-10-07 02:00 +0200
Re: recommended way to find out whether one is "within" the initramfs? Romain Perier <romain.perier@gmail.com> - 2021-10-07 12:40 +0200
csiph-web