mirror of
				https://github.com/Telecominfraproject/ols-nos.git
				synced 2025-10-31 01:57:48 +00:00 
			
		
		
		
	Reduce SONiC migration partition from 8G to 1G. (#1343)
* 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
This commit is contained in:
		| @@ -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) | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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" | ||||
|  | ||||
|   | ||||
							
								
								
									
										39
									
								
								files/initramfs-tools/resize-rootfs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								files/initramfs-tools/resize-rootfs
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 padmanarayana
					padmanarayana