Sunday, August 19, 2018

Using a schroot environment correctly

Without assign session name :

$schroot -c u1604

It will auto generate a session id under /var/lib/schroot/session :

$cat  /var/lib/schroot/session/u1604-3f9ac050-58ae-40af-95a3-e71dab8d1600
[u1604-3f9ac050-58ae-40af-95a3-e71dab8d1600]
aliases=
command-prefix=
description=Ubuntu 16.04 (session chroot)
directory=/home/neowong/u1604
...

And lots mounted folder under /var/lib/schroot/mount :

$ mount
/dev/nvme0n1p2 on /var/lib/schroot/mount/u1604-3f9ac050-58ae-40af-95a3-e71dab8d1600 type ext4 (rw,relatime,errors=remount-ro,data=ordered)
proc on /var/lib/schroot/mount/u1604-3f9ac050-58ae-40af-95a3-e71dab8d1600/proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /var/lib/schroot/mount/u1604-3f9ac050-58ae-40af-95a3-e71dab8d1600/sys type sysfs (rw,nosuid,nodev,noexec,relatime)
udev on /var/lib/schroot/mount/u1604-3f9ac050-58ae-40af-95a3-e71dab8d1600/dev type devtmpfs (rw,nosuid,relatime,size=4022048k,nr_inodes=1005512,mode=755)
devpts on /var/lib/schroot/mount/u1604-3f9ac050-58ae-40af-95a3-e71dab8d1600/dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
/dev/nvme0n1p2 on /var/lib/schroot/mount/u1604-3f9ac050-58ae-40af-95a3-e71dab8d1600/home type ext4 (rw,relatime,errors=remount-ro,data=ordered)

/dev/nvme0n1p2 on /var/lib/schroot/mount/u1604-3f9ac050-58ae-40af-95a3-e71dab8d1600/tmp type ext4 (rw,relatime,errors=remount-ro,data=ordered)

Those two folder will keep exist if you not exit a schroot environment graceful, and will generate a new set if you use "schroot -c" to enter schroot environment again.

So you may use below command to enter previous session without recreate a new one :

$ schroot -r -c $SESSIONID

Or to clean those existing session by :

$ schroot -e -c $SESSIONID


Friday, August 17, 2018

Setup a schroot environment of Ubuntu installation


### 1. Install schroot & debootstrap
sudo apt-get install schroot debootstrap


### 2. Install the Ubuntu in the schroot folder


$mkdir /home/neowong/u1604
$sudo debootstrap --variant=buildd --arch amd64 xenial /home/neowong/u1604 http://archive.ubuntu.com

variant=buildd fakechroot scratchbox minbase

### 3. Modify /etc/schroot/schroot.conf


[u1604]
description=Ubuntu 16.04
directory=/home/neowong/u1604
users=neowong
groups=neowong
root-users=neowong
root-groups=neowong
type=directory


### 4. List schroot availability 


$schroot  -l
chroot:u1604


### 5. Start to use schroot


$schroot -c u1604
(u1604)neowong@neonuc7:~$