Skip to content

Commit dce642c

Browse files
Resized roots_a partitions to 4GB and also setting roots_b partition to 4GB (#102)
Co-authored-by: yvuppalx <[email protected]>
1 parent 11fd5be commit dce642c

File tree

1 file changed

+48
-13
lines changed

1 file changed

+48
-13
lines changed

standalone-node/provisioning_scripts/enable-dmv.sh

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ rootfs_b_partition=6
3232
roothash_partition=7
3333

3434
swap_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
4646
reserved_size=5120
4747
boot_size=5120600
4848
bare_min_rootfs_size=25
49-
rootfs_size=3584
49+
rootfs_size=4096
5050
rootfs_hashmap_size=100
5151
rootfs_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) root_hashmap_b_start $(convert_mb_to_sectors ${root_hashmap_b_start} 1)"
244248
echo "root_hashmap_b_start $(convert_mb_to_sectors ${root_hashmap_b_start} 0) rootfs_b_start $(convert_mb_to_sectors ${rootfs_b_start} 1)"
245249
echo "rootfs_b_start $(convert_mb_to_sectors ${rootfs_b_start} 0) roothash_start $(convert_mb_to_sectors ${roothash_start} 1)"
246250
echo "roothash_start $(convert_mb_to_sectors ${roothash_start} 0) swap_start $(convert_mb_to_sectors ${swap_start} 1)"
247-
echo "swap_start $(convert_mb_to_sectors ${swap_start} 0) tep_start $(convert_mb_to_sectors ${total_size_disk} 1)"
251+
echo "swap_start $(convert_mb_to_sectors ${swap_start} 0) reserved_start $(convert_mb_to_sectors ${reserved_start} 1)"
252+
echo "reserved_start $(convert_mb_to_sectors ${reserved_start} 0) total_size_disk $(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}" 0)"s "$(convert_mb_to_sectors "${rootfs_b_start}" 1)"s \
262267
mkpart rootfs_b ext4 "$(convert_mb_to_sectors "${rootfs_b_start}" 0)"s "$(convert_mb_to_sectors "${roothash_start}" 1)"s \
263268
mkpart roothash ext4 "$(convert_mb_to_sectors "${roothash_start}" 0)"s "$(convert_mb_to_sectors "${swap_start}" 1)"s \
264-
mkpart swap linux-swap "$(convert_mb_to_sectors "${swap_start}" 0)"s "$(convert_mb_to_sectors "${total_size_disk}" 1)"s
269+
mkpart swap linux-swap "$(convert_mb_to_sectors "${swap_start}" 0)"s "$(convert_mb_to_sectors "${reserved_start}" 1)"s \
270+
mkpart reserved ext4 "$(convert_mb_to_sectors "${reserved_start}" 0)"s "$(convert_mb_to_sectors "${total_size_disk}" 1)"s
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}" of="${DEST_DISK}${suffix}${reserved_partition}" bs=4M status=progress conv=sparse count=$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}" 1)"s \
329+
mkpart edge_persistent ext4 "$(convert_mb_to_sectors "${rootfs_a_end}" 0)"s "$(convert_mb_to_sectors "${emt_persistent_end}" 1)"s
330+
331+
# restore the copied data from reserved
332+
#backup using dd
333+
dd if="${DEST_DISK}${suffix}${reserved_partition}" of="${DEST_DISK}${suffix}${emt_persistent_partition}" bs=4M status=progress conv=sparse count=$emt_persistent_dd_count
334+
sync
335+
##############
301336
}
302337

303338
#####################################################################################

0 commit comments

Comments
 (0)