stateless systems, factory reset, golden master systems and

80
Stateless Systems, Factory Reset, Golden Master Systems and systemd LinuxCon Europe, Duesseldorf October 2014 Stateless Systems, Factory Reset, Golden Master Systems and

Upload: vuongthien

Post on 07-Jan-2017

230 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Stateless Systems, Factory Reset, Golden Master Systems and

Stateless Systems, Factory Reset, Golden MasterSystems and systemd

LinuxCon Europe, Duesseldorf

October 2014

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 2: Stateless Systems, Factory Reset, Golden Master Systems and

Factory Reset?

The procedure to bring a system back into the state that is wasshipped in.

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 3: Stateless Systems, Factory Reset, Golden Master Systems and

Factory Reset?

The procedure to bring a system back into the state that is wasshipped in.

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 4: Stateless Systems, Factory Reset, Golden Master Systems and

Stateless System?

A system where every single boot-up is as if a factory reset wasjust completed.

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 5: Stateless Systems, Factory Reset, Golden Master Systems and

Stateless System?

A system where every single boot-up is as if a factory reset wasjust completed.

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 6: Stateless Systems, Factory Reset, Golden Master Systems and

Golden Master?

The one master image a factory reset returns the state to.

The same image is usually shared between a multitude of systems.

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 7: Stateless Systems, Factory Reset, Golden Master Systems and

Golden Master?

The one master image a factory reset returns the state to.

The same image is usually shared between a multitude of systems.

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 8: Stateless Systems, Factory Reset, Golden Master Systems and

Where do you want this?

Containers, servers, laptops/desktops/tablets, mobile, embedded

Verifiable setups

Apps

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 9: Stateless Systems, Factory Reset, Golden Master Systems and

Where do you want this?

Containers,

servers, laptops/desktops/tablets, mobile, embedded

Verifiable setups

Apps

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 10: Stateless Systems, Factory Reset, Golden Master Systems and

Where do you want this?

Containers, servers,

laptops/desktops/tablets, mobile, embedded

Verifiable setups

Apps

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 11: Stateless Systems, Factory Reset, Golden Master Systems and

Where do you want this?

Containers, servers, laptops/desktops/tablets,

mobile, embedded

Verifiable setups

Apps

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 12: Stateless Systems, Factory Reset, Golden Master Systems and

Where do you want this?

Containers, servers, laptops/desktops/tablets, mobile,

embedded

Verifiable setups

Apps

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 13: Stateless Systems, Factory Reset, Golden Master Systems and

Where do you want this?

Containers, servers, laptops/desktops/tablets, mobile, embedded

Verifiable setups

Apps

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 14: Stateless Systems, Factory Reset, Golden Master Systems and

Where do you want this?

Containers, servers, laptops/desktops/tablets, mobile, embedded

Verifiable setups

Apps

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 15: Stateless Systems, Factory Reset, Golden Master Systems and

Where do you want this?

Containers, servers, laptops/desktops/tablets, mobile, embedded

Verifiable setups

Apps

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 16: Stateless Systems, Factory Reset, Golden Master Systems and

Tons of prior art: Android, ChromeOS, CoreOS, virtualizationinfrastructure, and many embedded systems

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 17: Stateless Systems, Factory Reset, Golden Master Systems and

Our goal with working on this in the systemd context: to solve thisin a modular and generic way, for all usecases

Right in the OS itself.

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 18: Stateless Systems, Factory Reset, Golden Master Systems and

Our goal with working on this in the systemd context: to solve thisin a modular and generic way, for all usecases

Right in the OS itself.

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 19: Stateless Systems, Factory Reset, Golden Master Systems and

Let’s seperate state from OS resources!

/etc: configuration

/var: state

/usr: vendor OS resources

(after the /usr merge)

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 20: Stateless Systems, Factory Reset, Golden Master Systems and

Let’s seperate state from OS resources!

/etc: configuration

/var: state

/usr: vendor OS resources

(after the /usr merge)

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 21: Stateless Systems, Factory Reset, Golden Master Systems and

Let’s seperate state from OS resources!

/etc: configuration

/var: state

/usr: vendor OS resources

(after the /usr merge)

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 22: Stateless Systems, Factory Reset, Golden Master Systems and

Let’s seperate state from OS resources!

/etc: configuration

/var: state

/usr: vendor OS resources

(after the /usr merge)

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 23: Stateless Systems, Factory Reset, Golden Master Systems and

