0

In my chroot I need /proc and /sys and /dev.

I am happy to bind-mount /dev since it is a temp fs. But /proc and /sys are part of the rootfs.

In my chroot I need to erase/re-format the rootfs (which contains /proc and /dev) because they are on a flash and I need access to the UBI filesystem elements within.

I am not sure if I can just make a copy - somthing like:

cp -ax /{sys,proc} /mnt/chroot

Or is there a clever way to mount them that clones them?

2

But /proc and /sys are part of the rootfs.

No they're not. They're also temporary filesystems – even more than that, they're completely virtual filesystems. The boot process just needs to mount an instance of procfs and sysfs respectively.

Within a container, you can do the same – mount -t procfs, or even bind the host system's /proc.

  • ooh... cool! - which would you say is more correct mount -t ... or mount -o bind... considering I am going to erase the flash partition that the rootfs lives on... or does it really not matter since they are completly seperate from the flash partition/rootfs? ... sorry I am still a bit new to this and generally a bit confused! – code_fodder Oct 1 '18 at 13:30
  • All mounts of any kind are completely separate from the rootfs. That's what makes them mounts and not ordinary copies. The rootfs just has empty directories acting as mountpoints, but never actually gains the contents of the mounted filesystem. – grawity Oct 1 '18 at 13:33
  • yeh, ok - that makes sense... and probably sounds really obvious now that you point it out! so, if its a mount then it is not part of the rootfs. What is confusing me slightly is that when I get a rootfs tarball, there is a /proc and /sys and /dev in them...but looking closer they are all empty. I presume this is so that the "mount point" exists otherwise the mount would fail.... I think I am starting to get it! (pls correct if wrong :) – code_fodder Oct 1 '18 at 13:39
  • Yes. It's mostly a formality, I'd call it, but the path must already exist before you can mount anything on it. – grawity Oct 1 '18 at 14:45

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.