You are not logged in.

#1 2015-05-26 04:02:47

zackpete
Member
Registered: 2011-04-27
Posts: 9

[SOLVED] Run a snapshot root directory

I would like to set up booting into a root partition that doesn't persist filesystem changes after a reboot (similar to how the Arch install live ISO acts, and Deep Freeze on Windows) I'm using this outline as a guide for creating a snapshot with device mapper. [Edit: I figured it out, if anyone else wants to do it, here's how:]

Create build hook for mkinitcpio [ /usr/lib/initcpio/install/freeze ]

#!/bin/bash

build()
{
    add_binary "blockdev"
    add_runscript
}

Create runtime hook for mkinitcpio [ /usr/lib/initcpio/hooks/freeze ]
<block_device> is where you want the temporary changes to be written. If it runs out of space, weird things happen.

#!/usr/bin/ash

run_hook()
{
    dmsetup create frozenroot --table "0 `blockdev --getsz <root_partition>` snapshot <root_partition> <block_device> N 1" 
}

Edit /etc/mkinitcpio.conf
Add lvm2 and freeze to HOOKS before filesystems

...
HOOKS="base udev autodetect modconf block lvm2 freeze filesystems keyboard fsck"
...

Rebuild the initramfs

$ mkinitcpio -p linux

Change the root kernel parameter in the bootloader configuration

...
APPEND root=/dev/mapper/frozenroot
...

Last edited by zackpete (2015-05-28 04:52:29)

Offline

Board footer

Powered by FluxBB