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?
Best Answer
/proc
and (usually) much of/dev
are read only kernel-generated "filesystems". You don't delete them, you justumount
the filesystem. Ifrm -r /proc/6352
worked, it would have to be semantically equivalent tokill -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 thechroot
andumount
them before removing any files. This is perhaps even more important when it's abind
mount, sincerm -r
would remove the original files outside the jail.