====== OverlayFS ====== ===== Installation ===== $ sudo apt-get install overlayroot ===== Configuration ===== Sur une Ubuntu 14.04: $ sudo vim /etc/overlayroot.conf (...) overlayroot_cfgdisk="disabled" overlayroot="tmpfs,recurse=0" Sur une Ubuntu 16.04, j'ai du activer le SWAP pour que ça fonctionne : $ sudo vim /etc/overlayroot.conf (...) overlayroot_cfgdisk="disabled" overlayroot="tmpfs:swap=1,recurse=0" Après avoir modifié le fichier ''overlayroot.conf'', on redémarre : $ sudo reboot Après un redémarrage (sur Ubuntu 16.04) : {{ ::2016-10-26_23-23-58_read-only.png?300 |}} ===== Investigations en cas de problèmes ===== Pour vérifier que le module du kernel, ''overlay'' est bien chargé : $ lsmod | grep overlay overlay 49152 0 Si la commande précédente ne renvoie rien, on peut forcer le chargement du module avec [[:modprobe]]: $ sudo modprobe overlay (La commande [[:modprobe]] ne renvoie rien si tout se passe bien.) $ modinfo overlay filename: /lib/modules/4.4.0-45-generic/kernel/fs/overlayfs/overlay.ko alias: overlayfs alias: fs-overlayfs alias: fs-overlay license: GPL description: Overlay filesystem author: Miklos Szeredi srcversion: 50CE13FCD67769FE3D7357F depends: intree: Y vermagic: 4.4.0-45-generic SMP mod_unload modversions Normalement, le module ''overlay'' est chargé en cas de besoin. Pour que le chargement du module ''overlay'' soit forcé au boot, il faut l'ajouter au fichier ''/etc/modules'' : $ sudo vim /etc/modules $ sudo cat /etc/modules # /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with "#" are ignored. overlay ===== Vérifications ===== On peut vérifier dans /etc/fstab et /etc/mtab les changements : $ cat /etc/mtab overlayroot / overlayfs rw,errors=remount-ro 0 0 proc /proc proc rw,noexec,nosuid,nodev 0 0 sysfs /sys sysfs rw,noexec,nosuid,nodev 0 0 none /sys/fs/cgroup tmpfs rw 0 0 none /sys/fs/fuse/connections fusectl rw 0 0 none /sys/kernel/debug debugfs rw 0 0 none /sys/kernel/security securityfs rw 0 0 udev /dev devtmpfs rw,mode=0755 0 0 devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=0620 0 0 tmpfs /run tmpfs rw,noexec,nosuid,size=10%,mode=0755 0 0 none /run/lock tmpfs rw,noexec,nosuid,nodev,size=5242880 0 0 none /run/shm tmpfs rw,nosuid,nodev 0 0 none /run/user tmpfs rw,noexec,nosuid,nodev,size=104857600,mode=0755 0 0 none /sys/fs/pstore pstore rw 0 0 /dev/sda1 /media/root-ro ext2 rw,relatime 0 0 tmpfs-root /media/root-rw tmpfs rw,relatime 0 0 /dev/sda6 /media/data vfat rw,utf8,umask=007,gid=46 0 0 systemd /sys/fs/cgroup/systemd cgroup rw,noexec,nosuid,nodev,none,name=systemd 0 0 gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,user=alx 0 0 /proc /media/root-ro/proc none rw,bind 0 0 /run /media/root-ro/run none rw,bind 0 0 /sys /media/root-ro/sys none rw,bind 0 0 $ cat /etc/fstab # # This fstab is in an overlayfs. The real one can be found at # /media/root-ro/etc/fstab # The original entry for '/' and other mounts have been updated to be placed # under /media/root-ro. # To permanently modify this (or any other file), you should change-root into # a writable view of the underlying filesystem using: # sudo overlayroot-chroot # # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # # / was on /dev/sda1 during installation #bkp: UUID=23568d1b-88a5-4a9e-83cb-d97fdfcf57de / ext2 errors=remount-ro 0 1 # /media/data was on /dev/sda6 during installation UUID=1851-AC68 /media/data vfat utf8,umask=007,gid=46 0 1 # swap was on /dev/sda5 during installation UUID=037cea84-169f-4fd6-a56a-97994591af17 none swap sw 0 0 ===== Désactiver Overlayroot ===== Pour accéder à la partition racine réellement et pouvoir la modifier malgré Overlayroot, il faut utiliser cette commande : $ sudo overlayroot-chroot root@ordi:/# #faire ce qu'on veut (mise à jour, modification de fichiers, ...) root@ordi:/# exit Pour désactiver OverlayFS, on modifie le fichier de configuration dans le chroot et on redémarre : alx@systems:~$ sudo overlayroot-chroot [sudo] password for alx: INFO: Chrooting into [/media/root-ro] root@systems:/# vim /etc.overlayroot.conf (...) overlayroot="" #overlayroot="tmpfs:swap=1,recurse=0" (...) root@systems:/# exit exit alx@systems:~$ sudo reboot ===== Réactiver overlayfs ===== alx@systems:~$ sudo vim /etc/overlayroot.conf (...) #overlayroot="" overlayroot="tmpfs:swap=1,recurse=0" (...) alx@systems:~$ sudo reboot ===== Problèmes de réseau ===== J'ai eu des problème avec "AppArmor" et le réseau ne fonctionnait pas quand overlayroot était actif. J'ai simplement supprimé "AppArmor" alx@systems:~$ sudo overlayroot-chroot [sudo] password for alx: INFO: Chrooting into [/media/root-ro] root@systems:/# apt-get remove --purge apparmor root@systems:/# exit exit alx@systems:~$ sudo reboot ===== Sources ===== * [[http://www.blaess.fr/christophe/2014/12/14/le-systeme-overlayfs-de-linux-3-18/| Très bonnes explications sur OverlayFS (blaess.fr)]] * [[https://spin.atomicobject.com/2015/03/10/protecting-ubuntu-root-filesystem/|tutoriel que j'ai utilisé (spin.atomicobject.com)]]