Score:0

What happens if I do `mount --bind /dev` to a chroot directory and I remove it inside the chroot directory?

za flag

What happens if I do mount --bind /dev to a chroot directory and I chroot to the chroot directory and inside remove the /dev/ folder. I thought my host's /dev directory will be deleted but the web page I was reading says this :

The above commands will mount important directories of your host system to the edit directory. If you later decide to delete the edit directory, make sure to unmount all of them before doing so (see the Cleanup chapter below). Otherwise, your host system will become unusable until you reboot it.

So it's saying if I reboot my host it'll be ok. Is this true?

muru avatar
us flag
You cannot delete a mount point.
za flag
yeah, I tried a simple test, when I removed the files under the mount point, the files are also removed in the host file system. I don't know why the web page said like that.
za flag
@user535733 No, that's enough. I'll put an answer myself.
Score:0
za flag

as muru commented, I can't remove a mount point, only I can remove the files under that mount point. I did a simple test below (as I remember).

$sudo debootstrap --arch=amd64 forcal edit
$mkdir mydir; mkdir mydir/{a,b,c}
$mkdir edit/mnt2
$sudo mount --bind mydir edit/mnt2
$sudo chroot edit
(now I'm in the chroot file system)
#ls /mnt2
a b c
#\rm /mnt2/c
#exit
$ls mydir
a b

I could see the file I removed in the chroot file system is actally removed in the host file system as I expected.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.