Page 1 of 1

Boot from slice != 1

Posted: 05 Jul 2015 19:14
by svily0
Hello, I'm getting an error while trying to boot embedded Nas4Free installed in da0s2a. Error message states that Config.xml can't be found on the boot device, then the server halts. What is the correct way to force the system to consider slice 2 as a viable boot option?

Okay, I've found the relevant code in /etc/inc/config.inc
Still unsure how to approach the issue though, PHP is not my cup of tea.

Regards

Re: Boot from slice != 1

Posted: 08 Jul 2015 12:41
by svily0
The patch below does what I need...

Code: Select all

--- a/config.inc	2015-06-19 23:00:56.000000000 +0300
+++ b/config.inc	2015-07-07 19:15:33.981852035 +0300
@@ -122,15 +122,25 @@
 				echo " {$disk}";
 
 				// Try to mount device using UFS
-				if (0 == mwexec("/sbin/mount -r /dev/{$disk}s1a {$g['cf_path']}")) { // Search on slice 1
+
+				// Loop over disk's BSD <a> partitions
+				foreach (explode(" ", exec("/bin/ls /dev/{$disk}s?a")) as $pt) {
+				    if (0 == mwexec("/sbin/mount -r {$pt} {$g['cf_path']}")) { // Search on a <a> partition
 					if (file_exists("{$g['cf_conf_path']}/config.xml")) {
-						$cfgdevice = $disk;
-						$cfgpartition = "{$cfgdevice}s1a";
-						$cfgfstype = "ufs";
+					    $cfgdevice = $disk;
+					    $cfgpartition = trim(preg_replace("#/dev/#", "", $pt));
+					    $cfgfstype = "ufs";
 					}
 					// Unmount device
 					mwexec("/sbin/umount -f {$g['cf_path']}");
-				} else if (0 == mwexec("/sbin/mount -r /dev/{$disk}p2 {$g['cf_path']}")) { // Search on GPT/p2
+				    }
+				    // Device found, exit
+				    if ($cfgdevice) {
+					break 2;
+				    }
+				}
+
+				if (0 == mwexec("/sbin/mount -r /dev/{$disk}p2 {$g['cf_path']}")) { // Search on GPT/p2
 					if (file_exists("{$g['cf_conf_path']}/config.xml")) {
 						$cfgdevice = $disk;
 						$cfgpartition = "{$cfgdevice}p2";