Source

vlocity-vinstall-gambas / Vlocity / MdlAutoPartition.module

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
' Gambas module file

'    This file is part of vinstall-ng

'    vinstall-ng is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 2 of the License, or
'    (at your option) any later version.

'    vinstall-ng  is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.

'    You should have received a copy of the GNU General Public License
'    along with vinstall-ng.  If not, see <http://www.gnu.org/licenses/>.

PUBLIC NewPartitions AS NEW Object[]

PRIVATE sMountedList AS String
PUBLIC objProgs AS Object[]
PUBLIC objSliders AS Object[]
PUBLIC objTls AS Object[]
PUBLIC sResizableList AS String[]
PUBLIC objContainters AS Object[]
PUBLIC objRbs AS Object[]
PRIVATE picDrive AS Picture
PRIVATE myProgs AS Object[]

PUBLIC sPartitionToShrink AS String
PUBLIC lMBAmmountToUseForVL AS Long


PUBLIC FUNCTION PERFORM_AUTO_PARTITION_FROM_FREE_SPACE() AS Integer
  
  ' trigger the automatic partitioning process.
  DIM hproc AS Process
  DIM sPartitionString, sFs, sResizeCommand, sDump, sPartPrefx AS String
  DIM sLine, partedDump, sMountDumpArr, sDumparr AS String[]
  DIM lCurrentSize AS Long
  DIM i, iPart, iPartCnt AS Integer
  DIM lEndMark AS Long
  DIM bSwapNeeded AS Boolean
  DIM sSwapPart, sRootPart, sSimulatedCommand, sPartSize AS String
  DIM lMbStart, lMbEnd, lMbSize, lTotalRam, lTotalSwapNeeded AS Long
  DIM bSetBoot AS Boolean
  DIM p, pt AS Partition
  
  
  
  p = Partitioner.AutoTarget
  'Message(UnitConv.sector_to_gb(p.Fin))
  'RETURN 
  ' P is the new partition dimensions to the one we need to resize.
  'we will need to create a new object for the one to create.
    FOR EACH pt IN Partitioner.Partitions
      IF p.BlockDevice = pt.BlockDevice AND IF p.Number = pt.Number THEN 
        p.CurrentFileSystem = pt.CurrentFileSystem
        p.Flags = pt.Flags
      END IF
    NEXT 
  
  SELECT CASE p.CurrentFileSystem
    CASE "ntfs", "NTFS", "HPFS/NTFS"
    sResizeCommand = "ntfsresize -P --force --force " & p.BlockDevice & p.Number & Space(1) & "-s " & UnitConv.sector_to_mb(p.Size) & "M"
    sSimulatedCommand = "ntfsresize -P --force --force " & p.BlockDevice & p.Number & Space(1) & "-s" & UnitConv.sector_to_mb(p.Size) & "M --no-action"
      
    CASE "ext2", "ext3", "*fat*", "hfsx", "hfs+", "hfs", "linux-swap", "vfat", "VFAT"
      sResizableList = "parted " & p.BlockDevice & " -s \'unit s resize " & p.Number & Space(1) & p.Beginning & Space(1) & p.Fin & "\'"
    CASE "reiserfs"
      sResizeCommand = "echo \"y\" | resize_reiserfs -f -s " & UnitConv.sector_to_b(p.Size) & Space(1) & p.BlockDevice & p.Number
    CASE ELSE 
      Message.Error("I dont know how to resize a partition type " & p.CurrentFileSystem)
      RETURN 1
  END SELECT 
  
  ' MAKE SURE THE PARTITION IS NOT MOUNTED BEFORE ATTEMPTING RESIZE
  SHELL "mount | grep \"^" & p.BlockDevice & p.Number & "\"" TO sDump
    IF Len(Trim(sDump)) > 0 THEN 
      sMountDumpArr = Split(Trim(sDump), gb.NewLine)
        FOR i = 0 TO sMountDumpArr.Max
          SHELL "umount -f " & p.BlockDevice & p.Number WAIT 
        NEXT 
        
      ' Now just to make sure......
      SHELL "mount | grep \"^" & p.BlockDevice & p.Number & "\"" TO sDump
        IF Len(Trim(sDump)) > 0 THEN 
          Message.Error(p.BlockDevice & p.Number & Space(1)&
            ("Is currently being used and cannot be freed. Automatic partition is not possible for this partition."))
        RETURN 1
        END IF
    END IF
    
    IF p.CurrentFileSystem LIKE "ntfs" THEN 
      DEBUG "Simulating ntfs resize operation"
        hproc = SHELL sSimulatedCommand WAIT 
          IF hproc.Value > 0 THEN 
            DEBUG "Simulated resize failed. Resizing of " & p.BlockDevice & p.Number & Space(1) & "could be dangerous"
            Message.Error(("Simulated resize operation failed for") & Space(1)&
                            p.BlockDevice & p.Number & "." & Space(1)& 
                            ("It is not safe to resize this partitions."))
            RETURN hproc.Value
          END IF
    END IF
'''' PERFORM REAL RESIZING OPERATION.
      DEBUG "Running real resize operation on " & p.BlockDevice & p.Number
      DEBUG sResizeCommand
      hproc = SHELL sResizeCommand WAIT 
        IF hproc.Value > 0 THEN 
          RETURN hproc.Value
        END IF
      DEBUG "Resizing of " & p.BlockDevice & p.Number & " successfull"
      
''' some formats will need a deletion and re-creation of the filesystem
IF p.CurrentFileSystem LIKE "ntfs" THEN 
  DEBUG "Destroying current file system (This should be safe now)"
    hproc = SHELL "parted " & p.BlockDevice & " -s \'rm " & p.Number & "\'" WAIT 
      IF hproc.Value > 0 THEN 
        DEBUG "Error deleting the ntfs filesystem"
        RETURN hproc.Value
      END IF
      ' if the previous step succeeds, we now need to re-create the fs
    hproc = SHELL "parted " & p.BlockDevice & " -s \'unit s mkpart " & p.Type &
    Space(1) & "ntfs " & p.Beginning & Space(1) & p.Size & "\'" WAIT 
      IF hproc.Value > 0 THEN 
        DEBUG "Error restoring ntfs filesystem"
        RETURN hproc.Value
      END IF
    '''' restore the boot flag
    hproc = SHELL "parted " & p.BlockDevice & " -s \" set " & p.Number & " boot on\"" WAIT 
      IF hproc.Value > 0 THEN 
        DEBUG "Error restoring boot flag on " & p.BlockDevice & p.Number
        RETURN hproc.Value
      END IF
      
  ELSE IF p.CurrentFileSystem LIKE "reiserfs" THEN 
    DEBUG "Safely removing partition " & p.BlockDevice & p.Number
    hproc = SHELL "parted " & p.BlockDevice & " -s \'rm " & p.Number & "\'" WAIT 
      IF hproc.Value > 0 THEN 
        DEBUG "Error deleting old reisefs filesystem"
        RETURN hproc.Value
      END IF
    DEBUG "Creating new partition with preserved filesystem"
    IF NOT p.Type THEN p.Type = "primary" ' ugly haack
    DEBUG "Fixme"
    hproc = SHELL "parted " & p.BlockDevice & " -s \'mkpart " & p.Type & Space(1) & "reiserfs " & p.Beginning & Space(1) & UnitConv.sector_to_gb(p.Size) & "GB \'" WAIT 
      IF hproc.Value > 0 THEN 
        DEBUG "failed to re-create reiserfs filesystem on " & p.BlockDevice & p.Number
        RETURN hproc.Value
      END IF
  
  END IF
      
'-====== CREATE NEW PARTITIONS NOW =======-

SHELL "probepart | grep -i \"linux swap\"" TO sDump
  IF Len(Trim(sDump)) > 0 THEN 
    bSwapNeeded = FALSE
      sDumparr = Split(Trim(sDump), gb.NewLine)
      sLine = Split(sDumparr[0], " ")      
      sSwapPart = Trim(sLine[0])
      'determine the size of this partition
      DEBUG "Detecting size of existing swap partition (" & sSwapPart & ")"
      SHELL "parted " & Left(sSwapPart, Len("/dev/hda")) & " -s \'unit GB print | grep \"^ " & Right(sSwapPart, Len(sSwapPart) - Len("/dev/hda")) & " \" | tr -s \' \',\"\" | cut -f5 -d \' \' \'" TO sDump
        IF Len(Trim(sDump)) <= 0 THEN 
          DEBUG "Unable to find size for swap partition"
        END IF
      Main.Install.Partitions.Add(sSwapPart & "-" & Trim(sDump) & "-" & "swap" & "-" & "linux-swap")
  ELSE 
    bSwapNeeded = TRUE
  END IF
            
  ''' determine how many partitions are present in the drive first ''''
  SHELL "probepart | grep \"^" & p.BlockDevice & "\" | wc -l" TO sDump
    sDump = Trim(sDump)
    iPartCnt = sDump
  ''' determine where the free space is at '''
  SHELL "parted " & p.BlockDevice & " -s \'unit s print free | grep -i \"free space\" | tr -s \' \' \'" TO sDump
  sDump = Trim(sDump)
    IF Len(sDump) <= 0 THEN RETURN 1
    sDumparr = Split(Trim(sDump), " ")
    lMbStart = Replace(Trim(sDumparr[0]), "s", "")
    lMbEnd = Replace(Trim(sDumparr[1]), "s", "")
    lMbSize = Replace(Trim(sDumparr[2]), "s", "")
      ''' determine ammount of ram available
        SHELL "free -m | grep \"^Mem:\" | tr -s \' \',\"\" | cut -f2 -d \' \'" TO sDump
          sDump = Trim(sDump)
          lTotalRam = sDump
            IF lTotalRam <= 512 THEN 
              lTotalSwapNeeded = (lTotalRam * 2)
            ELSE 
              lTotalSwapNeeded = lTotalRam
            END IF

IF iPartCnt <= 2 THEN 
  IF bSwapNeeded = FALSE THEN 
    ' only create the / partition
    DEBUG "Create / partition @ " & p.BlockDevice & (iPartCnt + 1) & " size = " & UnitConv.sector_to_gb(p.Size) & " GB"
    hproc = SHELL "parted " & p.BlockDevice & " -s \"mkpart primary " & UnitConv.sector_to_mb(lMbStart) & "M" & Space(1) & UnitConv.sector_to_mb(lMbEnd) & "M\"" WAIT  ' lmbstart and end are now sector values ;)
      IF hproc.Value > 0 THEN 
        RETURN hproc.Value
      END IF
    SHELL "parted " & p.BlockDevice & " -s \'unit GB  print | grep \"^ " & (iPartCnt + 1) & "\" | tr -s \' \',\"\" | cut -f5 -d \' \' \'" TO sDump
    hproc = SHELL "mkfs.reiserfs -fq " & p.BlockDevice & (iPartCnt + 1) WAIT 
    Main.Install.Partitions.Add(p.BlockDevice & (iPartCnt + 1) & "-" & Trim(sDump) & "-" & "/" & "-" & "reiserfs")
  ELSE 
    ' we need to create root and swap partitions.
    SHELL "parted " & p.BlockDevice & " -s \"unit s mkpart extended " & lMbStart & Space(1) & lMbEnd & "\"" WAIT 
    SHELL "parted " & p.BlockDevice & " -s \'unit s print free | grep -i \"free space\" | tr -s \' \',\"\" \'" TO sDump
      sDump = Trim(sDump)
      sDumparr = Split(Trim(sDump), " ")
      lMbStart = Replace(Trim(sDumparr[0]), "s", "")
      lMbEnd = Replace(Trim(sDumparr[1]), "s", "")
      lMbSize = Replace(Trim(sDumparr[2]), "s", "")
    ' the swap partition will be iPartcnt + 2 here (because the extended wrapper takes up +1 )
    hproc = SHELL "parted " & p.BlockDevice & Space(1) & " unit s -s\"mkpart logical linux-swap " & lMbStart & Space(1) & (lMbStart + UnitConv.mb_to_sector(lTotalSwapNeeded)) & "\"" WAIT 
      IF hproc.Value > 0 THEN RETURN hproc.Value
    SHELL "parted " & p.BlockDevice & " -s \'unit GB print | grep \"^ " & (iPartCnt + 2) & "\" | tr -s \' \',\"\" | cut -f5 -d \' \' \'" TO sDump
    sSwapPart = p.BlockDevice & (iPartCnt + 2)
    Main.Install.Partitions.Add(sSwapPart & "-" & Trim(sDump) & "-swap-linux-swap")
    
          ' yet again, detect the dimensions of the free space
    SHELL "parted " & p.BlockDevice & " -s \'unit s print free | grep -i \"free space\" | tr -s \' \',\"\" \'" TO sDump
      sDumparr = Split(Trim(sDump), " ")
      lMbStart = Replace(Trim(sDumparr[0]), "s", "")
      lMbEnd = Replace(Trim(sDumparr[1]), "s", "")
      lMbSize = Replace(Trim(sDumparr[2]), "s", "")
    hproc = SHELL "parted " & p.BlockDevice & "unit s -s \"mkpart logical reiserfs " & lMbStart & Space(1) & lMbEnd & "\"" WAIT 
    sRootPart = p.BlockDevice & (iPartCnt + 3)
    Main.Install.Partitions.Add(sRootPart & "-" & Trim(sDump) & "-/-reiserfs")
  
      END IF
  
  ELSE ' we need to create an extended partition wich will be ipartcnt + 1
  SHELL "parted " & p.BlockDevice & " unit s -s \"mkpart extended " & lMbStart & Space(1) & lMbEnd & "\"" WAIT 
    ' now to read the new space location and dimensions***********
  SHELL "parted " & p.BlockDevice & " -s \'unit s print free | grep -i \"free space\"|tr -s \' \',\"\" \'" TO sDump
  sDump = Trim(sDump)
  sDumparr = Split(sDump, " ")
  lMbStart = Replace(Trim(sDumparr[0]), "s", "")
  lMbEnd = Replace(Trim(sDumparr[1]), "s", "")
  lMbSize = Replace(Trim(sDumparr[2]), "s", "")
  
  ' again, swap partition will be ipartcnt + 2 and root will be +3
          IF bSwapNeeded = TRUE THEN 
            hproc = SHELL "parted " & p.BlockDevice & " unit s -s \"mkpart logical linux-swap " & lMbStart & Space(1) & (lMbStart + UnitConv.mb_to_sector(lTotalSwapNeeded)) & "\"" WAIT
              IF hproc.Value > 0 THEN RETURN hproc.Value
            DEBUG "created new swap partition " & p.BlockDevice & (iPartCnt + 2) & " size = " & lTotalSwapNeeded & "MB"
            SHELL "parted " & p.BlockDevice & " -s \'unit GB print | grep \"^ " & (iPartCnt + 2) & "\"|tr -s \' \',\"\"|cut -f5 -d \' \' \'" TO sDump
            sSwapPart = p.BlockDevice & (iPartCnt + 2)
            Main.Install.Partitions.Add(sSwapPart & "-" & Trim(sDump) & "-swap-linux-swap")
            
              ' one more time... 
                SHELL "parted " & p.BlockDevice & " -s \'unit s print free | grep -i \"free space\" | tr -s \' \',\"\" \'" TO sDump
                  sDumparr = Split(Trim(sDump), " ")
                  lMbStart = Replace(Trim(sDumparr[0]), "s", "")
                  lMbEnd = Replace(Trim(sDumparr[1]), "s", "")
                  lMbSize = Replace(Trim(sDumparr[2]), "s", "")
                hproc = SHELL "parted " & p.BlockDevice & " unit s -s\"mkpart logical reisefs " & lMbStart & Space(1) & lMbEnd WAIT 
                IF hproc.Value > 0 THEN RETURN hproc.Value
                DEBUG " Created / partition  " & p.BlockDevice & (iPartCnt + 3) & " Size = " & UnitConv.sector_to_gb(lMbSize) & " GB"
                SHELL "parted " & p.BlockDevice & " -s \'unit GB print | grep \"^ " & (iPartCnt + 3) & "\" | tr -s \' \', \"\" | cut -f5 -d\' \' \'" TO sDump
                sRootPart = p.BlockDevice & (iPartCnt + 3)
                Main.Install.Partitions.Add(sRootPart & "-" & Trim(sDump) & "-/-reiserfs")
      ELSE ' no swap needed
        SHELL "parted " & p.BlockDevice & " -s \'unit s print free | grep -i \"free space\" | tr -s \' \',\"\" \'" TO sDump
          sDumparr = Split(Trim(sDump), " ")
          lMbStart = Replace(Trim(sDumparr[0]), "s", "")
          lMbEnd = Replace(Trim(sDumparr[1]), "s", "")
          lMbEnd = Replace(Trim(sDumparr[2]), "s", "")
        hproc = SHELL "parted " & p.BlockDevice & " unit s -s \"mkpart logical reiserfs " & lMbStart & Space(1) & lMbEnd & "\"" WAIT 
          IF hproc.Value > 0 THEN RETURN hproc.Value
        DEBUG "Created / partition " & p.BlockDevice & (iPartCnt + 2) & " Size = " & UnitConv.sector_to_gb(lMbSize) & " GB"
        SHELL "parted " & p.BlockDevice & " -s \'unit GB print | grep \"^ " & (iPartCnt + 2) & "\" | tr -s \' \',\"\" | cut -f5 -d \' \' \'" TO sDump
        sRootPart = p.BlockDevice & (iPartCnt + 2)
        Main.Install.Partitions.Add(sRootPart & "-" & Trim(sDump) & "-/-reiserfs")
    END IF
  END IF
  
    
    
          
  
  RETURN 
        
END        
  '   
  ' lMBAmmountToUseForVL = ClsGlobal.lTotalMBforVL
  '   
  ' PRINT " --- -> Preparing to allocate " & lMBAmmountToUseForVL & " MB of space for" & Space(1) & ClsGlobal.sDistroName & Space(1) & "from " & sPartition & " <- ---"
  ' WAIT 1
  '   iPart = Right(sPartition, Len(sPartition) - Len("/dev/hda"))
  '     IF iPart < 10 THEN 
  '       sPartPrefx = " " 
  '     ELSE 
  '       sPartPrefx = ""
  '     END IF
  '     
  '   ' search for the partition information
  '     FOR i = 0 TO sResizableList.Max
  '       IF Left(Trim(sResizableList[i]), Len("/dev/hda1")) = Trim(sPartition) THEN 
  '         sPartitionString = Trim(sResizableList[i])
  '       END IF
  '     NEXT ' we got the partition string now
  '     
  '     ' Ths string is formatted like this
  '     ' Filesystem    Type   1M-blocks      Used Available Use% Mounted on
  '     
  '     ' split it in spaces
  '     sLine = Split(sPartitionString, " ")
  '       sFs = Trim(sLine[1])
  '       lCurrentSize = sLine[2]
  '     
  '     IF lMBAmmountToUseForVL <= 0 THEN 
  '       Message.Error("I dont know how much space to use for VL")
  '         RETURN 
  '     END IF
  '     
  '     SELECT CASE sFs
  '       CASE "ntfs", "NTFS", "HPFS/NTFS"
  '         'sResizeCommand = "ntfsresize -s " & (lCurrentSize - lMBAmmountToUseForVL) & "m" & Space(1) & sPartition
  '         sResizeCommand = "ntfsresize -P --force --force " & spartition & Space(1) & "-s " & (lCurrentSize - lMBAmmountToUseForVL) & "M"
  '         sSimulatedCommand = "ntfsresize -P --force --force " & spartition & Space(1) & "-s " & (lCurrentSize - lMBAmmountToUseForVL) & "M --no-action"
  '         
  '           SHELL "parted " & Left(spartition, Len("/dev/hda")) & " print | grep \"^ " & Right(spartition, Len(spartition) - Len("/dev/hda")) & "\"| tr -s \' \',\"\"" TO sDump
  '             sDump = Trim(sDump)
  '             'Message(sDump)
  '             'sDumparr = Split(sDump, " ")
  '             
  '               
  '               IF InStr(sDump, " boot") THEN 
  '               
  '                   bSetBoot = TRUE
  '                   PRINT " ----- Boot flag detected on " & spartition
  '              
  '               END IF
  '               
  '             
  '           
  '       CASE "ext2", "ext3", "*fat*", "hfsx", "hfs+", "hfs", "linux-swap", "vfat", "VFAT"
  '         SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit mb print | tr -s \' \',\"\" | grep \"^" & sPartPrefx & iPart & "\"" TO sDump
  '           sDump = Trim(sDump)
  '           'Number Start End     Size    Type   File system Flags
  '           '1    0.03MB 12256MB 12256MB primary reiserfs 
  '           partedDump = Split(sDump, " ")
  '           
  '           'RETURN 1
  '           lEndMark = Left(partedDump[2], Len(partedDump[2]) - 2)
  '           sResizeCommand = "parted " & Left(sPartition, Len("/dev/hda")) & " unit mb -s \"resize " & iPart & Space(1) & Trim(partedDump[1]) & Space(1) & (lEndMark - lMBAmmountToUseForVL) & "m\""
  '       CASE "reiserfs"
  '          'r resize_reiserfs -s -1G /dev/hda8 ( see man resize_reiserfs )
  '          sResizeCommand = "echo \"y\" | resize_reiserfs -fq -s -" & lMBAmmountToUseForVL & "M" & Space(1) & sPartition
  '          PRINT "DEBUG: " & sResizeCommand
  '          
  '       CASE ELSE 
  '         Message.Error("I dont know how to resize a partition type " & sFs)
  '         RETURN 1
  '     END SELECT 
  '     
  ' 
  ' 'Message(sResizeCommand)
  '     ' MAKE SURE THE PARTITION IS NOT MOUNTED BEFORE PROCEEDING
  '     SHELL "mount | grep ^" & sPartition TO sDump
  '     sDump = Trim(sDump)
  '     sMountDumpArr = Split(sDump, "\n")
  '       FOR i = 0 TO sMountDumpArr.Max
  '         SHELL "umount -f " & sPartition
  '       NEXT 
  ' 
  ' ' Just to make sure
  '   SHELL "mount | grep ^" & sPartition TO sDump
  '     sDump = Trim(sDump)
  '       IF Len(sDump) > 0 THEN 
  '         Message.Error(sPartition & Space(1)("is currently being used. Unable to umount it.") & "<br>" &
  '         ("Try another partitioning method"))
  '         RETURN 1
  '       END IF
  '   
  '         
  '         'if ntfs... then run a simulation
  '         IF sfs LIKE "ntfs" THEN 
  '           PRINT " ---\\-> Running ntfs resize simulation "             
  '             hproc = SHELL sSimulatedCommand WAIT 
  '               IF hproc.Value > 0 THEN 
  '                 Message.Error(("Simulated resize of your ntfs partition") & Space(1) & "(" & spartition & ")" & "<br>" &
  '                 ("It is not safe to perform this operation... Please use another partitioning method"))
  '                 RETURN hproc.Value
  '               END IF
  '               
  '             ' we need to use sectors as the units for this to work... otherwise we may lose some data
  '               
  '               
  '           PRINT " ---\\__ Running real resize operation"
  '         END IF 
  '                 
  '             
  ' ' run the actual command
  ' 'DEBUG sResizeCommand
  ' 'RETURN 1
  '   DEBUG sResizeCommand
  '   hproc = SHELL sResizeCommand WAIT 
  '     PRINT " ---\\--> Shinking partition " & spartition
  '     IF hproc.Value > 0 THEN 
  '       RETURN hproc.Value
  '       
  '     END IF
  '     PRINT "Done"
  '     
  '     'DEBUG "done resizing"
  '     '
  '     'RETURN 1
  '     
  '     
  '     IF sFs LIKE "ntfs" THEN 
  '       PRINT " ----|=- Re-creating ntfs filesystem"
  '         hproc = SHELL "parted " & Left(spartition, Len("/dev/hda")) & " rm " & Right(sPartition, Len(spartition) - Len("/dev/hda")) WAIT ' remove the filesystem
  '           IF hproc.Value > 0 THEN 
  '             Message.Error(("Error deleting the ntfs filesytem"))
  '             RETURN hproc.Value
  '           END IF
  '         hproc = SHELL "parted " & Left(spartition, Len("/dev/hda")) & " -s \"mkpart primary ntfs 0M " & (lEndMark - lMBAmmountToUseForVL) & "M\"" WAIT ' re-create the shrunken fs
  '           IF hproc.Value > 0 THEN 
  '             Message.Error(("Error creating the ntfs filesystem after shrinking it"))
  '             RETURN hproc.Value
  '           END IF
  '         PRINT " ---- Restoring boot flag"
  '         hproc = SHELL "parted " & Left(spartition, Len("/dev/hda")) & " -s \" set " & Right(spartition, Len(spartition) - Len("/dev/hda")) & " boot on\"" WAIT ' set the boot flag again
  '           IF hproc.Value > 0 THEN 
  '             Message("Error setting the boot flag on " & spartition)
  '           END IF
  '   ELSE IF sfs LIKE "reiserfs" THEN 
  '     
  '                   ' determine where the free space is at
  '           SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit mb print free | grep -i \"free space\" | tr -s \' \',\"\"" TO sDump
  '           sDump = Trim(Replace(sDump, "MB", ""))
  '             IF sDump THEN 
  '           'Message(sDump)
  '           
  '           sDumparr = Split(sDump, " ")
  '           lMbStart = sDumparr[0]
  '           lMbEnd = sDumparr[1]
  '           lMbSize = sDumparr[2]
  '             ELSE 
  '               DEBUG "Cant find free space"
  '               RETURN 
  '             END IF
  '   
  '     hproc = SHELL "parted " & Left(spartition, Len("/dev/hda")) & " rm " & Right(spartition, Len(spartition) - Len("/dev/hda")) WAIT ' remove the old filesystem
  '       IF hproc.Value > 0 THEN 
  '         PRINT "Error deleting old reiserfs filesystem"
  '         RETURN hproc.Value
  '       END IF
  '     hproc = SHELL "parted " & Left(spartition, Len("/dev/hda")) & " -s \"mkpart primary reiserfs " & lMbStart & "M " & (lMbEnd - lMBAmmountToUseForVL) & "M\"" WAIT ' re-create the new fs"
  '         DEBUG "parted " & Left(spartition, Len("/dev/hda")) & " -s \"mkpart primary reiserfs " & lMbStart & "M " & (lMbEnd - lMBAmmountToUseForVL) & "M\"" ' re-create the new fs"
  '       IF hproc.Value > 0 THEN 
  '         PRINT "Error restoring reiserfs filesystem."
  '         RETURN hproc.Value
  '       END IF
  '     
  '           
  '         
  '   END IF
  '   
  '         
  '     
  ' ' create new partitions now that we're here ============================================================================================
  '   ' do we need to create a swap partition?
  '   ' the global partitions must be set as "/dev/hda1-SIZE_IN_GB"
  '   
  '   
  '     SHELL "probepart | grep -i \"linux swap\"" TO sDump
  '       sDump = Trim(sDump)
  '         IF sDump THEN 
  '           bSwapNeeded = FALSE ' found a swap partition
  '           sDumparr = Split(sDump, "\n")
  '           sLine = Split(sDumparr[0], " ")
  '           sSwapPart = Trim(sLine[0])
  '           'SHELL "parted " & lef & " unit GB print | grep \"^ " & sNum & "\" | tr -s \' \',\"\" | cut -f 5 -d \' \'" TO sDump        
  '           SHELL "parted " & Left(sSwapPart, Len("/dev/hda")) & " unit GB print | grep \"^ " & Right(sSwapPart, Len(sSwapPart) - Len("/dev/hda")) & "\" | tr -s \' \',\"\" | cut -f 5 -d \' \'" TO sDump
  '             sDump = Trim(sDump)
  '             DEBUG " --- . Use existing swap partition at " & sSwapPart
  '             sSwapPart = sSwapPart & "-" & sDump 
  '             Main.Install.Partitions.Add(sSwapPart & "-" & Trim(sDump) & "-" & "swap" & "-" & "linux-swap")
  '         ELSE 
  '           bSwapNeeded = TRUE
  '           
  '           
  '         END IF
  '        
  '        ' determine how many partitions are present in the drive
  '         SHELL "probepart | grep \"^" & Left(sPartition, Len("/dev/hda")) & "\" |wc -l" TO sDump
  '           sDump = Trim(sDump)
  '           iPartCnt = sDump
  '         
  '                     ' determine where the free space is at
  '           SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit mb print free | grep -i \"free space\" | tr -s \' \',\"\"" TO sDump
  '           sDump = Trim(Replace(sDump, "MB", ""))
  '           Message(sDump)
  '           IF Len(sDump) <= 0 THEN RETURN 1
  '           sDumparr = Split(sDump, " ")
  '           lMbStart = sDumparr[0]
  '           lMbEnd = sDumparr[1]
  '           lMbSize = sDumparr[2]
  '           
  '        ' determine ammount of ram available
  '                 SHELL "free -m | grep \"^Mem:\" | tr -s \' \',\"\" | cut -f2 -d \' \'" TO sDump
  '                   lTotalRam = sDump
  '                     IF lTotalRam <= 512 THEN 
  '                       lTotalSwapNeeded = (lTotalRam * 2)
  '                     ELSE 
  '                       lTotalSwapNeeded = lTotalRam
  '                     END IF
  '           
  '         
  '   IF iPartCnt <= 2 THEN 
  '     IF bSwapNeeded = FALSE THEN 
  '       ' only create the / partition
  '         PRINT " ---\\__ Create / partition @ " & Left(sPartition, Len("/dev/hda")) & (iPartCnt + 1) & " size = " & lMbSize & " MB with reiserfs as filesytem"
  '         PRINT "DEBUG: " & "parted " & Left(sPartition, Len("/dev/hda")) & " -s \"mkpart primary reiserfs " & lMbStart & "mb " & lMbEnd & "mb\""
  '         hproc = SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " -s \"mkpart primary reiserfs " & lMbStart & "mb " & lMbEnd & "mb\"" WAIT 
  '           IF hproc.Value > 0 THEN 
  '             RETURN hproc.Value
  '           END IF
  '         SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit GB print | grep \"^ " & (iPartCnt + 1) & "\" | tr -s \' \',\"\" | cut -f 5 -d \' \'" TO sDump
  '         hproc = SHELL "mkfs.reiserfs -q " & Left(spartition, Len("/dev/hda")) & (iPartCnt + 1) WAIT
  '          
  '         sRootPart = Left(sPartition, Len("/dev/hda")) & (iPartCnt + 1) & "-" & sDump
  '         Main.Install.Partitions.Add(sRootPart & "-" & sDump & "-" & "/" & "-" & "reiserfs")
  '     ELSE 
  '       ' create root and swap
  '         SHELL "parted " & Left(spartition, Len("/dev/hda")) & " -s \"mkpart extended " & lMbSize & "mb " & lMbEnd & "mb\"" WAIT 
  '          ' ^ creates a wrapper around the unpartitioned space to give us room for new partitions (logical type)
  '             ' **********  need to read new space location and dimensions ***************
  '         SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit mb print free | grep -i \"free space\" tr -s \' \',\"\"" TO sDump
  '           sDump = Trim(Replace(sDump, "MB", ""))
  '           sDumparr = Split(sDump, " ")
  '           lMbStart = sDumparr[0]
  '           lMbEnd = sDumparr[1]
  '           lMbSize = sDumparr[2]
  '     ' swap partition will be iPartcnt + 2 here (because the extended is iPartcnt +1)
  '     ' / partition (if needed) will be iPartcnt + 3
  '             
  '               
  '                 ' SHELL "parted " & Trim(sdrive) & " mkpart logical linux-swap " & sFreeStart & " " & sFreeEnd WAIT 
  '                 hproc = SHELL "parted " & Left(spartition, Len("/dev/hda")) & " mkpart logical linux-swap " & lMbStart & "MB " & (lMbStart + lTotalSwapNeeded) & "MB" WAIT 
  '                   IF hproc.Value > 0 THEN RETURN hproc.Value
  '                   PRINT " ---\\___ Created swap partition " & Left(spartition, Len("/dev/hda")) & (iPartCnt + 2) & " size = " & lTotalSwapNeeded & "MB"
  '                     ' register the new swap partition to the global class
  '                     SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit GB print | grep \"^ " & (iPartCnt + 2) & "\" | tr -s \' \',\"\" | cut -f 5 -d \' \'" TO sDump
  '                       sSwapPart = Left(spartition, Len("/dev/hda")) & (iPartCnt + 2) & "-" & sDump
  '                       Main.Install.Partitions.Add(sSwapPart & "-" & sDump & "-" & "swap" & "-" & "linux-swap")
  '                   
  '            ' YET AGAIN
  '            SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit mb print free | grep -i \"free space\" tr -s \' \',\"\"" TO sDump
  '                       sDump = Trim(Replace(sDump, "MB", ""))
  '                       sDumparr = Split(sDump, " ")
  '                       lMbStart = sDumparr[0]
  '                       lMbEnd = sDumparr[1]
  '                       lMbSize = sDumparr[2]
  '                 hproc = SHELL "parted " & Left(spartition, Len("/dev/hda")) & " -s \"mkpart logical reiserfs " & lMbStart & "MB " & lMbEnd & "MB\"" WAIT 
  '                   IF hproc.Value > 0 THEN RETURN hproc.Value
  '                 PRINT " ---\\___ Created / partition " & Left(spartition, Len("/dev/hda")) & (iPartCnt + 3) & " size = " & lMbSize & "MB"
  '                 SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit GB print | grep \"^ " & (iPartCnt + 3) & "\" | tr -s \' \',\"\" | cut -f 5 -d \' \'" TO sDump
  '                 sRootPart = Left(spartition, Len("/dev/hda")) & (iPartCnt + 3) & "-" & sDump
  '                 Main.Install.Partitions.Add(sRootPart & "-" & sDump & "-" & "/" & "-" & "reiserfs")
  '         
  '     END IF
  '         
  '         
  '         
  '     
  '   ELSE  
  '     ' we will create an extended partition wich will be number iPartCnt +1
  '       SHELL "parted " & Left(spartition, Len("/dev/hda")) & " -s \"mkpart extended " & lMbStart & "mb " & lMbEnd & "mb\"" WAIT 
  '       ' ^ creates a wrapper around the unpartitioned space to give us room for new partitions (logical type)
  '             ' **********  need to read new space location and dimensions ***************
  '         SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit mb print free | grep -i \"free space\" tr -s \' \',\"\"" TO sDump
  '           sDump = Trim(Replace(sDump, "MB", ""))
  '           sDumparr = Split(sDump, " ")
  '           lMbStart = sDumparr[0]
  '           lMbEnd = sDumparr[1]
  '           lMbSize = sDumparr[2]
  '     ' swap partition will be iPartcnt + 2 here (because the extended is iPartcnt +1)
  '     ' / partition (if needed) will be iPartcnt + 3
  '             IF bSwapNeeded = TRUE THEN 
  '               
  '                 ' SHELL "parted " & Trim(sdrive) & " mkpart logical linux-swap " & sFreeStart & " " & sFreeEnd WAIT 
  '                 hproc = SHELL "parted " & Left(spartition, Len("/dev/hda")) & " mkpart logical linux-swap " & lMbStart & "MB " & (lMbStart + lTotalSwapNeeded) & "MB" WAIT 
  '                   IF hproc.Value > 0 THEN RETURN hproc.Value
  '                   PRINT " ---\\___ Created swap partition " & Left(spartition, Len("/dev/hda")) & (iPartCnt + 2) & " size = " & lTotalSwapNeeded & "MB"
  '                     ' register the new swap partition to the global class
  '                     SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit GB print | grep \"^ " & (iPartCnt + 2) & "\" | tr -s \' \',\"\" | cut -f 5 -d \' \'" TO sDump
  '                       sSwapPart = Left(spartition, Len("/dev/hda")) & (iPartCnt + 2) & "-" & sDump
  '                       Main.Install.Partitions.Add(sSwapPart & "-" & sDump & "-" & "swap" & "-" & "linux-swap")
  '                   
  '            ' YET AGAIN
  '            SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit mb print free | grep -i \"free space\" tr -s \' \',\"\"" TO sDump
  '                       sDump = Trim(Replace(sDump, "MB", ""))
  '                       sDumparr = Split(sDump, " ")
  '                       lMbStart = sDumparr[0]
  '                       lMbEnd = sDumparr[1]
  '                       lMbSize = sDumparr[2]
  '                 hproc = SHELL "parted " & Left(spartition, Len("/dev/hda")) & " -s \"mkpart logical reiserfs " & lMbStart & "MB " & lMbEnd & "MB\"" WAIT 
  '                   IF hproc.Value > 0 THEN RETURN hproc.Value
  '                 PRINT " ---\\___ Created / partition " & Left(spartition, Len("/dev/hda")) & (iPartCnt + 3) & " size = " & lMbSize & "MB"
  '                 SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit GB print | grep \"^ " & (iPartCnt + 3) & "\" | tr -s \' \',\"\" | cut -f 5 -d \' \'" TO sDump
  '                 sRootPart = Left(spartition, Len("/dev/hda")) & (iPartCnt + 3) & "-" & sDump
  '                 Main.Install.Partitions.Add(sRootPart & "-" & sDump & "-" & "/" & "-" & "reiserfs")
  '         ELSE ' no swap needed
  '             
  '             SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit mb print free | grep -i \"free space\" tr -s \' \',\"\"" TO sDump
  '                       sDump = Trim(Replace(sDump, "MB", ""))
  '                       sDumparr = Split(sDump, " ")
  '                       lMbStart = sDumparr[0]
  '                       lMbEnd = sDumparr[1]
  '                       lMbSize = sDumparr[2]
  '                 hproc = SHELL "parted " & Left(spartition, Len("/dev/hda")) & " -s \"mkpart logical reiserfs " & lMbStart & "MB " & lMbEnd & "MB\"" WAIT 
  '                   IF hproc.Value > 0 THEN RETURN hproc.Value
  '                 PRINT " ---\\___ Created / partition " & Left(spartition, Len("/dev/hda")) & (iPartCnt + 2) & " size = " & lMbSize & "MB"
  '                 SHELL "parted " & Left(sPartition, Len("/dev/hda")) & " unit GB print | grep \"^ " & (iPartCnt + 2) & "\" | tr -s \' \',\"\" | cut -f 5 -d \' \'" TO sDump
  '                 sRootPart = Left(spartition, Len("/dev/hda")) & (iPartCnt + 2) & "-" & sDump
  '                 Main.Install.Partitions.Add(sRootPart & "-" & sDump & "-" & "/" & "-" & "reiserfs")
  '                 
  '                              
  '             END IF
  '   END IF
  '             
  '    
  '     ' 
  '     ' ClsGlobal.sTargetRoot = Trim(sRootPart)
  '     ' ClsGlobal.sTargetSwap = Trim(sSwapPart)
  ' 
  ' 
