Skip to content

Commit

Permalink
Reduce SONiC migration partition from 8G to 1G. (#1343)
Browse files Browse the repository at this point in the history
* Reduce SONiC migration partition from 8G to 1G.

* Changes to create 1G partition with ability to resize post migration.

* Remove redundant changes in varlog

* Use findfs to interpret root. Move resize in case cmdline params are reordered
  • Loading branch information
padmanarayana authored and lguohan committed Feb 7, 2018
1 parent 4925d48 commit 0d0752e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
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

0 comments on commit 0d0752e

Please sign in to comment.