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

Reduce SONiC migration partition from 8G to 1G. #1343

Merged
merged 4 commits into from
Feb 7, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
unzip \
gdisk \
sysfsutils \
grub2-common
grub2-common \
dosfstools \
parted
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need to install dosfstools, parted in the base image?

Copy link
Collaborator

Choose a reason for hiding this comment

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

separate PR due to different purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tools are needed in order to use a script (post migration) to revive free blocks and restore the OS9 partitions. I can remove them here since these can be installed on need basis on relevant units.


sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y download \
grub-pc-bin
Expand Down
32 changes: 25 additions & 7 deletions build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ elif [ "$IMAGE_TYPE" = "raw" ]; then
echo "Creating SONiC raw partition : $OUTPUT_RAW_IMAGE of size $RAW_IMAGE_DISK_SIZE MB"
fallocate -l "$RAW_IMAGE_DISK_SIZE"M $OUTPUT_RAW_IMAGE

## Generate a compressed 8GB partition dump that can be used to 'dd' in-lieu of using the onie-nos-installer
## Generate a partition dump that can be used to 'dd' in-lieu of using the onie-nos-installer
## Run the installer
## The 'build' install mode of the installer is used to generate this dump.
sudo chmod a+x $OUTPUT_ONIE_IMAGE
Expand All @@ -67,14 +67,32 @@ elif [ "$IMAGE_TYPE" = "raw" ]; then
exit 1
}

gzip $OUTPUT_RAW_IMAGE
if [ $CHUNK_SIZE = "0" ]; then
# Create a single compressed partition dump
gzip $OUTPUT_RAW_IMAGE

[ -r $OUTPUT_RAW_IMAGE.gz ] || {
echo "Error : gzip $OUTPUT_RAW_IMAGE failed!"
exit 1
}
[ -r $OUTPUT_RAW_IMAGE.gz ] || {
echo "Error : gzip $OUTPUT_RAW_IMAGE failed!"
exit 1
}

mv $OUTPUT_RAW_IMAGE.gz $OUTPUT_RAW_IMAGE
else
# Split the partition dump into chunks, compress each chunk
# and tar the chunks to be used as the raw image
split -a 4 -b "$CHUNK_SIZE"M -d $OUTPUT_RAW_IMAGE sonic-$TARGET_MACHINE-chunk
rm $OUTPUT_RAW_IMAGE
gzip sonic-$TARGET_MACHINE-chunk*
tar -cf sonic-$TARGET_MACHINE.tar --remove-files sonic-$TARGET_MACHINE-chunk*

[ -r sonic-$TARGET_MACHINE.tar ] || {
echo "Error : tar sonic-$TARGET_MACHINE.tar failed!"
exit 1
}

mv sonic-$TARGET_MACHINE.tar $OUTPUT_RAW_IMAGE
fi

mv $OUTPUT_RAW_IMAGE.gz $OUTPUT_RAW_IMAGE
echo "The compressed raw image is in $OUTPUT_RAW_IMAGE"

## Use 'aboot' as target machine category which includes Aboot as bootloader
Expand Down
6 changes: 6 additions & 0 deletions files/initramfs-tools/varlog
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ for x in "$@"; do
case "$x" in
varlog_size=*)
varlog_size="${x#varlog_size=}"
;;
resize2fs-host)
Copy link
Collaborator

Choose a reason for hiding this comment

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

where do you pass this data into /proc/cmdline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the resize2fs-host is pass in the bootline in the grub config file that is used for migration : nos_to_sonic_grub.cfg. e.g:

linux /image-master.0-dirty-20180129.024732/boot/vmlinuz-3.16.0-4-amd64 root=/dev/sda8 rw console=tty0 console=ttyS1,9600n8 quiet loop=image-master.0-dirty-20180129.024732/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor varlog_size=4096 fast-reboot resize2fs-host

resize_dev=`cat /proc/mounts | ${rootmnt}/bin/grep "/root/host" | ${rootmnt}/usr/bin/cut -d' ' -f1`
[ -z "$resize_dev" ] && exit 0
${rootmnt}/sbin/resize2fs $resize_dev
Copy link
Collaborator

Choose a reason for hiding this comment

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

do not use rootmnt, please follow mke2fs example to copy resize2fs into the initrd ramdisk.

Copy link
Collaborator

@lguohan lguohan Jan 29, 2018

Choose a reason for hiding this comment

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

follow arista-convertfs example to resize the rootfs in init-premount stage

;;
esac
done

Expand Down
5 changes: 4 additions & 1 deletion onie-image.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ OUTPUT_ONIE_IMAGE=target/sonic-$TARGET_MACHINE.bin
OUTPUT_RAW_IMAGE=target/sonic-$TARGET_MACHINE.raw

### Raw image size in MB
RAW_IMAGE_DISK_SIZE=8192
RAW_IMAGE_DISK_SIZE=1024

### Chunk size in MB (0 => single chunk)
CHUNK_SIZE=8
Copy link
Collaborator

Choose a reason for hiding this comment

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

default to 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If CHUNK_SIZE=0, the sonic-broadcom.raw will be a 1GB ext4 compressed to ~ 360MB.
Should we have the CHUNK_SIZE option at all to split the raw image into chunks OR it can be done by an offline script ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

keep CHUNK_SIZE as an option, I think default to 0 is better.


## Output file name for aboot installer
OUTPUT_ABOOT_IMAGE=target/sonic-aboot-$TARGET_MACHINE.swi
Expand Down