Let’s seperate state from OS resources!

/etc: configuration

/var: state

/usr: vendor OS resources

(after the /usr merge)

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 24: Stateless Systems, Factory Reset, Golden Master Systems and

Flushing /etc, /var, just keeping /usr: full factory reset

Flushing just /var, keeping /usr and /etc: keeping settings, butdropping collected state

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 25: Stateless Systems, Factory Reset, Golden Master Systems and

Booting with /var empty?

Mostly just works, just a few more tmpfiles rules

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 26: Stateless Systems, Factory Reset, Golden Master Systems and

Booting with /var empty?

Mostly just works, just a few more tmpfiles rules

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 27: Stateless Systems, Factory Reset, Golden Master Systems and

Booting with /var empty?

Mostly just works, just a few more tmpfiles rules

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 28: Stateless Systems, Factory Reset, Golden Master Systems and

What’s tmpfiles again?

d /var 0755 - - -

L /var/run - - - - ../run

d /var/log 0755 - - -

f /var/log/wtmp 0664 root utmp -

f /var/log/btmp 0600 root utmp -

d /var/cache 0755 - - -

d /var/lib 0755 - - -

d /var/spool 0755 - - -

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 29: Stateless Systems, Factory Reset, Golden Master Systems and

What’s tmpfiles again?

d /var 0755 - - -

L /var/run - - - - ../run

d /var/log 0755 - - -

f /var/log/wtmp 0664 root utmp -

f /var/log/btmp 0600 root utmp -

d /var/cache 0755 - - -

d /var/lib 0755 - - -

d /var/spool 0755 - - -

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 30: Stateless Systems, Factory Reset, Golden Master Systems and

Booting with /etc empty?

More complex

Software is more allergic if configuration files in /etc are missing

User database!

Core OS components shipped by systemd are fixed

Exception in the core OS: dbus, PAM

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 31: Stateless Systems, Factory Reset, Golden Master Systems and

Booting with /etc empty?

More complex

Software is more allergic if configuration files in /etc are missing

User database!

Core OS components shipped by systemd are fixed

Exception in the core OS: dbus, PAM

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 32: Stateless Systems, Factory Reset, Golden Master Systems and

Booting with /etc empty?

More complex

Software is more allergic if configuration files in /etc are missing

User database!

Core OS components shipped by systemd are fixed

Exception in the core OS: dbus, PAM

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 33: Stateless Systems, Factory Reset, Golden Master Systems and

Booting with /etc empty?

More complex

Software is more allergic if configuration files in /etc are missing

User database!

Core OS components shipped by systemd are fixed

Exception in the core OS: dbus, PAM

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 34: Stateless Systems, Factory Reset, Golden Master Systems and

Booting with /etc empty?

More complex

Software is more allergic if configuration files in /etc are missing

User database!

Core OS components shipped by systemd are fixed

Exception in the core OS: dbus, PAM

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 35: Stateless Systems, Factory Reset, Golden Master Systems and

Booting with /etc empty?

More complex

Software is more allergic if configuration files in /etc are missing

User database!

Core OS components shipped by systemd are fixed

Exception in the core OS: dbus, PAM

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 36: Stateless Systems, Factory Reset, Golden Master Systems and

tmpfiles to the rescue:

C /etc/pam.d

C /etc/nsswitch.conf

Introducing: /usr/share/factory/etc

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 37: Stateless Systems, Factory Reset, Golden Master Systems and

sysusers to the rescue:

u root 0 "Super User" /root

u nobody 65534 "Nobody" -

g adm - - -

g wheel - - -

g kmem - - -

g lock - - -

g tty 5 - -

g utmp - - -

g audio - - -

g cdrom - - -

g dialout - - -

g disk - - -

g input - - -

g lp - - -

g tape - - -

g video - - -

g users - - -

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 38: Stateless Systems, Factory Reset, Golden Master Systems and

systemd-nspawn –volatile=no -b -D /srv/mycontainer

systemd-nspawn –volatile=state -b -D /srv/mycontainer

systemd-nspawn –volatile=yes -b -D /srv/mycontainer

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 39: Stateless Systems, Factory Reset, Golden Master Systems and

systemd-nspawn –volatile=no -b -D /srv/mycontainer

systemd-nspawn –volatile=state -b -D /srv/mycontainer

