diff options
author | Andrew Cady <d@jerkface.net> | 2019-06-18 17:50:05 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2019-06-18 17:50:05 -0400 |
commit | c22f537987c966c7dfa541833a074f85a8b03d45 (patch) | |
tree | d7e08b042bcc87e284923d7bb09705f59d09b45b /fsmgr.hs | |
parent | 0f3173f383af4c1e464a4e47cb00b5a5387569aa (diff) |
save snapshot of unmodified root before first mount
Diffstat (limited to 'fsmgr.hs')
-rw-r--r-- | fsmgr.hs | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -85,6 +85,12 @@ buildRoot DiskImageConfig{..} finalOut = do | |||
85 | {- 4. custom setup commands -} | 85 | {- 4. custom setup commands -} |
86 | forM_ chrootCommands $ \c -> do | 86 | forM_ chrootCommands $ \c -> do |
87 | cmd_ "chroot" [mountpoint] "/bin/sh -c" [unpack c] | 87 | cmd_ "chroot" [mountpoint] "/bin/sh -c" [unpack c] |
88 | {- 5. create a backup snapshot -} | ||
89 | cmd_ "umount" [mountpoint] | ||
90 | cmd_ "mount -t btrfs -o subvol=/" [out, mountpoint] | ||
91 | flip actionCatch (\(SomeException _) -> return ()) $ cmd_ "btrfs subvolume delete" [mountpoint </> "root~orig"] | ||
92 | cmd_ "btrfs subvolume snapshot -r" [mountpoint </> "root", mountpoint </> "root~orig"] | ||
93 | |||
88 | -- cleanup | 94 | -- cleanup |
89 | cmd_ "umount" [mountpoint] | 95 | cmd_ "umount" [mountpoint] |
90 | cmd_ "rmdir" [mountpoint] | 96 | cmd_ "rmdir" [mountpoint] |