Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aboot]: add varlog limit file in aboot image #487

Merged
merged 2 commits into from
Apr 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion files/Aboot/boot0.j2
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ extract_image() {
rm -rf "$target_path/$f"
fi
done


## Unzip the image
unzip -oq "$swipath" -x boot0 -d "$target_path"
Expand Down Expand Up @@ -102,6 +101,8 @@ platform_specific() {
if [ "$platform" = "raven" ]; then
aboot_machine=arista_7050_qx32
echo "modprobe.blacklist=radeon" >>/tmp/append
# set varlog size to 100MB
echo "varlog_size=100" >>/tmp/append
fi
if [ "$platform" = "crow" ]; then
aboot_machine=arista_7050_qx32s
Expand Down
30 changes: 29 additions & 1 deletion files/initramfs-tools/arista-convertfs.j2
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,28 @@ run_cmd() {
fi
}

create_varlog_file() {
Copy link
Collaborator

@qiluo-msft qiluo-msft Apr 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_varlog_file [](start = 0, length = 18)

This function is not Arista specific. Suggest to move to a new file or into union-mount. #Closed

Copy link
Collaborator Author

@lguohan lguohan Apr 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for onie installer, it is in the installation process. For arista, since it does not have installation process, is needs to be put here.

I think the varlog filesystem should be created in the installation process. For arista platform, I am also asking them to push these operations into their installation process (they are coming up with some solution there). Thus, moving to union-mount does not look like to be long term solution. #Closed

Copy link
Collaborator Author

@lguohan lguohan Apr 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reason I think it should be in the installation process is to save the boot time. #Closed

Copy link
Collaborator

@qiluo-msft qiluo-msft Apr 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. This function is Arista specific because in the process of Arista aboot installation, there is no tool to create an ext4 partition, and it must be postpone to initramfs. #Closed

local err_msg="Error: create var-log ext4 file"
local cmd="[ -n $varlog_size ] && mkdir -p $root_mnt/disk-img && dd if=/dev/zero of=$root_mnt/disk-img/var-log.ext4 count=$((2048*$varlog_size)) && mke2fs -t ext4 -q -F $root_mnt/disk-img/var-log.ext4"
run_cmd "$cmd" "$err_msg"
}

mount_and_create_varlog_file() {
[ -z "$varlog_size" ] && exit 0
mkdir -p "$root_mnt"
mount -t ext4 "$root_dev" "$root_mnt"
# exit when the var_log.ext4 exists and the size matches
if [ -e "$root_mnt/disk-img/var-log.ext4" ]; then
cur_varlog_size=$(ls -l $root_mnt/disk-img/var-log.ext4 | awk '{print $5}')
if [ $cur_varlog_size == $((1024*1024*$varlog_size)) ]; then
exit 0
fi
fi
create_varlog_file
umount "$root_mnt"
exit 0
}

# Extract kernel parameters
set -- $(cat /proc/cmdline)
for x in "$@"; do
Expand All @@ -91,6 +113,9 @@ for x in "$@"; do
;;
Aboot=*)
aboot_flag="${x#Aboot=}"
;;
varlog_size=*)
varlog_size="${x#varlog_size=}"
esac
done
root_dev="$ROOT"
Expand All @@ -105,8 +130,9 @@ if ! wait_for_root_dev; then
echo "Error: timeout in waiting for $root_dev"
exit 1
fi
blkid | grep "$root_dev.*vfat" -q || exit 0

# mount, create varlog file and exit when the root is ext4
blkid | grep "$root_dev.*vfat" -q || mount_and_create_varlog_file

# Get flash dev name
if [ -z "$block_flash" ]; then
Expand Down Expand Up @@ -171,3 +197,5 @@ run_cmd "$cmd" "$err_msg"
err_msg="Error: copying files form $tmp_mnt to $root_mnt failed"
cmd="cp -a $tmp_mnt/. $root_mnt/"
run_cmd "$cmd" "$err_msg"

create_varlog_file