:: Re: [DNG] Help needed:[Fwd: eudev: …
Página Principal
Delete this message
Reply to this message
Autor: g4sra
Data:  
Para: dng
Assunto: Re: [DNG] Help needed:[Fwd: eudev: Methods to detect if running in a container.]
On 30/03/2020 16:18, aitor_czr wrote:
> Hi Svante,
>
> On 19/2/20 15:17, Svante Signell via Dng wrote:
>> Hello,
>>
>> No replies so far from the devuan-dev list. Maybe with a larger audience I can
>> get some help!
>>
>> Thanks!
> Checking� whether the *inode* number of the primary directory in the standard filesystem hierarchy
> used in the most unix-like sytems(that is, the root "/" directory) is *equal* to 2 will help to differentiate
> if you are within a container or not. eg you can do:
>
> $ ls --inode --directory "/"
>
> 2 /
>
> While in a container the output of this command will return a high inode number. I tested it in three
> different scenarios:
>
> a) Using docker bash shell of ubuntu:
>
> # docker run -it ubuntu bash
>
> root@b87da5b70a84:/# ls --inode --directory "/"
>
> 2492863 /
>
> b) Using a qemu qcow2 image of devuan:
>
> $ ls --inode --directory "/"
>
> 9531 /
>
> c) Inside the chroot jail of the live-sdk:
>
> root@devuan:/# ls --inode --directory "/"
>
> 22839335 /
>
> I reckon this approach won't work neither in the case of operating systems using random inode numbers
> (but this is not our case),nor in the case of chroot jails rooted on a mount point, in which case we have
> the following workaround(at least in debian-based systems):
>
> https://manpages.debian.org/jessie/debianutils/ischroot.1.en.html
>
> Hope this helps,
>
> Aitor.
>

This will likely only work reliably when the Guest is sharing a filesystem in some way.
Fails to identify a Devuan Guest which has its own partition running in a VM hosted by Fedora.
I reason it will also fail for a Guest with its own Logical Volume, anybody like to test ?