talos/pkg/makefs/xfs.go
Andrey Smirnov 2b68c8b67b
fix: enable long timestamps for xfs
This "fixes" the message like:

```
xfs filesystem being mounted at /var supports timestamps until 2038 (0x7fffffff)
```

We should support Talos beyond 2038, even if we switch to a different
filesystem type by 2038 :)

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2022-04-18 16:21:03 +03:00

47 lines
1.1 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package makefs
import (
"fmt"
"github.com/talos-systems/go-cmd/pkg/cmd"
)
// XFSGrow expands a XFS filesystem to the maximum possible. The partition
// MUST be mounted, or this will fail.
func XFSGrow(partname string) error {
_, err := cmd.Run("xfs_growfs", "-d", partname)
return err
}
// XFS creates a XFS filesystem on the specified partition.
func XFS(partname string, setters ...Option) error {
if partname == "" {
return fmt.Errorf("missing path to disk")
}
opts := NewDefaultOptions(setters...)
// The ftype=1 naming option is required by overlayfs.
// The bigtime=1 metadata option enables timestamps beyond 2038.
args := []string{"-n", "ftype=1", "-m", "bigtime=1"}
if opts.Force {
args = append(args, "-f")
}
if opts.Label != "" {
args = append(args, "-L", opts.Label)
}
args = append(args, partname)
_, err := cmd.Run("mkfs.xfs", args...)
return err
}