Debian Codegraph @

doc/source/example_use_cases/custom_fstab_extension.rst

raw
1 .. _custom_fstab_extension:
2
3 Add or Update the Fstab File
4 ============================
5
6 .. sidebar:: Abstract
7
8 This page provides further information for customizing
9 the `/etc/fstab` file which controls the mounting of
10 filesystems at boot time.
11
12 In {kiwi}, all major filesystems that were created at image
13 build time are handled by {kiwi} itself and setup in `/etc/fstab`.
14 Thus there is usually no need to add entries or change the
15 ones added by {kiwi}. However depending on where the image is
16 deployed later it might be required to pre-populate fstab
17 entries that are unknown at the time the image is built.
18
19 Possible use cases are for example:
20
21 * Adding NFS locations that should be mounted at boot time.
22 Using autofs would be an alternative to avoid additional
23 entries to fstab. The information about the NFS location
24 will make this image specific to the target network. This
25 will be independent of the mount method, either fstab or
26 the automount map has to provide it.
27
28 * Adding or changing entries in a read-only root system
29 which becomes effective on first boot but can't be added
30 at that time because of the read-only characteristics.
31
32 .. note::
33
34 Modifications to the fstab file are a critical change. If
35 done wrongly the risk exists that the system will not boot.
36 In addition this type of modification makes the image
37 specific to its target and creates a dependency to the
38 target hardware, network, etc... Thus this feature should
39 be used with care.
40
41 The optimal way to provide custom fstab information is through a
42 package. If this can't be done the files can also be provided via
43 the overlay file tree of the image description.
44
45 {kiwi} supports three ways to modify the contents of the `/etc/fstab`
46 file:
47
48 Providing an `/etc/fstab.append` file
49 If that file exists in the image root tree, {kiwi} will take its
50 contents and append it to the existing `/etc/fstab` file. The
51 provided `/etc/fstab.append` file will be deleted after successful
52 modification.
53
54 Providing an `/etc/fstab.patch` file
55 The `/etc/fstab.patch` represents a patch file that will be
56 applied to `/etc/fstab` using the `patch` program. This method
57 also allows to change the existing contents of `/etc/fstab`.
58 On success `/etc/fstab.patch` will be deleted.
59
60 Providing an `/etc/fstab.script` file
61 The `/etc/fstab.script` represents an executable which is called
62 as chrooted process. This method is the most flexible one and
63 allows to apply any change. On success `/etc/fstab.script` will be
64 deleted.
65
66 .. note::
67
68 All three variants to handle the fstab file can be used together.
69 Appending happens first, patching afterwards and the script call
70 is last. When using the script call, there is no validation that
71 checks if the script actually handles fstab or any other
72 file in the image rootfs.