systemd-nspawn –volatile=yes -b -D /srv/mycontainer

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 40: Stateless Systems, Factory Reset, Golden Master Systems and

systemd-nspawn –volatile=no -b -D /srv/mycontainer

systemd-nspawn –volatile=state -b -D /srv/mycontainer

systemd-nspawn –volatile=yes -b -D /srv/mycontainer

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 41: Stateless Systems, Factory Reset, Golden Master Systems and

Updating

/usr can be updated offline

On next boot, /etc and /var are updated

ConditionNeedsUpdate=

ldconfig, sysusers, udev hwdb, . . .

All atomic

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 42: Stateless Systems, Factory Reset, Golden Master Systems and

Updating

/usr can be updated offline

On next boot, /etc and /var are updated

ConditionNeedsUpdate=

ldconfig, sysusers, udev hwdb, . . .

All atomic

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 43: Stateless Systems, Factory Reset, Golden Master Systems and

Updating

/usr can be updated offline

On next boot, /etc and /var are updated

ConditionNeedsUpdate=

ldconfig, sysusers, udev hwdb, . . .

All atomic

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 44: Stateless Systems, Factory Reset, Golden Master Systems and

Updating

/usr can be updated offline

On next boot, /etc and /var are updated

ConditionNeedsUpdate=

ldconfig, sysusers, udev hwdb, . . .

All atomic

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 45: Stateless Systems, Factory Reset, Golden Master Systems and

Updating

/usr can be updated offline

On next boot, /etc and /var are updated

ConditionNeedsUpdate=

ldconfig, sysusers, udev hwdb, . . .

All atomic

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 46: Stateless Systems, Factory Reset, Golden Master Systems and

Updating

/usr can be updated offline

On next boot, /etc and /var are updated

ConditionNeedsUpdate=

ldconfig, sysusers, udev hwdb, . . .

All atomic

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 47: Stateless Systems, Factory Reset, Golden Master Systems and

Double Buffering

Multiple /usr trees around!

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 48: Stateless Systems, Factory Reset, Golden Master Systems and

Double Buffering

Multiple /usr trees around!

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 49: Stateless Systems, Factory Reset, Golden Master Systems and

RPM?

Classic Distributions?

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 50: Stateless Systems, Factory Reset, Golden Master Systems and

Timeframe?

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 51: Stateless Systems, Factory Reset, Golden Master Systems and

Apps!

/usr: os, runtime, framework

/opt/appname: app

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 52: Stateless Systems, Factory Reset, Golden Master Systems and

Apps!

/usr: os, runtime, framework

/opt/appname: app

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 53: Stateless Systems, Factory Reset, Golden Master Systems and

Apps!

/usr: os, runtime, framework

/opt/appname: app

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 54: Stateless Systems, Factory Reset, Golden Master Systems and

OS: a /usr one can boot up a system with

Runtime: a /usr one can run executables against

Framework: a /usr one can build executables with

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 55: Stateless Systems, Factory Reset, Golden Master Systems and

OS: a /usr one can boot up a system with

Runtime: a /usr one can run executables against

Framework: a /usr one can build executables with

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 56: Stateless Systems, Factory Reset, Golden Master Systems and

OS: a /usr one can boot up a system with

Runtime: a /usr one can run executables against

Framework: a /usr one can build executables with

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 57: Stateless Systems, Factory Reset, Golden Master Systems and

OS, Runtime, Framework, Instance, Apps

All in multiple versions on the same system

btrfs subvolumes

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 58: Stateless Systems, Factory Reset, Golden Master Systems and

OS, Runtime, Framework, Instance, Apps

All in multiple versions on the same system

btrfs subvolumes

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 59: Stateless Systems, Factory Reset, Golden Master Systems and

OS, Runtime, Framework, Instance, Apps

All in multiple versions on the same system

btrfs subvolumes

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 60: Stateless Systems, Factory Reset, Golden Master Systems and

btrfs???

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 61: Stateless Systems, Factory Reset, Golden Master Systems and

Clear naming Scheme for subvolumes

usr:vendorid:architecture:version

root:name:vendorid:architecture

runtime:vendorid:architecture:version

framework:vendorid:architecture:version

app:vendorid:runtime:architecture:version

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 62: Stateless Systems, Factory Reset, Golden Master Systems and

Clear naming Scheme for subvolumes

usr:vendorid:architecture:version

root:name:vendorid:architecture

runtime:vendorid:architecture:version

