Last active
November 15, 2016 11:39
-
-
Save philroche/0fdeb0c31887bbf7300ef64e20e9b6db to your computer and use it in GitHub Desktop.
Reproduce unmounting of /dev after running apt-key in chroot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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