@@ -32,8 +32,8 @@ rootfs_b_partition=6
3232roothash_partition=7
3333
3434swap_partition=8
35- singlehdd_lvm_partition =9
36- 
35+ reserved_partition =9
36+ singlehdd_lvm_partition=10 
3737
3838#  DEST_DISK set from the template.yaml file as an environment variable.
3939
@@ -46,7 +46,7 @@ tep_size=14336
4646reserved_size=5120
4747boot_size=5120600
4848bare_min_rootfs_size=25
49- rootfs_size=3584 
49+ rootfs_size=4096 
5050rootfs_hashmap_size=100
5151rootfs_roothash_size=50
5252
@@ -189,6 +189,7 @@ make_partition() {
189189    swap_size=$((  swap_size *  1024  )) 
190190
191191    total_size_disk=$( fdisk -l ${DEST_DISK}  |  grep -i ${DEST_DISK}  |  head -1 |   awk ' /GiB/{ print int($3)*1024} /TiB/{ print int($3)*1024*1024}' ) 
192+     echo  " total_size_disk(detected) ${total_size_disk} " 
192193
193194    #  For single HDD Size should be total disk - lvm_size in GB provided as input by the User 
194195    if  [ $single_hdd  -eq  0 ]; 
@@ -200,11 +201,13 @@ make_partition() {
200201            total_size_disk=$((  total_size_disk -  lvm_size )) 
201202        fi 
202203    fi 
204+     echo  " total_size_disk(fixed) ${total_size_disk} " 
203205
204206    # ####
205207    if  $COMPLETE_DMVERITY ; 
206208    then 
207- 	swap_start=$((  total_size_disk -  swap_size )) 
209+ 	reserved_start=$((  total_size_disk -  reserved_size )) 
210+ 	swap_start=$((  reserved_start -  swap_size )) 
208211
209212	roothash_start=$((  swap_start -  rootfs_roothash_size )) 
210213	rootfs_b_start=$((  roothash_start -  rootfs_size )) 
@@ -230,21 +233,23 @@ make_partition() {
230233    # ####
231234    #  logging needed to understand the block splits
232235    echo  " DEST_DISK ${DEST_DISK} " 
233-     echo  " rootfs_partition     $rootfs_partition          rootfs_end           ${rootfs_end} MB" 
234-     echo  " root_hashmap_a_start ${root_hashmap_a_start} MB root_hashmap_b_start ${root_hashmap_b_start} MB" 
235-     echo  " root_hashmap_b_start ${root_hashmap_b_start} MB rootfs_b_start       ${rootfs_b_start} MB" 
236-     echo  " rootfs_b_start       ${rootfs_b_start} MB       roothash_start       ${roothash_start} MB" 
237-     echo  " roothash_start       ${roothash_start} MB       swap_start           ${swap_start} MB" 
238-     echo  " swap_start          ${swap_start} MB            tep_start            ${total_size_disk} MB" 
236+     echo  " rootfs_partition     $rootfs_partition           rootfs_end           ${rootfs_end} MB" 
237+     echo  " root_hashmap_a_start ${root_hashmap_a_start} MB  root_hashmap_b_start ${root_hashmap_b_start} MB" 
238+     echo  " root_hashmap_b_start ${root_hashmap_b_start} MB  rootfs_b_start       ${rootfs_b_start} MB" 
239+     echo  " rootfs_b_start       ${rootfs_b_start} MB        roothash_start       ${roothash_start} MB" 
240+     echo  " roothash_start       ${roothash_start} MB        swap_start           ${swap_start} MB" 
241+     echo  " swap_start           ${swap_start} MB            swap_end             ${reserved_start} MB" 
242+     echo  " reserved_start       ${reserved_start} MB        total_size_disk      ${total_size_disk} MB" 
239243    # ####
240244
241245    echo  " sizes in sectors" 
242-     echo  " rootfs_partition     $rootfs_partition          rootfs_end              $( convert_mb_to_sectors ${rootfs_end}  1) " 
246+     echo  " rootfs_partition     $rootfs_partition                                   rootfs_end            $( convert_mb_to_sectors ${rootfs_end}  1) " 
243247    echo  " root_hashmap_a_start $( convert_mb_to_sectors ${root_hashmap_a_start}  0) $( convert_mb_to_sectors ${root_hashmap_b_start}  1) " 
244248    echo  " root_hashmap_b_start $( convert_mb_to_sectors ${root_hashmap_b_start}  0) $( convert_mb_to_sectors ${rootfs_b_start}  1) " 
245249    echo  " rootfs_b_start       $( convert_mb_to_sectors ${rootfs_b_start}  0) $( convert_mb_to_sectors ${roothash_start}  1) " 
246250    echo  " roothash_start       $( convert_mb_to_sectors ${roothash_start}  0) $( convert_mb_to_sectors ${swap_start}  1) " 
247-     echo  " swap_start          $( convert_mb_to_sectors ${swap_start}  0) $( convert_mb_to_sectors ${total_size_disk}  1) " 
251+     echo  " swap_start           $( convert_mb_to_sectors ${swap_start}  0) $( convert_mb_to_sectors ${reserved_start}  1) " 
252+     echo  " reserved_start       $( convert_mb_to_sectors ${reserved_start}  0) $( convert_mb_to_sectors ${total_size_disk}  1) " 
248253    # ####
249254
250255    if  $COMPLETE_DMVERITY ; 
@@ -261,7 +266,8 @@ make_partition() {
261266	       mkpart hashmap_b ext4  " $( convert_mb_to_sectors " ${root_hashmap_b_start} " ) " " $( convert_mb_to_sectors " ${rootfs_b_start} " ) " 
262267	       mkpart rootfs_b ext4   " $( convert_mb_to_sectors " ${rootfs_b_start} " ) " " $( convert_mb_to_sectors " ${roothash_start} " ) " 
263268	       mkpart roothash ext4   " $( convert_mb_to_sectors " ${roothash_start} " ) " " $( convert_mb_to_sectors " ${swap_start} " ) " 
264- 	       mkpart swap linux-swap " $( convert_mb_to_sectors " ${swap_start} " ) " " $( convert_mb_to_sectors " ${total_size_disk} " ) " 
269+ 	       mkpart swap linux-swap " $( convert_mb_to_sectors " ${swap_start} " ) " " $( convert_mb_to_sectors " ${reserved_start} " ) " 
270+ 	       mkpart reserved ext4   " $( convert_mb_to_sectors " ${reserved_start} " ) " " $( convert_mb_to_sectors " ${total_size_disk} " ) " 
265271
266272
267273	check_return_value $?  " Failed to create paritions" 
@@ -298,6 +304,35 @@ make_partition() {
298304	mkfs -t ext4 -L root_b -F " ${DEST_DISK}${suffix}${rootfs_b_partition} " 
299305	check_return_value $?  " Failed to mkfs rootfs part" 
300306    fi 
307+ 
308+     #  Save the emt persistent
309+     #  this is needed because we need to resize the rootfs a
310+     # #############
311+     # save using dd
312+     dd if=" ${DEST_DISK}${suffix}${emt_persistent_partition} " " ${DEST_DISK}${suffix}${reserved_partition} " $emt_persistent_dd_count 
313+     sync
314+     # #############
315+ 
316+     #  delete the complete emt persistent partition
317+     parted -s ${DEST_DISK}  \
318+ 	   rm " ${emt_persistent_partition} " 
319+ 
320+     # resize rootfs a partition
321+     rootfs_a_start=$( parted ${DEST_DISK}  unit MB print |  awk ' /^ ' $rootfs_partition ' / {gsub(/MB/, "", $2); print $2}' ) 
322+ 
323+     # end size of rootfs a partition
324+     rootfs_a_end=$((  rootfs_a_start +  rootfs_size )) 
325+ 
326+     #  resize part a
327+     parted -s ${DEST_DISK}  \
328+ 	   resizepart $rootfs_partition  " $( convert_mb_to_sectors " ${rootfs_a_end} " ) " 
329+ 	   mkpart edge_persistent ext4 " $( convert_mb_to_sectors " ${rootfs_a_end} " ) " " $( convert_mb_to_sectors " ${emt_persistent_end} " ) " 
330+ 
331+     #  restore the copied data from reserved
332+     # backup using dd
333+     dd if=" ${DEST_DISK}${suffix}${reserved_partition} " " ${DEST_DISK}${suffix}${emt_persistent_partition} " $emt_persistent_dd_count 
334+     sync
335+     # #############
301336}
302337
303338# ####################################################################################
0 commit comments