mirror of
https://github.com/rancher/os.git
synced 2025-08-31 22:32:14 +00:00
find fs type of device automatically
This commit is contained in:
31
init/init.go
31
init/init.go
@@ -213,12 +213,31 @@ func MainInit() {
|
||||
|
||||
func mountState(cfg *config.Config) error {
|
||||
var err error
|
||||
if len(cfg.StateDev) == 0 {
|
||||
log.Debugf("State will not be persisted")
|
||||
err = util.Mount("none", STATE, "tmpfs", "")
|
||||
} else {
|
||||
log.Debugf("Mounting state device %s", cfg.StateDev)
|
||||
err = util.Mount(cfg.StateDev, STATE, cfg.StateDevFSType, "")
|
||||
|
||||
dev := util.ResolveDevice(cfg.StateDev)
|
||||
log.Debugf("Mounting state device %s", dev)
|
||||
|
||||
fsType := cfg.StateDevFSType
|
||||
log.Debugf("FsType has been set to %s", fsType)
|
||||
if fsType == "auto" {
|
||||
actualFsType, fsErr := util.GetFsType(dev)
|
||||
if fsErr != nil {
|
||||
return fsErr
|
||||
}
|
||||
fsType = actualFsType
|
||||
}
|
||||
err = util.Mount(dev, STATE, fsType, "")
|
||||
|
||||
if err != nil {
|
||||
if cfg.StateRequired {
|
||||
return err
|
||||
} else {
|
||||
log.Debugf("State will not be persisted")
|
||||
err = util.Mount("none", STATE, "tmpfs", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user