1 |
Patrick McLean posted on Wed, 29 Jul 2015 15:35:02 -0700 as excerpted: |
2 |
|
3 |
> On Thu, 30 Jul 2015 01:11:30 +0300 Alon Bar-Lev <alonbl@g.o> |
4 |
> wrote: |
5 |
> |
6 |
>> On 29 July 2015 at 23:20, William Hubbs <williamh@g.o> wrote: |
7 |
>>> |
8 |
>>> so that there is a better idea out there of what I'm talking about, |
9 |
>>> the OpenRC github repository now has a mount-service branch. |
10 |
>> |
11 |
>> But I still trying to figure out why do we need to keep fstab around. |
12 |
>> It is pure legacy. |
13 |
>> |
14 |
>> |
15 |
> On what planet is fstab pure legacy? Many utilities use it and expect it |
16 |
> to exist. For example the ability to do "mount /foo" requires a properly |
17 |
> configured fstab file (also mount -a). |
18 |
> |
19 |
> AFAIK even systemd needs a fstab file if you want to do anything that |
20 |
> it can't autodetect by probing the system. |
21 |
|
22 |
Based on systemd documentation and experience... |
23 |
|
24 |
Systemd doesn't require an fstab file; its mount units are valid |
25 |
replacements. But systemd _does_ still recommend using fstab at least |
26 |
for normal admin-configured mounts, in preference to its own mount-unit |
27 |
alternative. So systemd doesn't consider fstab legacy. |
28 |
|
29 |
Systemd ships systemd-fstab-generator[1], which parses /etc/fstab and |
30 |
places its dynamically created mount units in /run/systemd/generator. |
31 |
It then uses these dynamically created *.mount units in combination with |
32 |
those it ships[2] and any others created either dynamically by other |
33 |
generators or by distros/other-packages or admins[3], instead of using |
34 |
/etc/fstab entries directly. |
35 |
|
36 |
But systemd's own docs still recommend using fstab in preference to its |
37 |
own mount units, at least for mounts designed for admin control[4]. |
38 |
According to the systemd.mount (5) manpage, first paragraph in the FSTAB |
39 |
section: |
40 |
|
41 |
>>>>> |
42 |
|
43 |
Mount units may either be configured via unit files, or via /etc/fstab |
44 |
(see fstab(5) for details). Mounts listed in /etc/fstab will be converted |
45 |
into native units dynamically at boot and when the configuration of the |
46 |
system manager is reloaded. In general, configuring mount points through |
47 |
/etc/fstab is the preferred approach. See systemd-fstab-generator(8) for |
48 |
details about the conversion. |
49 |
|
50 |
<<<<< |
51 |
|
52 |
So while fstab isn't actually _required_ on a systemd-managed system as |
53 |
its mount units offer the same functionality, its use is still |
54 |
"preferred", and fstab is therefore not considered legacy. |
55 |
|
56 |
|
57 |
And purely from a practical admin viewpoint, I can see see why... |
58 |
|
59 |
>> There can be a migration script to generate /etc/conf.d/* configuration |
60 |
>> once, but there is no need to keep it around. |
61 |
>> The conf.d can contain everything that fstab contains. |
62 |
>> |
63 |
>> mount_mountpoint_\${NAME}= |
64 |
>> mount_type_\${NAME}= |
65 |
>> mount_fs_\${NAME}= |
66 |
>> mount_opts_\${NAME}= |
67 |
>> mount_dump_\${NAME}= |
68 |
>> mount_pass_\${NAME}= |
69 |
>> |
70 |
>> |
71 |
> That's a mighty verbose format, especially compared to fstab. I don't |
72 |
> think we should force people to move away from fstab because we have a |
73 |
> new and shiny service system. |
74 |
|
75 |
... And that is _precisely_ _why_. =:^) |
76 |
|
77 |
Systemd's mount units may offer the same functionality, but they're far |
78 |
more verbose. Moreover the ratio is one fstab line per mount-unit file, |
79 |
with mount-unit files potentially scattered in three different locations |
80 |
in the file tree depending on their specific purpose and whether they're |
81 |
running as shipped or created/customized by the sysadmin. |
82 |
|
83 |
> Also if you are trying to get rid of "legacy" stuff, why on earth are |
84 |
> you keeping dump and pass around? Both of those are certainly not needed |
85 |
> if you are doing everything via services. |
86 |
|
87 |
Good point. The dump and pass fields are actually optional in fstab now |
88 |
days as well, with the defaults being 0 for both (don't dump and don't |
89 |
fsck), if the field isn't present. And if we're getting rid of fstab, |
90 |
anything using those fields will need code to handle some alternative |
91 |
config format anyway (if it doesn't have it already), so might as well |
92 |
simply drop the options from the mount config entirely, and let that |
93 |
separate config handle it. |
94 |
|
95 |
|
96 |
Meanwhile, if we're talking specific fstab replacement config format, no |
97 |
need to reinvent the wheel, we might as well simply adopt systemd's |
98 |
*.mount unit-file format as it covers all the bases, including |
99 |
compatibility. =:^) The systemd mount-unit fstab field parallels, |
100 |
according to the systemd.mount (5) manpage, Options section (quoting |
101 |
abridged excerpts): |
102 |
|
103 |
>>>>> |
104 |
|
105 |
Mount files must include a [Mount] section. The options specific to the |
106 |
[Mount] section of mount units are the following: |
107 |
|
108 |
What= |
109 |
|
110 |
[Mandatory: A]n absolute path of a device node, file or other resource to |
111 |
mount. |
112 |
|
113 |
Where= |
114 |
|
115 |
[Mandatory: A]n absolute path of a directory of the mount point. |
116 |
|
117 |
Type= |
118 |
|
119 |
[Optional: A] string for the file system type. |
120 |
|
121 |
Options= |
122 |
|
123 |
[Optional: O]ptions to use when mounting. This takes a comma-separated |
124 |
list of options. |
125 |
|
126 |
<<<<< |
127 |
|
128 |
That would be sufficient for an initial openrc implementation. Additional |
129 |
optional options that an initial openrc implementation could ignore |
130 |
include: |
131 |
|
132 |
SloppyOptions= |
133 |
|
134 |
Corresponds to mount's -s option, allowing unknown mount options. |
135 |
Defaults to off. |
136 |
|
137 |
DirectoryMode= |
138 |
|
139 |
Mountpoints (and parents) are created if they don't exist. This sets |
140 |
their (octal) mode. Default is 0755. |
141 |
|
142 |
TimeoutSec= |
143 |
|
144 |
Mount command timeout. If the mount command is still running after this |
145 |
time, it is SIGTERMed. If it's still running after this time elapses |
146 |
again, it is SIGKILLed. A unitless value is interpreted as seconds, or a |
147 |
time value such as "5min 20s" can be given. 0 disables the timeout |
148 |
entirely. Systemd sets the default at a higher config level, and openrc |
149 |
would presumably do so as well. |
150 |
|
151 |
|
152 |
Additionally, note that mount itself interprets both the nofail and noauto |
153 |
options from the fstab options field or -o commandline option, but an |
154 |
individualized mount service would have to parse them from the Options= |
155 |
line above, avoiding invoking mount with noauto, and ignoring mount |
156 |
failure with nofail. |
157 |
|
158 |
And finally, systemd acts on a number of otherwise systemd specific |
159 |
options out of the mount options field. Some of these are effectively |
160 |
systemd specific, but there are two specific dependency related options |
161 |
that it would be useful for openrc to act on as well, x-systemd.requires=, |
162 |
and xsystemd.requires-mounts-for=. Both of these take an absolute path |
163 |
and set systemd unit dependencies (Requires= and After= for requires, |
164 |
RequiresMountsFor= for that one) one way or the other between this mount |
165 |
unit and others. |
166 |
|
167 |
It's worth noting that were openrc to act on these fstab options field |
168 |
options as well, it would in doing so process fstab-configured |
169 |
dependencies, and there'd be far less need to have separate |
170 |
individualized service unit configuration, as dependencies could be |
171 |
specified directly in fstab. |
172 |
|
173 |
--- |
174 |
[1] systemd-fstab-generator: Installed on a normal systemd-managed system |
175 |
as /usr/lib/systemd/system-generators/systemd-fstab-generator. |
176 |
|
177 |
[2] Systemd shipped mount units: /usr/lib/systemd/system/var-run.mount, |
178 |
for instance, which conditionally bind-mounts /var/run to /run, only if |
179 |
/var/run already exists and isn't a symlink. |
180 |
|
181 |
[3] Distro/package shipped mount units, as other distro/package shipped |
182 |
units, will be installed as /usr/lib/systemd/system/*.mount, while admin- |
183 |
created units should be created as /etc/systemd/system/*.mount. |
184 |
|
185 |
[4] Mounts designed for admin control: as opposed to automated mounts |
186 |
like the one mentioned in [2], that aren't intended for admin control, |
187 |
with some of them part of the systemd API and thus with limited override |
188 |
ability even via the usual /etc/systemd/system/ override location, |
189 |
according to the manpage. |
190 |
|
191 |
|
192 |
-- |
193 |
Duncan - List replies preferred. No HTML msgs. |
194 |
"Every nonfree program has a lord, a master -- |
195 |
and if you use the program, he is your master." Richard Stallman |