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 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
4 changes: 4 additions & 0 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/hooks/setfacl
sudo cp files/initramfs-tools/arista-net $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/arista-net
sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/arista-net

# Hook into initramfs: resize root partition after migration from another NOS to SONiC on Dell switches
sudo cp files/initramfs-tools/resize-rootfs $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/resize-rootfs
sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/resize-rootfs

## Hook into initramfs: after partition mount and loop file mount
## 1. Prepare layered file system
## 2. Bind-mount docker working directory (docker aufs cannot work over aufs rootfs)
Expand Down
2 changes: 1 addition & 1 deletion 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 Down
2 changes: 2 additions & 0 deletions files/initramfs-tools/mke2fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ esac
copy_exec /sbin/mke2fs
copy_exec /sbin/sfdisk
copy_exec /sbin/fdisk
copy_exec /sbin/resize2fs
copy_exec /sbin/findfs

fstypes="ext4 ext3"

Expand Down
39 changes: 39 additions & 0 deletions files/initramfs-tools/resize-rootfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

case $1 in
prereqs)
exit 0
;;
esac

# Extract kernel parameters
set -- $(cat /proc/cmdline)
for x in "$@"; do
case "$x" in
root=*)
root_val="${x#root=}"
;;
resize-rootfs)
need_resize=1
;;
esac
done

if [ -n "$need_resize" ]; then
if [ -z "$root_val" ]; then
echo "ERROR: resize required but unable to get root location from command line"
exit 1
fi

root_dev=$(findfs $root_val)
if [ $? != 0 ]; then
echo "ERROR: resize required but findfs failed"
exit 1
fi

resize2fs -f $root_dev
if [ $? != 0 ]; then
echo "ERROR: Unable to resize the root file system. Manual intervention needed to fix the issue."
exit 1
fi
fi
2 changes: 1 addition & 1 deletion onie-image.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ 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

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