'END




PUBLIC SUB DISPLAY_PARTITIONS_WITH_FREE_SPACE(hostContainer AS Container)
  
  DIM sDump, sPreMountList, sDfDump, sDrives, sPartition, sPartShort AS String
  DIM sResults, sDumparr, sLineArr AS String[]
  DIM sPost, sFinalList AS String
  DIM lFreeMB, lTotalMB, lUsedMB AS Long
  DIM i, n AS Integer
  DIM rb AS RadioButton
  DIM pb AS ProgressBar
  DIM sl AS Slider
  DIM hb AS hpanel
  DIM tl AS TextLabel
  DIM hr AS Separator
  DIM picb AS PictureBox
  DIM hobox AS Panel
  DIM sFs AS String
  DIM bgc AS Integer
  
  objProgs = NEW Object[]
  objSliders = NEW Object[]
  sResizableList = NEW String[]
  objTls = NEW Object[]
  objRbs = NEW Object[]
  objContainters = NEW Object[]
  myProgs = NEW Object[]

  
  picDrive = Picture.Load("images/hdd.png")
  PRINT " ---\\_ Shrink existing partitions to make room for VL"  

  WAIT 
    
  SHELL "df -Th | grep \"^/dev/\" | cut -f 1 -d \' \'" TO sPreMountList '| tr -s \' \',\"\"" TO sPreMountList
  'Message(sPreMountList)
    sDumparr = Split(sPreMountList, "\n")
      FOR i = 0 TO sDumparr.Max
        IF InStr(sFinalList, Trim(sDumparr[i])) = FALSE THEN 
          SHELL "df -Tm | grep \"" & Trim(sDumparr[i]) & "\" | tr -s \' \', \"\"" TO sDump
          sFinalList = sFinalList & sDump
        END IF
      NEXT        
  
  
  SHELL "probepart | grep \"^/dev/\" | tr -s \' \',\"\" | cut -f 1 -d \' \'" TO sDump
  'Message(sDump)
    sDump = Trim(sDump)
    sDumparr = Split(sDump, "\n")
      FOR i = 0 TO sDumparr.Max
        sPartition = Trim(sDumparr[i])
        sPartShort = Right(sPartition, Len(sPartition) - RInStr(sPartition, "/"))
        'Message(sPartShort)
        'sMountedList = sMountedList & sPartition & " "
        'IF InStr(sMountedList, sPartition) = FALSE THEN 
        'IF NOT InStr(Trim(sPreMountList), Trim(sPartition)) THEN 
        'IF InStr(Trim(sPreMountList), Trim(sPartition)) = FALSE THEN 
        IF InStr(sFinalList, Trim(sPartition)) = FALSE THEN 
          'Message(sPartition & " is not in the pre-mounted list")
          SHELL "mkdir -p /mnt" &/ sPartShort & " 2> /dev/null" WAIT 
          SHELL "mount -o ro " & sPartition & Space(1) & "/mnt" &/ sPartShort & " 2> /dev/null" WAIT 
          'SHELL "df -Th | grep \"^" & sPartition & "\" | head -n 1 | tr -s \' \',\"\"" TO sDump
          SHELL "df -Tm /mnt" &/ sPartShort & " | grep \"^/dev/\"| tr -s \' \',\"\"" TO sDump
          'Message(sDump)
          'sPost = sPost & sDump
          IF InStr(sFinalList, sDump) = FALSE THEN 
          IF InStr(sDump, ClsGlobal.sSourceAddr) = FALSE THEN 
          sFinalList = sFinalList & sDump
          END IF
          END IF
          SHELL "umount -f /mnt" &/ sPartShort & " 2> /dev/null" WAIT 
          
        END IF
          
      NEXT 
      
  
     'Message(sFinalList)
     sFinalList = Trim(sFinalList)
     sResults = Split(sFinalList, "\n")
      FOR i = 0 TO sResults.Max
        ' Message(Trim(sResults[i]))
        sLineArr = Split(Trim(sResults[i]), " ")
        sFs = Trim(sLineArr[1])
        lTotalMB = Trim(sLineArr[2])
        lUsedMB = Trim(sLineArr[3])        
        lFreeMB = Trim(sLineArr[4])
        'Message(sLineArr[0] & Space(1) & "fREE SPACE " & sLineArr[4] & " Mb") 
        
        IF lFreeMB >= 10240 THEN ' only if free space is equal to or greater than 10GB
        'Message(sLineArr[1])
          'IF Trim(sLineArr[1]) <> "*xfs*" OR Trim(sLineArr[1]) <> "reiserfs" OR Trim(sLineArr[1]) <> "*jfs*" THEN  'only if fs is not xfs or jfs
            SELECT CASE sFs ' set the background color for the existing data label
              CASE "xfs", "jfs", "reiserfs", "hfsplus"
                CONTINUE 
              CASE "ntfs", "NTFS"
                bgc = &h66FF66
              CASE "fat32", "FAT32", "vfat", "VFAT"
                bgc = &h33FF33
              CASE "fat16", "FAT", "FAT16"
                bgc = &h009900
              CASE "ext2", "EXT2"
                bgc = &h99CCFF
              CASE "ext3", "EXT3"
                bgc = &h336699
              CASE ELSE 
                bgc = Color.DarkGreen
            END SELECT 
          IF sFS <> "reiserfs" THEN           
        sResizableList.Add(Trim(sResults[i]))
        rb = NEW RadioButton(hostContainer) AS "PartitionOptions"
          WITH rb
            .Text = Trim(sLineArr[0]) & Space(1) & "-" & Space(1) & Trim(sLineArr[4]) & Space(1) & ("MB of free space") & " [ " & sFs & " ]"
            .tag = Trim(sLineArr[0])
            .Height = 21
            .Expand = TRUE
          END WITH 
          objRbs.Add(rb)


        hb = NEW hpanel(hostContainer)
          WITH hb
            .Expand = TRUE
            .Height = 72
            .Tag = Trim(sLineArr[0])
            .Visible = FALSE
          END WITH 
          objContainters.Add(hb)
               

          
          hr = NEW Separator(hb)
            WITH hr
              .Expand = TRUE
              .Height = 8
              .tag = Trim(sLineArr[0])
            END WITH 
          hobox = NEW Panel(hb)
            WITH hobox
              .Height = 21
              '.Width = .Parent.Width / 2
              .Tag = Trim(sLineArr[0])
              .Expand = TRUE
              .Arrangement = Arrange.Row
              .Spacing = 2
              '.Padding = 4
              .BackColor = Color.LightBackground
            END WITH 
          'panels.Add(hobox)
          tl = NEW TextLabel(hobox)
            WITH tl
              '.BackColor = Color.SelectedBackground
              .BackColor = bgc
              .Expand = FALSE
              .Text = ("Existing Data")
              .Width = .Parent.Width / 2
              '.Width = .Parent.Width - (((lUsedMB + (4 * 1024)) + (lFreeMB / 2) / lFreeMB) / 100) * 100
              .Height = .Parent.Height
              .Alignment = Align.Center
              '.Visible = TRUE
              .tag = .Parent.Tag
            END WITH 
            myProgs.Add(tl)
          tl = NEW TextLabel(hobox)
            WITH tl
              .Text = Main.Install.Name
              .Height = .Parent.Height
              '.Width = .Parent.Width * 0.5
              .Expand = TRUE
              '.BackColor = Color.LightBackground
              .Alignment = Align.Center
              .Tag = .Parent.Tag & "R"
            END WITH 
 
          tl = NEW TextLabel(hb)
            WITH tl
              .Text = ("Total space for") & Space(1) & Main.Install.Name & Space(1) & ":" & Space(1)
              .Height = 21
              '.Width = .Parent.Width * 0.5
              .Alignment = Align.Left
              .BackColor = Color.Transparent
              .Expand = TRUE
              .tag = Trim(sLineArr[0])
            END WITH 
              objTls.Add(tl)

          sl = NEW Slider(hb) AS "Slider"
            WITH sl
              .Tag = Trim(sLineArr[0])
              .Height = 21
              .Expand = TRUE
              '.Value = ((lUsedMB + (4 * 1024)) + (lFreeMB / 2) / lFreeMB) / 100
              '.Value = 50
              .Value = ((lUsedMB + (4 * 1024)) / lFreeMB) * 100
              '.MaxValue = 
              ' IF pb.Value < 0.5 THEN 
              ' .Value = 50
              ' ELSE 
              ' .Value = (pb.Value * 100) + ((pb.Value * 100) / 2) '/ 2
              ' END IF
              '.Value = 50
            END WITH 
            objSliders.Add(sl)
          hr = NEW Separator(hb)
          WITH hr
          .Expand = TRUE
          .Height = 4
          .Tag = Trim(sLineArr[0])
          END WITH 

              
        ' hb = NEW HBox(hostContainer)
        '   WITH hb
        '     .Height = 12
        '     .Expand = TRUE
        '   END WITH 

        END IF
      END IF
      NEXT 
   
   IF objContainters.count > 0 THEN objContainters[0].visible = TRUE
    FOR EACH tl IN myProgs
      FOR EACH sl IN objSliders
        IF tl.Tag = sl.tag THEN 
        'Message(sl.value)
          tl.Width = tl.Parent.Width / 2
        END IF
      NEXT 
    NEXT 
   
    
   IF objRbs.Count <= 0 THEN ' no partitions found
    'Message.Error("No resizable partitions found")
      Step3a3.tlExp.Text = ("No resizable partitions found on your system. Please use the manual partitioning method")
      Step3a3.Refresh()
      ClsGlobal.fRunningMainForm.btnext.enabled = objRbs.count >= 1
      
   END IF
   
END



  
PUBLIC SUB Slider_change()
  
  DIM pb AS ProgressBar
  DIM hb AS Panel
  DIM fMin AS Float
  DIM fVal AS Float
  DIM i AS Integer
  DIM sMatch AS String
  DIM sLine AS String[]
  DIM lFree, lMin, ltotal, lval AS Long
  DIM tl, tlr AS TextLabel
  DIM sAllocated AS Long
  
    ' FOR EACH pb IN objProgs
    ' 
    '   IF pb.tag = LAST.tag THEN fMin = pb.Value * 100
      FOR i = 0 TO sResizableList.Max
        IF Left(Trim(sResizableList[i]), Len("/dev/hda1")) = LAST.tag THEN 
          
        'Message("fount match")
          sMatch = Trim(sResizableList[i])
          sLine = Split(sMatch, " ")
          lFree = sLine[4]
          lTotal = Trim(sLine[2])
          lMin = lFree + (4 * 1024)
          lval = (lMin / lTotal) * 10

        END IF
      NEXT 
    'NEXT 
    fmin = (LAST.value / 100)
    'Message(fmin)
    sAllocated = ltotal - (lTotal * fMin)
    LAST.tooltip = ("Select the location to which we will resize") & Space(1) & LAST.tag
    FOR EACH tl IN objTls
      IF tl.Tag = LAST.tag THEN 
      
        tl.Text = ("Total space for") & Main.Install.Name & ":" & Space(1) & (100 - LAST.Value) & "%" & Space(1) & "-" & " ( " & sAllocated & " MB )"
      'lMBAmmountToUseForVL = sAllocated  
      ClsGlobal.lTotalMBforVL = sAllocated
      END IF
    NEXT 

  FOR EACH tl IN myProgs
    IF tl.tag = LAST.tag THEN 
      tl.Width = tl.Parent.Width * (LAST.value / 100)      
      
    END IF
      
  NEXT 

IF sAllocated <= (4 * 1024) THEN 
  Message(("We need at least 4GB for") & Space(1) & Main.Install.Name)
  STOP EVENT 
  RETURN 
END IF

  IF LAST.Value < lval THEN 
    LAST.Value = lval
      Message("This is the minimum we can resize this partition to.")
    STOP EVENT 
    RETURN 
  END IF
  
END

PUBLIC SUB PartitionOptions_Click()
  
  DIM hb AS HPanel
  FOR EACH hb IN objContainters
    IF hb.tag = LAST.tag THEN 
      hb.visible = TRUE
    ELSE 
      hb.visible = FALSE
    END IF
  NEXT 
END
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.