1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Saving a session back to the boot device (or even somewhere else)</title>
<!-- (en) Add your meta data here -->
<link href="css/larchdocs.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 7]>
<link href="css/yaml/core/iehacks.css" rel="stylesheet" type="text/css" />
<![endif]-->
</head>
<body>
<!-- skip link navigation -->
<ul id="skiplinks">
<li><a class="skip" href="#col1">Skip to main content (Press Enter).</a></li>
</ul>
<div class="page_margins">
<div class="page">
<div id="top"><div id="tm"></div></div>
<!-- begin: #col1 -->
<div id="col1" role="main">
<div id="col1_content">
<div id="header" role="banner">
<h1><span><em>live Arch Linux</em> builder</span></h1>
</div>
<!-- begin: #col3 navigation column -->
<div id="col3" role="complementary">
<div id="col3_content">
<img class="indent2" alt="larch logo" src="css/screen/larch150x.png" width="150" height="150" />
<div class="vlist">
<ul>
<li><a href="index.html"><h6>Table Of Contents</h6></a></li>
<li><a href="larch_ssh.html"><h6>Next:</h6>
<div class="indent1">ssh access</div></a></li>
<li><a href="larch_live_system.html"><h6>Previous:</h6>
<div class="indent1">Structure of a larch live system</div></a></li>
</ul>
</div>
</div>
</div>
<!-- end: #col3 -->
<div class="larchdocs">
<h2 id="pagetitle" level="1">Saving a session back to the boot device (or even somewhere else)</h2>
<p>An easy way to create a customized <em>live</em> system is to start from an
existing one, make whatever changes you like, and then save the result back to
the boot device. Of course, for this you need a writeable boot device, e.g.
a USB-stick.
</p>
<h3><a name="overlays"></a>Overlay archives</h3>
<p>In <em>larch</em> the uppermost layer in the union file-system is in
<em>tmpfs</em> and can (optionally) be saved at shutdown to the boot medium.
It is <em>compressed</em> using <em>tar</em> and <em>lzop</em> to the file
'overlay.tar.lzo'. When the system next boots this file will then be
unpacked into the initially empty top layer.
</p>
<p>This is handled primarily by the 'shutdown2' script, supplied in the
'larch-live' package. It is called from a hook function in 'etc/rc.shutdown'.
If the medium is writeable and contains a file 'larch/save', the user is
offered the possibility of saving this overlay archive, thus saving the
current state.
</p>
<p>When this archive grows too large it will reduce the amount of available
memory, perhaps to an unacceptable extent.
It will also lengthen boot and shutdown times.
To counter this, it is possible to merge the
overlay archive with the middle (<em>squashfs</em>) <em>union</em> layer,
<strong>mods.sqf</strong> (which is normally not copied to memory),
thus restoring the rapid load and save times for <strong>overlay.tar.lzo</strong>,
and maximizing the available memory. I call this process
'overlay merging', and it is offered as a shutdown option. The script
'merge_overlay' (in the 'larch-live' package) provides this facility.
It takes longer to execute than a normal session save, so it should probably
not be used for every session saving operation, but just when the top overlay
gets too big. Note that use of the overlay merging feature creates an
additional layer in the <em>union</em>, 'filter.sqf'. This contains only
'whiteout' files to cover up overwritten data in the underlying 'system.sqf'.
Unlike in previous <em>larch</em> versions the 'mods.sqf' archive contains
no 'whiteouts'. It is hoped that this new structure will cure the
problems experienced in these earlier versions.
</p>
<h3><a name="var_files"></a>Special places in /var</h3>
<p>It was considered undesirable to include some things in the '/var' directory
in the session saves, primarily because of the space they occupy. Firstly,
the standard <em>pacman</em> package cache, '/var/cache/pacman/pkg' - if you
do want to save your cache, you should either handle this manually or set
up another location using 'CacheDir' in /etc/pacman.conf'. Also the log files
(in '/var/log') and '/var/tmp' (temporary files, like '/tmp') are not saved.
</p>
<h3><a name="upd_packages"></a>Updating packages</h3>
<p>It is possible to perform package addition and removal in the <em>live</em>
system, but one should be aware that packages in the base system are not actually
replaced, just (effectively) hidden, so that the space usage might become a
consideration. Also the handling of kernel updates must be handled in a special
way, because it is stored outside the root file-system, on the boot medium
and needs a separate mechanism to save it at shutdown. It should be fairly
transparent to the user, but under certain circumstances it might be necessary
to bear this in mind.
</p>
<p>At some point, after extensive updating, it might be desirable to completely
<a href="larch_rebuild.html">rebuild the system</a>, so that also
'system.sqf' is recreated. This will require quite a bit of space,
but should otherwise pose no great problems.
</p>
<h3><a name="de-Act"></a>Activating and deactivating the session-saving feature</h3>
<p>As mentioned above, for this feature to be available, there must be a
file with the name 'save' in the boot medium's 'larch' directory. This
will be generated automatically if installing to a partition (i.e. if not
building an <em>iso</em>) and if there is no 'nosave' file in the profile.
The gui provides a button to create and delete this 'nosave' file,
thus disabling or enabling session saving on the created medium.
</p>
<h3><a name="custom"></a>Customizing the behaviour using scripts</h3>
<p>Some aspects of the session saving can be customized by writing scripts to
override the default behaviour. These scripts are (in general) kept on the boot
medium, in the 'larch' directory. As these are shell scripts and their use requires
some knowledge of the inner workings of the <em>larch live </em>system, it will
almost certainly be necessary to read the existing <em>larch</em> scripts where the
custom scripts are 'sourced' if you want to
write your own scripts to change the behaviour of the <em>live</em> system in
this respect. All these scripts are found in the 'larch-live' package.
</p>
<ul>
<li><strong>session-save0</strong>
<p>Used in <strong>session-save/shutdown2</strong> (in function 'checkse').
This script can be used to customize the creation of the new overlay
archive, e.g. by specifying a new location. The default is
'overlay.tar.lzo' on the boot medium.
</p>
</li>
<li><strong>save-menu</strong>
<p>Used in <strong>session-save/shutdown2</strong> (in function
'session-save'). This script can be used to further customize the creation
of the new overlay archive, e.g. by providing an alternative session save
menu. Note that if the <strong>session-save0</strong> script specified
an alternative device path for saving the overlay, this script will be
sought in the 'larch' directory on that path.
</p>
</li>
<li><a name="boot-init"></a><strong>boot-init</strong>
<p>In initramfs hook <strong>larch3</strong>. This script allows adjustment of
the overlay handling during the boot process, e.g. getting them from another
path.
Note that the shell environment here is that of the initramfs and thus
very limited.
</p>
</li>
</ul>
</div>
<div class="topref"><a href="#top">Top</a></div>
</div>
<!-- begin: #footer -->
<div id="footer">
<div id="footer-content" role="contentinfo">© 2010 Michael Towers<br />
Page layout assisted by <a href="http://www.yaml.de/">YAML</a> and
<a href="http://www.kuwata-lab.com/tenjin/">pyTenjin</a>
</div>
</div>
<!-- end: #footer -->
</div>
<!-- end: #col1 -->
<div id="bottom"><div id="bl"><div id="bm"></div></div></div>
</div>
</div>
<!-- full skiplink functionality in webkit browsers -->
<script src="css/yaml/core/js/webkit-focusfix.js" type="text/javascript"></script>
</body>
</html>
|