Skip to content

Instantly share code, notes, and snippets.

@iaguis
Last active February 25, 2016 14:24
Show Gist options
  • Select an option

  • Save iaguis/1f1bdf2086a7b4f122ff to your computer and use it in GitHub Desktop.

Select an option

Save iaguis/1f1bdf2086a7b4f122ff to your computer and use it in GitHub Desktop.
CentOS is different!
#!/bin/bash
# Try with:
# sudo $PWD/udevd-experiment.sh
THIS_SCRIPT=$0
if [ "$1" = "udevd1" ] ; then
unshare --propagation unchanged -m $THIS_SCRIPT udevd2
exit 0
fi
if [ "$1" = "udevd2" ] ; then
mount --make-rslave /
mount --make-rshared /
sleep 5000
exit 0
fi
$THIS_SCRIPT udevd1 &
sleep 1
DIR=/tmp/udevd-experiment-$RANDOM
mkdir $DIR
cd $DIR
mkdir s1
mount -t tmpfs tmpfs $DIR/s1
mkdir s1/rootfs
mount -t tmpfs tmpfs $DIR/s1/rootfs
echo In the host namespace:
cat /proc/self/mountinfo|grep udevd || true
echo In the udevd namespace:
cat /proc/$(pidof sleep)/mountinfo|grep udevd || true
echo Simulating GC...
mount --make-private $DIR/s1/rootfs
mount --make-private $DIR/s1
umount $DIR/s1/rootfs
umount $DIR/s1
rm -rf $DIR/s1
echo In the host namespace:
cat /proc/self/mountinfo|grep udevd || true
echo In the udevd namespace:
cat /proc/$(pidof sleep)/mountinfo|grep udevd || true
# Cleanup
killall sleep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment