Super Grub2 Disk Sid Chroot
Introduction
First of all you need to know that this is simply a Debian Sid Chroot. It's a amd64 chroot.
The base OS that we are using is another Debian Sid. If you are not using a Debian based OS like Ubuntu you might need to use cdebootstrap instead of debootstrap.
Chroot in this example is going to be installed in:
/mnt/ssd/sgd_chroot_sid_amd64
Please adapt to your needs.
First setup
So we cd to the parent directory of the directoy where our chroot will be created. And we invoke debootstrap
cd /mnt/ssd/ mkdir sgd_chroot_sid_amd64 debootstrap --arch amd64 sid sgd_chroot_sid_amd64 http://http.debian.net/debian/
Then we need to prepare our fstab to take care of mounting some auxiliar folders for the chroot so that it works ok. You can opt to mount them manually if you are not fancing of fstab doing it automatically. Please type all the command as root user
cat << EOF | sudo tee -a /etc/fstab proc /mnt/ssd/sgd_chroot_sid_amd64/proc proc defaults 0 0 sysfs /mnt/ssd/sgd_chroot_sid_amd64/sys sysfs defaults 0 0 EOF
I personally also add the home directory because I found it easier to work with from my main system. Be aware that you can delete all your files if you don't umount it before deleting the whole chroot.
cat << EOF | sudo tee -a /etc/fstab /home /mnt/ssd/sgd_chroot_sid_amd64/home ext4 bind 0 0 EOF
Then you need to mount all these mounts with:
mount -a
Custom your Sid Chroot
In order to enter into the Chroot you need to do:
chroot /mnt/ssd/sgd_chroot_sid_amd64/ /bin/bash
Once inside the chroot:
- I add my usual user (which happens to be 1000 UID so that's ok with home files)
adduser myuser
- I setup a password for it.
passwd myuser
- I make sure that resolv.conf has a working nameserver
nano /etc/resolv.conf
- I install sudo package
apt-get install sudo
- I setup sudo so that my normal user has sudo permissions
sudoedit /etc/sudoers myuser ALL=(ALL:ALL) ALL
- I modify the chroot name so that I am aware of it
nano /etc/debian_chroot I write: SG2D_CHROOT inside it
- Take rid of perl warning messages:
apt-get install debconf apt-get install locales nano /etc/locale.gen Uncomment # en_US.UTF-8 UTF-8 line and save locale-gen
If I am inside the chroot and I want to work as my new normal user I can run:
su myuser
.