Skip to content

Instantly share code, notes, and snippets.

@thenewvu
Last active November 19, 2023 13:57
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thenewvu/a8e0c47e9cc89c2fd499 to your computer and use it in GitHub Desktop.
Save thenewvu/a8e0c47e9cc89c2fd499 to your computer and use it in GitHub Desktop.
A guide to create a chroot environment from an Ubuntu iso on Ubuntu
# download ubuntu iso
The iso version should be lower/equal than/to the host version.
# install uck (ubuntu customization kit)
run:
sudo apt-get install uck
# setup chroot environment from iso
run:
export BASEDIR=/path/to/chroot/directory
sudo uck-remaster-unpack-iso /path/to/the/image.iso "$BASEDIR" && sudo uck-remaster-unpack-rootfs "$BASEDIR" && sudo uck-remaster-unpack-initrd "$BASEDIR"
# enter chroot environment
run:
sudo uck-remaster-chroot-rootfs /path/to/chroot/directory/
# run GUI app inside chroot environment
before enter chroot environment, run:
xhost +
inside chroot environment, run:
export DISPLAY=:0
# access a directory from chroot environment
run:
mount --bind /path/to/host/directory /path/to/directory/inside/chroot
ex:
mount --bind ~/work/docs ~/work/devenv/doanything/remaster-root/root/docs
after exit chroot environment, should run:
umount /path/to/directory/inside/chroot
# write files from outside chroot environment
run:
sudo chmod g+w -R /path/to/chroot/directory/remaster-root/
sudo chmod g+w -R /path/to/chroot/directory/remaster-root-home/
# replace app host with a faster one
inside chroot environment, edit:
/etc/apt/sources.list
replace the current host with the host get from:
https://launchpad.net/ubuntu/+mirror/free.nchc.org.tw-archive
the complete host list can get from:
https://launchpad.net/ubuntu/+archivemirrors
# references
https://help.ubuntu.com/community/DebootstrapChroot
http://www.thegeekstuff.com/2010/06/xhost-cannot-open-display/
https://help.ubuntu.com/community/FilePermissions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment