Skip to content

Commit 329eba6

Browse files
mirzakKristian Amlie
authored and
Kristian Amlie
committed
Fall-back to environment and conf in active part probe
There are situations where it nearly impossible to find the active root-filesystem based on probing mounted devices. One example is this: /dev/root on /rom type squashfs (ro,relatime) There is no information about the actual device device used in above example. One additional probe step could be parsing /proc/cmdline to find the "root=" argument but this is essentially the same as looking at "mender_boot_part" environment variable. Hence we add a fall-back to only using the "mender_boot_part" environment variable and comparing that to what we have in "mender.conf" if we are not able to match against mounted devices. Changelog: Fix active partition detection when using non-native filesystems. Signed-off-by: Mirza Krak <[email protected]> (cherry picked from commit dfa2297)
1 parent 35595ed commit 329eba6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

partitions.go

+14
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,20 @@ func (p *partitions) getAndCacheActivePartition(rootChecker func(StatCommander,
191191

192192
activePartition, err := getRootFromMountedDevices(p, rootChecker, mountedDevices, rootDevice)
193193
if err != nil {
194+
// If we reach this point, we have not been able to find a match
195+
// based on mounted device.
196+
//
197+
// Fall-back to configuration and environment only!
198+
if checkBootEnvAndRootPartitionMatch(bootEnvBootPart, p.rootfsPartA) {
199+
p.active = p.rootfsPartA
200+
log.Debug("Setting active partition from configuration and environment: ", p.active)
201+
return p.active, nil
202+
}
203+
if checkBootEnvAndRootPartitionMatch(bootEnvBootPart, p.rootfsPartB) {
204+
p.active = p.rootfsPartB
205+
log.Debug("Setting active partition from configuration and environment: ", p.active)
206+
return p.active, nil
207+
}
194208
return "", err
195209
}
196210
if checkBootEnvAndRootPartitionMatch(bootEnvBootPart, activePartition) {

0 commit comments

Comments
 (0)