1
// This Source Code Form is subject to the terms of the Mozilla Public
2
// License, v. 2.0. If a copy of the MPL was not distributed with this
3
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
11
"github.com/siderolabs/go-cmd/pkg/cmd"
15
// FilesystemTypeXFS is the filesystem type for XFS.
16
FilesystemTypeXFS = "xfs"
19
// XFSGrow expands a XFS filesystem to the maximum possible. The partition
20
// MUST be mounted, or this will fail.
21
func XFSGrow(partname string) error {
22
_, err := cmd.Run("xfs_growfs", "-d", partname)
27
// XFSRepair repairs a XFS filesystem on the specified partition.
28
func XFSRepair(partname, fsType string) error {
29
if fsType != FilesystemTypeXFS {
30
return fmt.Errorf("unsupported filesystem type: %s", fsType)
33
_, err := cmd.Run("xfs_repair", partname)
38
// XFS creates a XFS filesystem on the specified partition.
39
func XFS(partname string, setters ...Option) error {
41
return errors.New("missing path to disk")
44
opts := NewDefaultOptions(setters...)
46
// The ftype=1 naming option is required by overlayfs.
47
// The bigtime=1 metadata option enables timestamps beyond 2038.
48
args := []string{"-n", "ftype=1", "-m", "bigtime=1"}
51
args = append(args, "-f")
55
args = append(args, "-L", opts.Label)
58
args = append(args, partname)
60
_, err := cmd.Run("mkfs.xfs", args...)