Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
"arch-chroot" breaks /tmp in chrooted environment [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
FlyingBullets
n00b
n00b


Joined: 19 Mar 2024
Posts: 24

PostPosted: Mon Jan 20, 2025 5:44 pm    Post subject: "arch-chroot" breaks /tmp in chrooted environment Reply with quote

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
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 2001

PostPosted: Mon Jan 20, 2025 6:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
FlyingBullets
n00b
n00b


Joined: 19 Mar 2024
Posts: 24

PostPosted: Mon Jan 20, 2025 6:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 2001

PostPosted: Mon Jan 20, 2025 6:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1479
Location: Richmond Hill, Canada

PostPosted: Mon Jan 20, 2025 6:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
FlyingBullets
n00b
n00b


Joined: 19 Mar 2024
Posts: 24

PostPosted: Mon Jan 20, 2025 6:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum