deleting a ‘file’ under /proc or /dev

I am using a cowdancer/debootstrap setup to generate a chroot.

Of course, as I iterate, I generate some chroot configurations that are bad.

I have found myself in an awkward situation where I have a slew of files under /proc that are refusing to be deleted.

When I sudo rm -rf z_needs_to_be_deleted, I get a ton of messages that look analogous to this:

rm: cannot remove 'z_needs_to_be_deleted/var/cache/pbuilder/build/cow.13620/
proc/6352/task/6358/loginuid':  Permission denied

How do I kill off this chroot?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

/proc and (usually) much of /dev are read only kernel-generated “filesystems”. You don’t delete them, you just umount the filesystem. If rm -r /proc/6352 worked, it would have to be semantically equivalent to kill -9 6352, since it’s really just presenting information about pid 6352, not actual files anywhere.

Use mount to see what mounted filesystems are under the chroot and umount them before removing any files. This is perhaps even more important when it’s a bind mount, since rm -r would remove the original files outside the jail.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x