by dockeradz » Sun May 31, 2020 1:59 am
Here is a patch to utilize multiple data partitions on boot. (edited to put partition in the right order) I also changed the partition color to match the md vol color, to indicate what partition is a member. I haven't looked too much into the UI yet to somehow display the mds in the same table when they share disks. I made an assumption that the data partitions on local disks always start at 8. The original code takes the last partition. It looks like a big change but basically I just added a loop for any partition over 8, and moved the md vols above to get the color.
- Code: Select all
Index: dm_update_single_db.finc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- dm_update_single_db.finc (revision 877c880a9e94a2e2b5eca10d953eece9d3ca94fd)
+++ dm_update_single_db.finc (date 1590939296261)
@@ -106,7 +106,31 @@
$disks=array();
$vols=array();
natsort($result);
-
+
+ //add RAID volume
+ exec("/usr/bin/grep ' md' /proc/partitions|/usr/bin/awk '{print \$4}'",$raid);
+ $hasRaidVol=false;
+ foreach ($raid as $md){
+ $raidinfo=null;
+ if(dm_get_raid_settings($md,$raidinfo) == OK_E){
+ $jvol['volid']="110".$md[2];
+ $jvol['md']= '/dev/'.$md;
+ $jvol['fs']= $jvol['volid'];
+ $jvol['lastindex']= 1;
+ $volname=exec("sudo /usr/sbin/e2label /dev/$md 2>/dev/null");
+ $volname=str_replace(' ','-',$volname);
+ $jvol['name']= (empty($volname))?$raidinfo['name']:$volname;
+ $jvol['devices']= $raidinfo['devices'];
+ $jvol['raidtype']= $raidinfo['raidtype'];
+ $jvol['color']=dm_random_color();
+ $jvol['formatting']= ( $raidinfo['init'] == 'true' )?0:1;
+ $jvol['size']= dm_get_vol_size("/dev/$md",$jvol['volid']);
+ //push the new volume
+ $vols[]=$jvol;
+ $hasRaidVol=true;
+ }
+ }
+
foreach ($result as $key => $disk){
unset($serial);
unset($model);
@@ -171,61 +195,66 @@
$jdisk['init']='false';
$jdisk['partitions']['partition']="";
}
- else{
- $nbpart=count($jpartitions);
- if($nbpart ==0){
- //partitions table is empty
- $jdisk['freesize']=$jdisk['size'];
- $jdisk['init']='false';
- $jdisk['partitions']['partition']="";
- }
- elseif($jpartitions[$nbpart-1]['type']!='83'&& $jpartitions[$nbpart-1]['type']!='8300'
- && $jpartitions[$nbpart-1]['type']!='fd'&& $jpartitions[$nbpart-1]['type']!='FD00'){
- //filesystem of sdx(last) is not ext3 => not valid
- $jdisk['freesize']=$jdisk['size'];
- $jdisk['init']='false';
- $jdisk['partitions']['partition']="";
- }
- else{
- //we can use sdx(last) as data partition
- $size=dm_get_partition_size($jpartitions[$nbpart-1]['name'])/1024/1024;
- $jdisk['size']=$size;
- $jdisk['freesize']=0;
- $jdisk['init']='true';
- //set partition data
- $jpart=array();
- $jpart['lvname']='/dev/'.$jpartitions[$nbpart-1]['name'];
- $jpart['color']=dm_random_color();
- //check if the device belongs to a RAID array
- unset($md);
- exec('sudo /sbin/mdadm --examine --brief '.$jpart['lvname'].'|/usr/bin/grep ARRAY|/usr/bin/awk \'{print $1"\n"$2}\'',$md);
- if (isset($md[0]) && $md[0] == 'ARRAY'){
- $jpart['volid']='110'.trim($md[1],'/mddev');
- }
- else{
- $jpart['volid']=$fs[$ind_disk];
- $command="sudo /usr/sbin/blkid -o value -s TYPE {$jpart['lvname']} 2>/dev/null";
- $fsdev=trim(exec($command));
- //set volume data
- $jvol['volid']=$jpart['volid'];
- $jvol['md']= $jpart['lvname'];
- $jvol['fs']= $jpart['volid'];
- $jvol['lastindex']= 1;
- $volname=exec('sudo /usr/sbin/e2label '.$jpart['lvname'].' 2>/dev/null');
- $volname=str_replace(' ','-',$volname);
- $jvol['name']= (empty($volname))?'Vol-'.strtoupper($ind_disk):$volname;
- $jvol['devices']= '';
- $jvol['raidtype']= 'single';
- $jvol['color']=$jpart['color'];
- $jvol['formatting']= ($fsdev == 'ext3' || $fsdev == 'ext4')?0:1;
- $jvol['size']= $size;
+ else {
+ $nbpart = count($jpartitions);
+ if ($nbpart == 0) {
+ //partitions table is empty
+ $jdisk['freesize'] = $jdisk['size'];
+ $jdisk['init'] = 'false';
+ $jdisk['partitions']['partition'] = "";
+ } elseif ($jpartitions[$nbpart - 1]['type'] != '83' && $jpartitions[$nbpart - 1]['type'] != '8300'
+ && $jpartitions[$nbpart - 1]['type'] != 'fd' && $jpartitions[$nbpart - 1]['type'] != 'FD00') {
+ //filesystem of sdx(last) is not ext3 => not valid
+ $jdisk['freesize'] = $jdisk['size'];
+ $jdisk['init'] = 'false';
+ $jdisk['partitions']['partition'] = "";
+ } else {
+ //we can use sdx(last) as data partition - a little presumptuous
+ //handle multiple data partitions
+ //data partitions on the 5big2 start at 8...is that true for other platforms?
+ for ($nbparti = 8-1; $nbparti < $nbpart; $nbparti++) {
+ $size = dm_get_partition_size($jpartitions[$nbparti]['name']) / 1024 / 1024;
+ $jdisk['size'] = $size;
+ $jdisk['freesize'] = 0;
+ $jdisk['init'] = 'true';
+ //set partition data
+ $jpart = array();
+ $jpart['lvname'] = '/dev/' . $jpartitions[$nbparti]['name'];
+ $jpart['color'] = dm_random_color();
+ //check if the device belongs to a RAID array
+ unset($md);
+ exec('sudo /sbin/mdadm --examine --brief ' . $jpart['lvname'] . '|/usr/bin/grep ARRAY|/usr/bin/awk \'{print $1"\n"$2}\'', $md);
+ if (isset($md[0]) && $md[0] == 'ARRAY') {
+ $jpart['volid'] = '110' . trim($md[1], '/mddev');
+ //get color of md
+ foreach ($vols as $vol) {
+ if ($vol['volid'] == $jpart['volid']) $jpart['color'] = $vol['color'];
+ }
+ } else {
+ $jpart['volid'] = $fs[$ind_disk];
+ $command = "sudo /usr/sbin/blkid -o value -s TYPE {$jpart['lvname']} 2>/dev/null";
+ $fsdev = trim(exec($command));
+ //set volume data
+ $jvol['volid'] = $jpart['volid'];
+ $jvol['md'] = $jpart['lvname'];
+ $jvol['fs'] = $jpart['volid'];
+ $jvol['lastindex'] = 1;
+ $volname = exec('sudo /usr/sbin/e2label ' . $jpart['lvname'] . ' 2>/dev/null');
+ $volname = str_replace(' ', '-', $volname);
+ $jvol['name'] = (empty($volname)) ? 'Vol-' . strtoupper($ind_disk) : $volname;
+ $jvol['devices'] = '';
+ $jvol['raidtype'] = 'single';
+ $jvol['color'] = $jpart['color'];
+ $jvol['formatting'] = ($fsdev == 'ext3' || $fsdev == 'ext4') ? 0 : 1;
+ $jvol['size'] = $size;
- //push the new volume
- $vols[]=$jvol;
- }
- $jpart['index']=0;
- $jpart['size']=$size;
- $jdisk['partitions']['partition'][]=$jpart;
+ //push the new volume
+ $vols[] = $jvol;
+ }
+ $jpart['index'] = 0;
+ $jpart['size'] = $size;
+ $jdisk['partitions']['partition'][] = $jpart;
+ }
}
}
$disks[]=$jdisk;
@@ -252,30 +281,6 @@
$vols[]=$usbvl;
}
- //add RAID volume
- exec("/usr/bin/grep ' md' /proc/partitions|/usr/bin/awk '{print \$4}'",$raid);
- $hasRaidVol=false;
- foreach ($raid as $md){
- $raidinfo=null;
- if(dm_get_raid_settings($md,$raidinfo) == OK_E){
- $jvol['volid']="110".$md[2];
- $jvol['md']= '/dev/'.$md;
- $jvol['fs']= $jvol['volid'];
- $jvol['lastindex']= 1;
- $volname=exec("sudo /usr/sbin/e2label /dev/$md 2>/dev/null");
- $volname=str_replace(' ','-',$volname);
- $jvol['name']= (empty($volname))?$raidinfo['name']:$volname;
- $jvol['devices']= $raidinfo['devices'];
- $jvol['raidtype']= $raidinfo['raidtype'];
- $jvol['color']=dm_random_color();
- $jvol['formatting']= ( $raidinfo['init'] == 'true' )?0:1;
- $jvol['size']= dm_get_vol_size("/dev/$md",$jvol['volid']);
- //push the new volume
- $vols[]=$jvol;
- $hasRaidVol=true;
- }
- }
-
//update nas database with the current volid
$oldshares=array();
$oldusers=array();
You do not have the required permissions to view the files attached to this post.