From nobody Fri Jun 5 11:18:07 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gWzSb62Ssz6gtYh for ; Fri, 05 Jun 2026 11:18:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gWzSb3tZPz3vnn for ; Fri, 05 Jun 2026 11:18:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780658287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4aYVUrlGetXf+ccx9yqt1E/drI0m78YKU/0C4GDzsaY=; b=WNgDmCaImY5wv0um5D2GtyGvrcn41IF1MaQUxO+DEcz3rQ3fyd0HIg3lLFpORVdK+TjBwm yIpPA35UdQB6vxMPdgSWSleooRSNX1nkQ+aeap7NUIbYTrJkY5RJBvqkQu/l6xTVxcFzJQ avQ4YhIIw5w4LU1ZwsvhkB/mIS7sN/7R5j1PX2q0H9u8pQa5CKXTCvPM8bxf333qTglZMS M91xE3OW12R+xJM80Uj8Y77EacqkS1iPR7oa9MssCQskQAnTYHO9FAlbB+C8fl/zsfLwWR JXoFgmygUDm9P3n+hizjsLTN3w5GSrkxUYXZ5Uh8TE9E+7+yWh/ybxb6W7r2CA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780658287; a=rsa-sha256; cv=none; b=hwfhLewv5drV5G85JaQnsyW7ZM12j8RZZWiqI+LJoK+z5OvUFm3YR3wBrG6/b//QAakr75 qiJYB7jz1CE0+tgZLTuZLhoB8CllA61/z/e0jU3VtovEmp6jUrhSn4tx22AVNL1L4pM/Zn C+qUxAX3z+vAaHEWSOfzqfq8LyxNTLiM+vuDZ2LGHSpUSJYot4ZuGv5D9xCeTy/mF3fpOm 9+IBkAAyE60LutEuyIwtPaARE7JTxbqfPrRVz2cQ58GV/n4yFdEIytIA8isYTwQh1+XFIK 2QxwsSQJBZqO2zmpJqnCkbatgit1Sfg8i0O5a39TQbJwOGzRr+4j3AjQTbs8Jg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780658287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4aYVUrlGetXf+ccx9yqt1E/drI0m78YKU/0C4GDzsaY=; b=vPcrkqZ8idIuncD/Lnw2is21Qn/Hd7Uf3ex2k02T5GTqTGAHbzwSgNllFA7x0NXVsAY2cz 7uAtY7qqAHBw1auWTaA9tiy66p5XmIscTgAwy87kElW0RPUBtvdBs0AJ+MpShl98lWWAP0 vOv2nes3RrJh3eJ8XRqDU+/G6/RCyNGQPRLiiSwny8tw+Ijn+T56oOmUPzpXqIUVDum/Yy PUsyVXqKp2DCAon4iCl3WspPyKNihW3u+NpLBjUDymW9oItedYho2xxgzslmAraWX4izAz e9KoAzHj7vq8uS3kAvVgnqfX12aM7+6uMcvHS5MUwbpp/S7dkm+VG+yju7mtIA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gWzSb39WyzBkb for ; Fri, 05 Jun 2026 11:18:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1ef54 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 05 Jun 2026 11:18:07 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 797dad91ff46 - main - nuageinit: implement mounts support List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 797dad91ff468a9bd6cd5d4f720eb4bbac1f454a Auto-Submitted: auto-generated Date: Fri, 05 Jun 2026 11:18:07 +0000 Message-Id: <6a22b06f.1ef54.50c7c1cc@gitrepo.freebsd.org> The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=797dad91ff468a9bd6cd5d4f720eb4bbac1f454a commit 797dad91ff468a9bd6cd5d4f720eb4bbac1f454a Author: Baptiste Daroussin AuthorDate: 2026-06-05 10:05:08 +0000 Commit: Baptiste Daroussin CommitDate: 2026-06-05 11:15:16 +0000 nuageinit: implement mounts support Add support for the 'mounts' cloud-config key which configures mount points by appending entries to /etc/fstab and creating the corresponding directories. --- libexec/nuageinit/nuage.lua | 48 +++++++++++++++++++++++++++++++++++- libexec/nuageinit/nuageinit | 33 +++++++++++++++++++++++++ libexec/nuageinit/nuageinit.7 | 36 +++++++++++++++++++++++++++ libexec/nuageinit/tests/nuageinit.sh | 28 +++++++++++++++++++++ 4 files changed, 144 insertions(+), 1 deletion(-) diff --git a/libexec/nuageinit/nuage.lua b/libexec/nuageinit/nuage.lua index 45e14ef0ce21..34cf8c9fc090 100644 --- a/libexec/nuageinit/nuage.lua +++ b/libexec/nuageinit/nuage.lua @@ -821,6 +821,50 @@ local function addfile(file, defer) return true end +local function add_fstab_entry(root, device, mount_point, fstype, options, dump_freq, passno) + local fstab_path = root .. "/etc/fstab" + local f = io.open(fstab_path, "a") + if not f then + warnmsg("unable to open " .. fstab_path .. " for writing") + return false + end + options = options or "rw" + dump_freq = dump_freq or 0 + passno = passno or 0 + f:write(string.format("%s\t\t%s\t\t%s\t\t%s\t\t%d\t\t%d\n", + device, mount_point, fstype, options, dump_freq, passno)) + f:close() + return true +end + +local function remove_fstab_entry(root, mount_point) + local fstab_path = root .. "/etc/fstab" + local f = io.open(fstab_path, "r") + if not f then + return + end + local lines = {} + for line in f:lines() do + local fields = {} + for field in line:gmatch("%S+") do + table.insert(fields, field) + end + if fields[2] ~= mount_point then + table.insert(lines, line) + end + end + f:close() + local nf = io.open(fstab_path, "w") + if not nf then + warnmsg("unable to open " .. fstab_path .. " for writing") + return + end + for _, line in ipairs(lines) do + nf:write(line .. "\n") + end + nf:close() +end + local n = { shell_escape = shell_escape, warn = warnmsg, @@ -844,7 +888,9 @@ local n = { upgrade_packages = upgrade_packages, addsudo = addsudo, adddoas = adddoas, - addfile = addfile + addfile = addfile, + add_fstab_entry = add_fstab_entry, + remove_fstab_entry = remove_fstab_entry, } return n diff --git a/libexec/nuageinit/nuageinit b/libexec/nuageinit/nuageinit index 9d2f3c6024c4..f56d1207cf01 100755 --- a/libexec/nuageinit/nuageinit +++ b/libexec/nuageinit/nuageinit @@ -531,6 +531,38 @@ local function disable_root(obj) end end +local function mounts(obj) + if obj.mounts == nil then return end + for _, m in ipairs(obj.mounts) do + local device, mount_point, fstype, options, dump_freq, passno + if type(m) == "table" then + if m[1] then + -- List format: [device, mount_point, fstype, options, dump_freq, passno] + device = m[1] + mount_point = m[2] + fstype = m[3] + options = m[4] + dump_freq = tonumber(m[5]) or 0 + passno = tonumber(m[6]) or 0 + else + -- Dict format + device = m.name or m.device or m.spec + mount_point = m.mount_point or m.mountpoint + fstype = m.type or m.filesystem or m.fstype + options = m.options or m.opts + dump_freq = tonumber(m.dump) or 0 + passno = tonumber(m.passno) or tonumber(m.pass_no) or 0 + end + end + if device and mount_point and fstype then + nuage.mkdir_p(root .. mount_point) + nuage.add_fstab_entry(root, device, mount_point, fstype, options, dump_freq, passno) + else + warnmsg("Invalid mount entry, skipping") + end + end +end + local function bootcmd(obj) if obj.bootcmd == nil then return end local f = nil @@ -828,6 +860,7 @@ if line == nil then -- YAML user-data elseif line == "#cloud-config" then local pre_network_calls = { + mounts, bootcmd, sethostname, manage_etc_hosts, diff --git a/libexec/nuageinit/nuageinit.7 b/libexec/nuageinit/nuageinit.7 index 66a72324f414..c2981669acb7 100644 --- a/libexec/nuageinit/nuageinit.7 +++ b/libexec/nuageinit/nuageinit.7 @@ -159,6 +159,42 @@ Defaults to Set to .Ar false to skip this behaviour. +.It Ic mounts +A list of mount points to configure. +Each entry is written to +.Pa /etc/fstab +and the mount point directory is created. +.Pp +Each entry can be specified as a list: +.Bd -literal -offset indent +[ device, mountpoint, fstype ] +.Ed +.Pp +or as an object: +.Bd -literal -offset indent +{ device: "...", mountpoint: "...", type: "...", options: "..." } +.Ed +.Pp +The following keys are recognized: +.Bl -tag -width "options" +.It device (or name, spec) +The device to mount. +.It mountpoint (or mount_point) +The mount point directory. +.It type (or fstype, filesystem) +The filesystem type. +.It options (or opts) +The mount options, defaults to +.Qq rw . +.It dump +The dump frequency for +.Xr dump 8 , +defaults to 0. +.It passno +The pass number for +.Xr fsck 8 , +defaults to 0. +.El .It Ic timezone Sets the system timezone based on the value provided. .Pp diff --git a/libexec/nuageinit/tests/nuageinit.sh b/libexec/nuageinit/tests/nuageinit.sh index ac7086183d86..11d34fcd98ea 100644 --- a/libexec/nuageinit/tests/nuageinit.sh +++ b/libexec/nuageinit/tests/nuageinit.sh @@ -34,6 +34,7 @@ atf_test_case config2_userdata_ssh_deletekeys atf_test_case config2_userdata_disable_root atf_test_case config2_userdata_bootcmd atf_test_case config2_userdata_manage_etc_hosts +atf_test_case config2_userdata_mounts atf_test_case config2_userdata_fqdn_and_hostname atf_test_case config2_userdata_write_files @@ -1113,6 +1114,32 @@ EOF atf_check -o inline:"::1\t\tlocalhost\n127.0.0.1\t\tlocalhost\n" cat etc/hosts } +config2_userdata_mounts_head() +{ + atf_set "require.user" root +} +config2_userdata_mounts_body() +{ + mkdir -p media/nuageinit + setup_test_adduser + printf "{}" > media/nuageinit/meta_data.json + cat > media/nuageinit/user_data <