framework:vendorid:architecture:version

app:vendorid:runtime:architecture:version

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 63: Stateless Systems, Factory Reset, Golden Master Systems and

Clear naming Scheme for subvolumes

usr:vendorid:architecture:version

root:name:vendorid:architecture

runtime:vendorid:architecture:version

framework:vendorid:architecture:version

app:vendorid:runtime:architecture:version

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 64: Stateless Systems, Factory Reset, Golden Master Systems and

Clear naming Scheme for subvolumes

usr:vendorid:architecture:version

root:name:vendorid:architecture

runtime:vendorid:architecture:version

framework:vendorid:architecture:version

app:vendorid:runtime:architecture:version

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 65: Stateless Systems, Factory Reset, Golden Master Systems and

Clear naming Scheme for subvolumes

usr:vendorid:architecture:version

root:name:vendorid:architecture

runtime:vendorid:architecture:version

framework:vendorid:architecture:version

app:vendorid:runtime:architecture:version

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 66: Stateless Systems, Factory Reset, Golden Master Systems and

Clear naming Scheme for subvolumes

usr:vendorid:architecture:version

root:name:vendorid:architecture

runtime:vendorid:architecture:version

framework:vendorid:architecture:version

app:vendorid:runtime:architecture:version

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 67: Stateless Systems, Factory Reset, Golden Master Systems and

Namespaces!

Dynamic views on the system, for containers and apps

Multiple root subvolumes sharing the same usr subvolume!

Multiple app subvolumes sharing the same runtime subvolume!

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 68: Stateless Systems, Factory Reset, Golden Master Systems and

Namespaces!

Dynamic views on the system, for containers and apps

Multiple root subvolumes sharing the same usr subvolume!

Multiple app subvolumes sharing the same runtime subvolume!

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 69: Stateless Systems, Factory Reset, Golden Master Systems and

Namespaces!

Dynamic views on the system, for containers and apps

Multiple root subvolumes sharing the same usr subvolume!

Multiple app subvolumes sharing the same runtime subvolume!

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 70: Stateless Systems, Factory Reset, Golden Master Systems and

Namespaces!

Dynamic views on the system, for containers and apps

Multiple root subvolumes sharing the same usr subvolume!

Multiple app subvolumes sharing the same runtime subvolume!

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 71: Stateless Systems, Factory Reset, Golden Master Systems and

Delivery:

btrfs send/recv deltas via http

Same for OS, runtimes, frameworks and apps

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 72: Stateless Systems, Factory Reset, Golden Master Systems and

Delivery:

btrfs send/recv deltas via http

Same for OS, runtimes, frameworks and apps

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 73: Stateless Systems, Factory Reset, Golden Master Systems and

Delivery:

btrfs send/recv deltas via http

Same for OS, runtimes, frameworks and apps

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 74: Stateless Systems, Factory Reset, Golden Master Systems and

OS installation:

1 Create GPT table with ESP + btrfs

2 Deserialize usr tree into btrfs

3 Install bootloader into ESP

4 Profit!

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 75: Stateless Systems, Factory Reset, Golden Master Systems and

OS installation:

1 Create GPT table with ESP + btrfs

2 Deserialize usr tree into btrfs

3 Install bootloader into ESP

4 Profit!

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 76: Stateless Systems, Factory Reset, Golden Master Systems and

OS installation:

1 Create GPT table with ESP + btrfs

2 Deserialize usr tree into btrfs

3 Install bootloader into ESP

4 Profit!

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 77: Stateless Systems, Factory Reset, Golden Master Systems and

OS installation:

1 Create GPT table with ESP + btrfs

2 Deserialize usr tree into btrfs

3 Install bootloader into ESP

4 Profit!

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 78: Stateless Systems, Factory Reset, Golden Master Systems and

OS installation:

1 Create GPT table with ESP + btrfs

2 Deserialize usr tree into btrfs

3 Install bootloader into ESP

4 Profit!

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 79: Stateless Systems, Factory Reset, Golden Master Systems and

http://0pointer.net/blog/projects/stateless.html

http://0pointer.net/blog/

revisiting-how-we-put-together-linux-systems.html

Stateless Systems, Factory Reset, Golden Master Systems and systemd

Page 80: Stateless Systems, Factory Reset, Golden Master Systems and

That’s all, folks!

Stateless Systems, Factory Reset, Golden Master Systems and systemd