summaryrefslogtreecommitdiff
path: root/src/switchroot/switchroot.sh
blob: 64de80c144b831f0960f41f43c5f4988b1407cdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh

# This demonstration script is an implementation in shell
# similar to ostree-prepare-root.c.  For a bit more information,
# see adapting-existing.md.

## the ostree boot parameter is avaialbe during the init
env | grep ostree
# ostree=/ostree/boot.1/.../.../0
## bind mount the ostree deployment to prepare it for move
mount --bind $sysroot$ostree $sysroot$ostree
## bind mount read-only /usr
mount --bind $sysroot$ostree/usr $sysroot$ostree/usr
mount --bind -o remount,ro $sysroot$ostree/usr $sysroot$ostree/usr
## bind mount the physical root
mount --bind $sysroot $sysroot$ostree/sysroot
## bind mount the var directory which is preserved between deployments
mount --bind $sysroot/ostree/deploy/os/var $sysroot$ostree/var
## make sure target directories are present within var
cd $sysroot$ostree/var
mkdir -p roothome mnt opt home
cd -
## move the deployment to the sysroot
mount --move $sysroot$ostree $sysroot
## after these the init system should start the switch root process