chroot.sh 478 B

123456789101112131415
  1. work_dir=$( dirname "${BASH_SOURCE[0]}" )
  2. echo "Chrooting to ${work_dir}..."
  3. mount -t proc none ${work_dir}/proc
  4. mount --rbind /sys ${work_dir}/sys
  5. mount --rbind /dev ${work_dir}/dev
  6. mount --rbind /tmp ${work_dir}/tmp
  7. #mount --rbind /usr/lib64 ${work_dir}/usr/lib64
  8. env -i HOME=/root TERM=$TERM SHELL=/bin/bash chroot ${work_dir} /bin/bash --login
  9. #umount ${work_dir}/usr/lib64
  10. umount ${work_dir}/tmp
  11. umount -l ${work_dir}/dev
  12. umount -l ${work_dir}/sys
  13. umount ${work_dir}/proc