Skip to content

Commit a35609f

Browse files
Nakrezlguohan
authored andcommitted
[arista/aboot]: Zero out 1st MB before repartitioning (#5220)
The first partition starting point was changed to be 1M as part of this commit: 6ba2f97. On systems that are misaligned before conversion (partition start is the first sector), the relica partition that is left in the first MB can cause problems in Aboot and result in corruption of the filesystem on the new aligned partition. Zeroing this old relica makes sure that there is nothing left of the old partition lying around. There won't be any risk of having Aboot corrupt the new filesystem because of the old relica. Signed-off-by: Baptiste Covolato <[email protected]>
1 parent 80dc2b7 commit a35609f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

files/initramfs-tools/arista-convertfs.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ umount "$root_mnt"
213213

214214
if [ $(echo -n "$root_dev" | tail -c 1) == "1" ]; then
215215
# Create a new partition table (content in flash_dev will be deleted)
216+
err_msg="Error: Failed to zero out first MB"
217+
cmd="dd if=/dev/zero of=$flash_dev bs=512 count=2048"
218+
run_cmd "$cmd" "$err_msg"
216219
err_msg="Error: repartitioning $flash_dev failed"
217220
cmd="echo '2048' | sfdisk $flash_dev || (sleep 3; blockdev --rereadpt $flash_dev && fdisk -l $flash_dev | grep -q ${root_dev}.*Linux)"
218221
run_cmd "$cmd" "$err_msg"

0 commit comments

Comments
 (0)