Skip to content

Instantly share code, notes, and snippets.

@philroche
Last active November 15, 2016 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philroche/0fdeb0c31887bbf7300ef64e20e9b6db to your computer and use it in GitHub Desktop.
Save philroche/0fdeb0c31887bbf7300ef64e20e9b6db to your computer and use it in GitHub Desktop.
Reproduce unmounting of /dev after running apt-key in chroot
# Get the squashfs file system for the image we want to alter
wget http://cloud-images.ubuntu.com/yakkety/current/yakkety-server-cloudimg-amd64.squashfs
# Extract the squashfs filesystem to a local directory
unsquashfs yakkety-server-cloudimg-amd64.squashfs
# Mount and bind local /dev/ to local directory squashfs-root/dev
sudo mount --bind /dev/ squashfs-root/dev
# Update the resolv.conf so that we can make network calls within a chroot
sudo rm squashfs-root/etc/resolv.conf
sudo cp /etc/resolv.conf squashfs-root/etc/
# Add the Google Cloud Packages signing key
sudo chroot squashfs-root/ apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3746C208A7317B0F
# Try to unmount squashfs-root/dev
sudo umount squashfs-root/dev
# The result is:
# umount: /home/ubuntu/squashfs-root/dev: target is busy
# (In some cases useful info about processes that
# use the device is found by lsof(8) or fuser(1).)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment