View previous topic :: View next topic |
Author |
Message |
FlyingBullets n00b
Joined: 19 Mar 2024 Posts: 24
|
Posted: Mon Jan 20, 2025 5:44 pm Post subject: "arch-chroot" breaks /tmp in chrooted environment |
|
|
I know I should be reporting this to Gentoo's Bugzilla, but creating an account is inconvenient at the moment.
The "arch-chroot" command seems to have a bug where the simple act of chrooting into an environment causes the environment's /tmp directory to delete everything in it -- sort of. When using arch-chroot, it appears that there is nothing in the environment's /tmp even if we put something in there before; even stranger, it seems to delete everything for all the non-chrooted environments too. If we exit the chrooted environment, everything comes back.
I came across this bug when I was trying to fix a problem during my Gentoo install using a custom script I made -- it paused while it was installing stuff. I used arch-chroot to get into the environment and fixed the issue, and let the script continue. At the end of the installation, the script reported that it couldn't find /tmp/my_stuff while it was chrooted.
This does not happen when using the normal "chroot" command -- everything in the environment's /tmp directory stays intact, both from the chrooted and non-chrooted environment.
##############
How to reproduce
##############
1. Use the official Gentoo Minimal Installation CD
2. Follow the Handbook up to chrooting into the new environment, but don't chroot yet.
3. Run
Code: | touch /mnt/gentoo/tmp/dummy |
3. Switch to a different tty and run
Code: | arch-chroot /mnt/gentoo |
If we run "ls /tmp" in the chrooted tty, there will be no "dummy" file; the same goes for the original tty if we run "ls /mnt/gentoo/tmp".
Last edited by FlyingBullets on Mon Jan 20, 2025 6:36 pm; edited 4 times in total |
|
Back to top |
|
|
grknight Retired Dev
Joined: 20 Feb 2015 Posts: 2001
|
Posted: Mon Jan 20, 2025 6:00 pm Post subject: |
|
|
To replicate this, you did everything that arch-chroot does? including: Code: | unshare --fork --pid chroot /mnt/gentoo
mount -t tmpfs -o mode=1777,strictatime,nodev,nosuid tmp /tmp |
|
|
Back to top |
|
|
FlyingBullets n00b
Joined: 19 Mar 2024 Posts: 24
|
Posted: Mon Jan 20, 2025 6:11 pm Post subject: |
|
|
grknight wrote: | To replicate this, you did everything that arch-chroot does? including: |
No, I didn't run those commands, just arch-chroot. |
|
Back to top |
|
|
grknight Retired Dev
Joined: 20 Feb 2015 Posts: 2001
|
Posted: Mon Jan 20, 2025 6:18 pm Post subject: |
|
|
Quote: | This does not happen when using the normal "chroot" command -- everything in the environment's /tmp directory stays intact, both from the chrooted and non-chrooted environment. |
FlyingBullets wrote: | No, I didn't run those commands, just arch-chroot. |
Then I suggest you do. It is creating a namespaced environment with unshare which may not be what you are expecting. "It's a feature, not a bug"
If you don't like what arch-chroot does, then just use chroot and set things up how you like. |
|
Back to top |
|
|
pingtoo Veteran
Joined: 10 Sep 2021 Posts: 1479 Location: Richmond Hill, Canada
|
Posted: Mon Jan 20, 2025 6:31 pm Post subject: |
|
|
FlyingBullets,
arch-chroot the script internally mount -t tmpfs to chroot's /tmp. so effectively it cover the original chroot's /tmp with a new content (empty). so it is by design. |
|
Back to top |
|
|
FlyingBullets n00b
Joined: 19 Mar 2024 Posts: 24
|
Posted: Mon Jan 20, 2025 6:31 pm Post subject: |
|
|
grknight wrote: | Then I suggest you do. It is creating a namespaced environment with unshare which may not be what you are expecting. "It's a feature, not a bug" |
I see; the "mount -t tmpfs" command makes more sense.
In that case, my solution is to use "chroot". Thank you. |
|
Back to top |
|
|
|