[Petter Reinholdtsen] > A more complete script would ensure /proc/, /sys/ and /dev/ are > mounted from the system, to allow for example java to figure out what > CPU is used. It should also be used with some care, as packages like > grub might change the disk images outside the snapshot and thus affect > the real system instead of the snapshot.
The OpenSuse news reference Leen posted today mentioned an interesting variation of my upgrade in a snapshot first idea that I decided to try out today. Instead of testing the upgrade in a snapshot, one can snapshot the file systems before the upgrade and thus make it possible to switch back to a working setup if the upgrade was unsuccessful. It is less robust and harder to clean up than the "upgrade in a snapshot first" approach, but it is easier to implement. So I made a draft Debian package btrfs-aptkeeper inspired by etckeeper to test the idea, and the result can be seen on <URL: http://anonscm.debian.org/cgit/collab-maint/btrfs-aptkeeper.git >. Here is a test run installing rwho (random package I knew would not pull in too many dependencies) with the new btrfs-aptkeeper package in place: root@freedombox:~# apt-get install rwho Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: rwhod The following NEW packages will be installed: rwho rwhod 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 31.6 kB of archives. After this operation, 138 kB of additional disk space will be used. Do you want to continue? [Y/n] Get:1 http://http.debian.net/debian/ unstable/main rwhod i386 0.17-13 [18.3 kB] Get:2 http://http.debian.net/debian/ unstable/main rwho i386 0.17-13 [13.2 kB] Fetched 31.6 kB in 2s (11.2 kB/s) creating btrfs snapshot aptkeeper-@--2014-11-24T19:17:11 before installing packages Create a snapshot of '/' in '/btrfs/aptkeeper-@--2014-11-24T19:17:11' [master 404ca06] saving uncommitted changes in /etc prior to apt run Author: fbx <fbx@freedombox> 2 files changed, 1 insertion(+), 2 deletions(-) rename apt/{conf.d => apt.conf.d}/02btrfs-aptkeeper (100%) Selecting previously unselected package rwhod. (Reading database ... 60304 files and directories currently installed.) Preparing to unpack .../rwhod_0.17-13_i386.deb ... Unpacking rwhod (0.17-13) ... Selecting previously unselected package rwho. Preparing to unpack .../archives/rwho_0.17-13_i386.deb ... Unpacking rwho (0.17-13) ... Processing triggers for man-db (2.7.0.2-3) ... Setting up rwhod (0.17-13) ... Setting up rwho (0.17-13) ... [master d11f89a] committing changes in /etc after apt run Author: fbx <fbx@freedombox> 19 files changed, 97 insertions(+) create mode 100755 cron.monthly/rwhod create mode 100644 default/rwhod create mode 100755 init.d/rwhod create mode 120000 rc0.d/K01rwhod create mode 120000 rc1.d/K01rwhod create mode 120000 rc2.d/S02rwhod create mode 120000 rc3.d/S02rwhod create mode 120000 rc4.d/S02rwhod create mode 120000 rc5.d/S02rwhod create mode 120000 rc6.d/K01rwhod ====== How can you help? (doc: https://wiki.debian.org/how-can-i-help ) ====== ----- Show old opportunities as well as new ones: how-can-i-help --old ----- root@freedombox:~# I plan to change the snapshot naming system to be more like zfsnap, and store enough information in the snapshot names to know when to purge them without any manual intervention. Anyone know how to figure out how much space a btrfs snapshot uses? I would like something like 'zfs list -t snapshot' for btrfs, to test an idea about flushing/removing snapshots before the upgrade when snapshots take up too much space before an upgrade. Some cleanup method seem to be needed, as this happened later in the testing when I tried to get rid of the rwho packages again: root@freedombox:~# apt-get purge rwhod rwho Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: rwho* rwhod* 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded. After this operation, 138 kB disk space will be freed. Do you want to continue? [Y/n] creating btrfs snapshot aptkeeper-@--2014-11-24T21:16:08 before installing packages Create a snapshot of '/' in '/btrfs/aptkeeper-@--2014-11-24T21:16:08' ERROR: cannot snapshot '/' - No space left on device E: Problem executing scripts DPkg::Pre-Invoke 'if [ -x /usr/lib/btrfs-aptkeeper/btrfs-aptkeeper ]; then /usr/lib/btrfs-aptkeeper/btrfs-aptkeeper pre-install; fi' E: Sub-process returned an error code root@freedombox:~# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 2.8G 1.9G 886M 69% / udev 10M 0 10M 0% /dev tmpfs 101M 4.5M 96M 5% /run tmpfs 251M 0 251M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 251M 0 251M 0% /sys/fs/cgroup tmpfs 251M 0 251M 0% /tmp /dev/vda1 2.8G 1.9G 886M 69% /btrfs tmpfs 51M 0 51M 0% /run/user/113 tmpfs 51M 0 51M 0% /run/user/1000 root@freedombox:~# btrfs balance start / ERROR: error during balancing '/' - No space left on device There may be more info in syslog - try dmesg | tail root@freedombox:~# dmesg | tail [ 156.128842] random: nonblocking pool is initialized [ 361.018447] 8139cp 0000:00:03.0 eth0: link up, 100Mbps, full-duplex, lpa 0x05E1 [ 361.934025] ip_tables: (C) 2000-2006 Netfilter Core Team [ 361.961361] nf_conntrack version 0.5.0 (8010 buckets, 32040 max) [ 361.977762] ip6_tables: (C) 2000-2006 Netfilter Core Team [ 362.015188] Ebtables v2.0 registered [ 362.021687] Bridge firewalling registered [42520.196369] [sched_delayed] sched: RT throttling activated [80824.227896] BTRFS info (device vda1): 14 enospc errors during balance [80860.981474] BTRFS info (device vda1): 14 enospc errors during balance root@freedombox:~# The situation improved after I removed some snapshots. -- Happy hacking Petter Reinholdtsen _______________________________________________ Freedombox-discuss mailing list Freedombox-discuss@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/freedombox-discuss