0eb0749442
Why I did it Move the /var/log on RAM. This is to prevent too many disk write on /var/log when mounted on disk. Work item tracking Microsoft ADO (number only): 17955517 How I did it Pass kernel cmdline option "log_inram=on" How to verify it Mellanox SN2700 root@str-msn2700-02:~# df -h Filesystem Size Used Avail Use% Mounted on udev 3.9G 0 3.9G 0% /dev tmpfs 791M 15M 776M 2% /run root-overlay 15G 12G 2.9G 80% / /dev/sda3 15G 12G 2.9G 80% /host tmpfs 790M 12M 779M 2% /var/log tmpfs 3.9G 107M 3.8G 3% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup overlay 15G 12G 2.9G 80% /var/lib/docker/overlay2/f50948841bee041368bf7c0546ceab4c71f05951fb0ed5ae70411f28dde68907/merged overlay 15G 12G 2.9G 80% /var/lib/docker/overlay2/c45de6c53e7185631a37e87686dd296b2585425f638aa92c720c90eae038480c/merged overlay 15G 12G 2.9G 80% /var/lib/docker/overlay2/f5bc87d5c2965b21b222f09dd57fe0fc798e518101d7ecd25d170b7662ae3e80/merged overlay 15G 12G 2.9G 80% /var/lib/docker/overlay2/b2f435a256b930da4897d8a096095dcce183a6efa55b5b637187a654db0585ee/merged overlay 15G 12G 2.9G 80% /var/lib/docker/overlay2/5c3588e42b29fd0516a164c00de621b7a00236ecbb240c4d0b3903ec706c220d/merged overlay 15G 12G 2.9G 80% /var/lib/docker/overlay2/5a4a2a2602fb4ed1d1df90c3916076f595b4d8bc18eb465dd23e33f354adcfb8/merged overlay 15G 12G 2.9G 80% /var/lib/docker/overlay2/9926f7378de9223fd3e88c8f59d888ad178e2ca23fa978f372e9838f10b7b803/merged overlay 15G 12G 2.9G 80% /var/lib/docker/overlay2/130abaf95cffc06d952adacb6aa54a2f5e7c54c81fa8c15184389e25a7884328/merged overlay 15G 12G 2.9G 80% /var/lib/docker/overlay2/aeef95cf5af6e20909a4cfd6c696176cc5dcb31dd456cc8acbbd3d59d47333d7/merged overlay 15G 12G 2.9G 80% /var/lib/docker/overlay2/ef9bb94012b9fe987e55c9b73141296da8081d258d0d134922776c3c4b3ec551/merged overlay 15G 12G 2.9G 80% /var/lib/docker/overlay2/cf425d372b347fd68569f128e1771e5a70dbf504b2f013304d60bcef6dfbd0da/merged overlay 15G 12G 2.9G 80% /var/lib/docker/overlay2/7a2592cdac5c7369a6a98e07dbf1c2d96d29634e7d7b593617c50cc7e09e5cb3/merged root@str-msn2700-02:~# root@str-msn2700-02:~# free -h total used free shared buff/cache available Mem: 7.7Gi 3.0Gi 3.3Gi 133Mi 1.5Gi 4.4Gi Swap: 0B 0B 0B root@str-msn2700-02:~# Dell S6100 root@str-s6100-acs-5:~# df -h Filesystem Size Used Avail Use% Mounted on udev 3.9G 0 3.9G 0% /dev tmpfs 794M 15M 780M 2% /run root-overlay 14G 9.9G 3.6G 74% / /dev/sda4 14G 9.9G 3.6G 74% /host tmpfs 793M 13M 781M 2% /var/log tmpfs 3.9G 60K 3.9G 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup overlay 14G 9.9G 3.6G 74% /var/lib/docker/overlay2/f94441208fba5df49b0b8f0b49c699475ed0fd07673ab4a3eb574869b8e17c83/merged overlay 14G 9.9G 3.6G 74% /var/lib/docker/overlay2/1c3dc3b582599602aec0dbd78945560f330f6244d2e218750622b3814dc53ed3/merged overlay 14G 9.9G 3.6G 74% /var/lib/docker/overlay2/ab5b96e72e323fff5168abc69f8599fa244410d856dbd10cdbf73c99a4fe8d67/merged overlay 14G 9.9G 3.6G 74% /var/lib/docker/overlay2/0e6e3adaba6bb1d2684da444661e540030d588ef498466b7d8ff773ce263a2ea/merged overlay 14G 9.9G 3.6G 74% /var/lib/docker/overlay2/1218ed8bfa7a17c8927b20005d45f5e1e4a634e653d5c5c2057ac54713dc3387/merged overlay 14G 9.9G 3.6G 74% /var/lib/docker/overlay2/b31486f665e5c929966185397990553fee6b41b515cbef28c945096673ac9bef/merged overlay 14G 9.9G 3.6G 74% /var/lib/docker/overlay2/b984fa70f30bd1bac92bdf8d36542ed4433b4dabc33f7bb1f0a17a5eaee90f3e/merged overlay 14G 9.9G 3.6G 74% /var/lib/docker/overlay2/b7866a1462768f3564b832187837c7a5e3d493b8084204e59610960cc5f6bc19/merged overlay 14G 9.9G 3.6G 74% /var/lib/docker/overlay2/113bbbe88ee8452f4310b02a1343cfb4f1beb5fedf68a7d810ff5b5d7457c9f0/merged overlay 14G 9.9G 3.6G 74% /var/lib/docker/overlay2/e7cc383186c6f9acecf2031c0c1f0870b8a7f63e1918b8359afa7a13d3c28963/merged overlay 14G 9.9G 3.6G 74% /var/lib/docker/overlay2/c5d269100da205981c51e70e9e86facf69487f99e234dcdac822b8ab01af3d6a/merged overlay 14G 9.9G 3.6G 74% /var/lib/docker/overlay2/463874ab78b2e45a34cf4d3d1cd2e45ff18c0abbf37be62d2c8559dce38d6219/merged root@str-s6100-acs-5:~# free -h total used free shared buff/cache available Mem: 7.8Gi 2.1Gi 4.1Gi 69Mi 1.6Gi 5.3Gi Swap: 0B 0B 0B root@str-s6100-acs-5:~# Nokia-7215 root@str-2-7215-acs-4:~# df -h Filesystem Size Used Avail Use% Mounted on udev 1.5G 0 1.5G 0% /dev tmpfs 303M 14M 289M 5% /run root-overlay 15G 7.2G 7.2G 51% / /dev/sda2 15G 7.2G 7.2G 51% /host tmpfs 302M 7.5M 295M 3% /var/log tmpfs 1.5G 60K 1.5G 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup overlay 15G 7.2G 7.2G 51% /var/lib/docker/overlay2/617e49b8b8e4368db2b3b2fb3e3204e80ec572fe7981d67ad2116d9c3e4472f3/merged overlay 15G 7.2G 7.2G 51% /var/lib/docker/overlay2/c94b855482fc14aa1f032b0c8dc035b02f37ad9e4341cb5a8d22f14e14c63824/merged overlay 15G 7.2G 7.2G 51% /var/lib/docker/overlay2/2d8c6ee95b212bbc8376d15916723128455678f2a3c88f382b451bec88297341/merged overlay 15G 7.2G 7.2G 51% /var/lib/docker/overlay2/92114013a19dc19f30505ba645f961d50e093365422a9b22116ced1fa88ded2b/merged overlay 15G 7.2G 7.2G 51% /var/lib/docker/overlay2/c8e79a8403863887666324f163a4b6633c40c8b349402b3a0f40ba7e51adb28b/merged overlay 15G 7.2G 7.2G 51% /var/lib/docker/overlay2/27fd4a51859f3febd345a8551a0b4686d696c205048e1d595b76114385a68949/merged root@str-2-7215-acs-4:~#
303 lines
13 KiB
Plaintext
303 lines
13 KiB
Plaintext
# Copyright (C) Marvell Inc
|
|
|
|
# over ride default behaviour
|
|
|
|
echo "Preparing for installation ... "
|
|
|
|
# global defines
|
|
kernel_addr=0x1100000
|
|
fdt_addr=0x2800000
|
|
fdt_high=0x28fffff
|
|
initrd_addr=0x2900000
|
|
|
|
kernel_fname="/boot/vmlinuz-5.10.0-18-2-armmp"
|
|
initrd_fname="/boot/initrd.img-5.10.0-18-2-armmp"
|
|
fdt_fname="/boot/armada-385-ET6448M_4G_Nand.dtb"
|
|
|
|
if [ "$install_env" = "onie" ]; then
|
|
MACH_FILE="/etc/machine.conf"
|
|
else
|
|
MACH_FILE="/host/machine.conf"
|
|
fi
|
|
# armhf-marvell_et6448m_52x-r0 - Platform = Et6448M
|
|
# armhf-nokia_ixs7215_52x-r0 - Platform = Nokia IPD6448M
|
|
PLATFORM=`sed -n 's/^onie_platform=\(.*\)/\1/p' $MACH_FILE`
|
|
echo "Intalling SONiC from $install_env on Platform $PLATFORM"
|
|
|
|
# global mount defines
|
|
if [ "$PLATFORM" = "armhf-marvell_et6448m_52x-r0" ]; then
|
|
demo_dev=ubi0
|
|
mtd_dev=/dev/$(cat /proc/mtd | grep "SONIC" | grep -o "mtd[0-9]")
|
|
mtd_num=$(echo $mtd_dev | grep -o "[0-9]")
|
|
|
|
fdt_fname="/boot/armada-385-ET6448M_4G_Nand.dtb"
|
|
|
|
BOOTARGS='setenv bootargs root='$demo_dev' rw rootwait ubi.mtd='$mtd_num' rootfstype=ubifs panic=1 console=ttyS0,115200 ${othbootargs} ${mtdparts} ${linuxargs}'
|
|
UBI_LOAD='run ubi_sonic_boot_mount_ubi; ubifsload $kernel_addr $image_name;ubifsload $fdt_addr $fdt_name; ubifsload $initrd_addr $initrd_name'
|
|
BOOTARGS_OLD='setenv bootargs root='$demo_dev' rw rootwait ubi.mtd='$mtd_num' rootfstype=ubifs panic=1 console=ttyS0,115200 ${othbootargs} ${mtdparts} ${linuxargs_old}'
|
|
UBI_LOAD_OLD='run ubi_sonic_boot_mount_ubi; ubifsload $kernel_addr $image_name_old;ubifsload $fdt_addr $fdt_name_old; ubifsload $initrd_addr $initrd_name_old'
|
|
UBIBOOTCMD='run ubi_sonic_boot_bootargs; run ubi_sonic_boot_load; test -n "$boot_once" && setenv boot_once "" && saveenv; bootz $kernel_addr $initrd_addr $fdt_addr'
|
|
UBIBOOTCMD_OLD='run ubi_sonic_boot_bootargs_old; run ubi_sonic_boot_load_old; test -n "$boot_once" && setenv boot_once "" && saveenv; bootz $kernel_addr $initrd_addr $fdt_addr'
|
|
LINUX_MISC_CMD='apparmor=1 security=apparmor usbcore.autosuspend=-1'
|
|
|
|
elif [ "$PLATFORM" = "armhf-nokia_ixs7215_52x-r0" ]; then
|
|
demo_dev=sda2
|
|
|
|
fdt_fname="/boot/armada-385-ipd6448m.dtb"
|
|
|
|
BOOTARGS='setenv bootargs root=/dev/'$demo_dev' rw rootwait rootfstype=ext4 panic=1 console=ttyS0,${baudrate} ${othbootargs} ${mtdparts} ${linuxargs}'
|
|
UBI_LOAD='scsi init; ext4load scsi 0:2 $kernel_addr $image_name; ext4load scsi 0:2 $fdt_addr $fdt_name; ext4load scsi 0:2 $initrd_addr $initrd_name'
|
|
BOOTARGS_OLD='setenv bootargs root=/dev/'$demo_dev' rw rootwait rootfstype=ext4 panic=1 console=ttyS0,${baudrate} ${othbootargs} ${mtdparts} ${linuxargs_old}'
|
|
UBI_LOAD_OLD='scsi init; ext4load scsi 0:2 $kernel_addr $image_name_old; ext4load scsi 0:2 $fdt_addr $fdt_name_old; ext4load scsi 0:2 $initrd_addr $initrd_name_old'
|
|
UBIBOOTCMD='run ubi_sonic_boot_bootargs; run ubi_sonic_boot_load; test -n "$boot_once" && setenv boot_once "" && saveenv; bootz $kernel_addr $initrd_addr $fdt_addr'
|
|
UBIBOOTCMD_OLD='run ubi_sonic_boot_bootargs_old; run ubi_sonic_boot_load_old; test -n "$boot_once" && setenv boot_once "" && saveenv; bootz $kernel_addr $initrd_addr $fdt_addr'
|
|
LINUX_MISC_CMD='apparmor=1 security=apparmor usbcore.autosuspend=-1'
|
|
|
|
else
|
|
echo "Unsupported Platform $PLAFORM"
|
|
exit 2
|
|
fi
|
|
demo_mnt=/tmp
|
|
FW_ENV_DEFAULT='/dev/mtd0 0x00500000 0x80000 0x100000 8'
|
|
UBOOT_FW_DEFAULT=1
|
|
|
|
prepare_boot_menu() {
|
|
echo "Sync up cache ..."
|
|
sync
|
|
echo "Setting up U-Boot environment..."
|
|
|
|
DTB_HAS_ENV_BLK=$(grep uboot-env /proc/mtd | sed -e 's/:.*$//')
|
|
if [ -c "/dev/$DTB_HAS_ENV_BLK" ]; then
|
|
PROC_ENV_FILE=$(find /proc/device-tree/ -name env_size)
|
|
if [ -n "$PROC_ENV_FILE" ]
|
|
then
|
|
UBOOT_ENV_SIZ="0x$(hd $PROC_ENV_FILE | awk 'FNR==1 {print $2 $3 $4 $5}')"
|
|
UBOOT_ENV_ERASE_SIZ="0x$(grep uboot-env /proc/mtd | awk '{print $3}')"
|
|
if [[ -n "$UBOOT_ENV_SIZ" && -n "$UBOOT_ENV_ERASE_SIZ" ]]
|
|
then
|
|
# Env info from DTB
|
|
FW_ENV_DTB="/dev/$DTB_HAS_ENV_BLK 0x00000000 $UBOOT_ENV_SIZ $UBOOT_ENV_ERASE_SIZ"
|
|
fi
|
|
fi
|
|
fi
|
|
if [ -n "$FW_ENV_DTB" ]
|
|
then
|
|
echo $FW_ENV_DTB > /etc/fw_env.config
|
|
echo "Found uboot env offset in device tree"
|
|
UBOOT_ENV_CRC=$(fw_printenv 2>&1 | grep -c 'Warning: Bad CRC') || true
|
|
if [ "$UBOOT_ENV_CRC" -eq 0 ]
|
|
then
|
|
echo "Uboot env offset in device tree is valid"
|
|
UBOOT_FW_DEFAULT=0
|
|
fdt_fname="/boot/armada-385-ET6448M_4G_Nand_r2019.dtb"
|
|
else
|
|
echo "Uboot env offset in device tree is NOT valid"
|
|
UBOOT_FW_DEFAULT=1
|
|
fi
|
|
fi
|
|
if [ $UBOOT_FW_DEFAULT -eq 1 ]
|
|
then
|
|
echo $FW_ENV_DEFAULT > /etc/fw_env.config
|
|
echo "Using pre-configured uboot env"
|
|
fi
|
|
if [ "$PLATFORM" = "armhf-nokia_ixs7215_52x-r0" ]; then
|
|
FW_ENV_DEFAULT='/dev/mtd0 0x00100000 0x10000 0x10000'
|
|
echo $FW_ENV_DEFAULT > /etc/fw_env.config
|
|
echo "Using pre-configured uboot env for armhf-nokia_ixs7215_52x-r0"
|
|
fi
|
|
|
|
image_name=${image_dir}${kernel_fname}
|
|
initrd_name=${image_dir}${initrd_fname}
|
|
fdt_name=${image_dir}${fdt_fname}
|
|
|
|
if [ "$install_env" = "onie" ]; then
|
|
FW_ARG="-f"
|
|
image_dir_old=""
|
|
image_name_old=""
|
|
initrd_name_old=""
|
|
fdt_name_old=""
|
|
sonic_version_2="None"
|
|
else
|
|
eval running_version="$(cat /proc/cmdline | sed -n 's/^.*loop=\/*image-\(\S\+\)\/.*$/\1/p')"
|
|
current_boot_next=$(fw_printenv -n boot_next || true)
|
|
running_sonic_image=1
|
|
if [ "$current_boot_next" = "run sonic_image_1" ]; then
|
|
# boot_next=run sonic_image_1
|
|
sonic_version_2=$(fw_printenv -n sonic_version_2 || true)
|
|
if test "${sonic_version_2#*$running_version}" != "$sonic_version_2"
|
|
then
|
|
running_sonic_image=2
|
|
else
|
|
running_sonic_image=1
|
|
fi
|
|
else
|
|
# boot_next=run sonic_image_2
|
|
sonic_version_1=$(fw_printenv -n sonic_version_1 || true)
|
|
if test "${sonic_version_1#*$running_version}" != "$sonic_version_1"
|
|
then
|
|
running_sonic_image=1
|
|
else
|
|
running_sonic_image=2
|
|
fi
|
|
fi
|
|
|
|
if [ $running_sonic_image -eq 1 ]; then
|
|
image_dir_old=$(fw_printenv -n image_dir || true)
|
|
image_name_old=$(fw_printenv -n image_name || true)
|
|
initrd_name_old=$(fw_printenv -n initrd_name || true)
|
|
fdt_name_old=$(fw_printenv -n fdt_name || true)
|
|
sonic_version_2=$(fw_printenv -n sonic_version_1 || true)
|
|
else
|
|
image_dir_old=$(fw_printenv -n image_dir_old || true)
|
|
image_name_old=$(fw_printenv -n image_name_old || true)
|
|
initrd_name_old=$(fw_printenv -n initrd_name_old || true)
|
|
fdt_name_old=$(fw_printenv -n fdt_name_old || true)
|
|
sonic_version_2=$(fw_printenv -n sonic_version_2 || true)
|
|
fi
|
|
fi
|
|
|
|
# Set boot variables
|
|
fw_setenv ${FW_ARG} image_dir $image_dir > /dev/null
|
|
fw_setenv ${FW_ARG} image_name $image_name > /dev/null
|
|
fw_setenv ${FW_ARG} initrd_name $initrd_name > /dev/null
|
|
fw_setenv ${FW_ARG} fdt_name $fdt_name > /dev/null
|
|
fw_setenv ${FW_ARG} sonic_version_1 $demo_volume_revision_label > /dev/null
|
|
fw_setenv ${FW_ARG} image_dir_old $image_dir_old > /dev/null
|
|
fw_setenv ${FW_ARG} image_name_old $image_name_old > /dev/null
|
|
fw_setenv ${FW_ARG} initrd_name_old $initrd_name_old > /dev/null
|
|
fw_setenv ${FW_ARG} fdt_name_old $fdt_name_old > /dev/null
|
|
fw_setenv ${FW_ARG} sonic_version_2 $sonic_version_2 > /dev/null
|
|
BOOT1='echo " > Boot1: $sonic_version_1 - run sonic_image_1";echo;'
|
|
BOOT2='echo " > Boot2: $sonic_version_2 - run sonic_image_2";echo;'
|
|
if [ "$PLATFORM" = "armhf-nokia_ixs7215_52x-r0" ]; then
|
|
BOOT3='echo " > Boot3: ONIE - run onie_bootcmd";echo;'
|
|
else
|
|
BOOT3='echo " > Boot3: ONIE - run onie_nand_boot";echo;'
|
|
fi
|
|
BORDER='echo "---------------------------------------------------";echo;'
|
|
fw_setenv ${FW_ARG} print_menu "$BORDER $BOOT1 $BOOT2 $BOOT3 $BORDER" > /dev/null
|
|
fw_setenv ${FW_ARG} linuxargs "net.ifnames=0 loopfstype=squashfs loop=$image_dir/$FILESYSTEM_SQUASHFS systemd.unified_cgroup_hierarchy=0 varlog_size=$VAR_LOG_SIZE loglevel=4 ${extra_cmdline_linux} ${ONIE_PLATFORM_EXTRA_CMDLINE_LINUX}" > /dev/null
|
|
fw_setenv ${FW_ARG} linuxargs_old "net.ifnames=0 loopfstype=squashfs loop=$image_dir_old/$FILESYSTEM_SQUASHFS systemd.unified_cgroup_hierarchy=0 varlog_size=$VAR_LOG_SIZE loglevel=4" > /dev/null
|
|
|
|
# Set boot configs
|
|
fw_setenv ${FW_ARG} kernel_addr $kernel_addr > /dev/null
|
|
fw_setenv ${FW_ARG} fdt_addr $fdt_addr > /dev/null
|
|
fw_setenv ${FW_ARG} fdt_high $fdt_high > /dev/null
|
|
fw_setenv ${FW_ARG} initrd_addr $initrd_addr > /dev/null
|
|
fw_setenv ${FW_ARG} mtdids 'nand0=armada-nand' > /dev/null
|
|
if [ $UBOOT_FW_DEFAULT -eq 1 ]
|
|
then
|
|
fw_setenv ${FW_ARG} mtdparts 'mtdparts=armada-nand:10m(U-Boot)ro,20m@10m(ONIE),-(SONIC)' > /dev/null
|
|
else
|
|
fw_setenv ${FW_ARG} mtdparts 'mtdparts=armada-nand:4m(uboot)ro,5m@5m(uboot-env),20m@10m(ONIE),-(SONIC)' > /dev/null
|
|
fi
|
|
if [ "$PLATFORM" = "armhf-nokia_ixs7215_52x-r0" ]; then
|
|
fw_setenv ${FW_ARG} mtdparts 'mtdparts=spi0.0:4m(boot),-(spi-rootfs)' > /dev/null
|
|
fi
|
|
fw_setenv ${FW_ARG} ubi_sonic_boot_mount_ubi 'ubi part SONIC; ubifsmount ubi0' > /dev/null
|
|
fw_setenv ${FW_ARG} ubi_sonic_boot_bootargs "$BOOTARGS" > /dev/null
|
|
fw_setenv ${FW_ARG} ubi_sonic_boot_load "$UBI_LOAD" > /dev/null
|
|
fw_setenv ${FW_ARG} sonic_image_1 "$UBIBOOTCMD" > /dev/null
|
|
fw_setenv ${FW_ARG} ubi_sonic_boot_bootargs_old "$BOOTARGS_OLD" > /dev/null
|
|
fw_setenv ${FW_ARG} ubi_sonic_boot_load_old "$UBI_LOAD_OLD" > /dev/null
|
|
fw_setenv ${FW_ARG} sonic_image_2 "$UBIBOOTCMD_OLD" > /dev/null
|
|
fw_setenv ${FW_ARG} boot_next 'run sonic_image_1'> /dev/null
|
|
fw_setenv ${FW_ARG} bootcmd 'run print_menu; usb start; test -n "$boot_once" && run boot_once; run boot_next' > /dev/null
|
|
|
|
}
|
|
|
|
create_ubi_partition() {
|
|
ubidetach /dev/ubi_ctrl -d 0 2>/dev/null || true
|
|
|
|
trap_push "${onie_bin} ubidetach -d 0 /dev/ubi_ctrl || true"
|
|
echo -en "Format mtd partition '$mtd_dev' "
|
|
ubiformat $mtd_dev -y -q || {
|
|
echo "Failed"
|
|
}
|
|
|
|
#attaches MTD devices (which describe raw flash) to UBI and creates corresponding UBI devices; ('-m 2' --> mtd2)
|
|
echo -en "ubiattach mtd '$mtd_num' "
|
|
ubiattach /dev/ubi_ctrl -m $mtd_num || {
|
|
echo "Failed"
|
|
}
|
|
|
|
#creates UBI volumes on UBI devices
|
|
ubimkvol /dev/$demo_dev -N $demo_dev -s 3900MiB
|
|
}
|
|
|
|
create_gpt_partition() {
|
|
blk_dev="/dev/sda"
|
|
demo_part=$(sgdisk -p $blk_dev | grep -e "$demo_volume_label" | awk '{print $1}')
|
|
# ONIE partition size 168MB
|
|
onie_part_size=168
|
|
|
|
if [ -z "$demo_part" ] ; then
|
|
# Partition Does NOT Exists
|
|
echo "SONIC label [$demo_volume_label] is NOT found in Partition"
|
|
echo "Proceeding to create partition"
|
|
|
|
attr_bitmask="0x0"
|
|
|
|
sgdisk --new=${demo_part}::+${onie_part_size}MB \
|
|
--attributes=${demo_part}:=:$attr_bitmask \
|
|
--change-name=${demo_part}:$demo_volume_label $blk_dev \
|
|
|| {
|
|
echo "Warning: The first trial of creating partition failed, trying the largest aligned available block of sectors on the disk"
|
|
begin=$(sgdisk -F $blk_dev)
|
|
end=$(sgdisk -E $blk_dev)
|
|
sgdisk --new=${demo_part}:$begin:$end \
|
|
--attributes=${demo_part}:=:$attr_bitmask \
|
|
--change-name=${demo_part}:$demo_volume_label $blk_dev
|
|
} || {
|
|
echo "Error: Unable to create partition $demo_part on $blk_dev"
|
|
exit 1
|
|
}
|
|
partprobe || true
|
|
else
|
|
# Partition Exists
|
|
echo "Partition exists $demo_part on $blk_dev"
|
|
fi
|
|
|
|
# Make filesystem
|
|
mkfs.ext4 -L $demo_volume_label /dev/$demo_dev
|
|
}
|
|
|
|
create_partition() {
|
|
# Platform speicific partition
|
|
if [ "$PLATFORM" = "armhf-marvell_et6448m_52x-r0" ]; then
|
|
echo "Doing UBI partition"
|
|
create_ubi_partition
|
|
else
|
|
echo "Doing GPT partition"
|
|
create_gpt_partition
|
|
fi
|
|
}
|
|
|
|
mount_partition() {
|
|
|
|
demo_mnt=$(mktemp -d) || {
|
|
echo "Error: Unable to create file sstem mount point"
|
|
exit 1
|
|
}
|
|
|
|
echo "Mounting $demo_dev on $demo_mnt "
|
|
if [ "$PLATFORM" = "armhf-marvell_et6448m_52x-r0" ]; then
|
|
trap_push "${onie_bin} umount /dev/ubi0_0|| true"
|
|
mount -t ubifs /dev/ubi0_0 $demo_mnt || {
|
|
echo "mount -t ubifs /dev/ubi0_0 $demo_mnt Failed"
|
|
exit 1
|
|
}
|
|
else
|
|
trap_push "${onie_bin} umount /dev/sda2|| true"
|
|
mount -t ext4 /dev/sda2 $demo_mnt || {
|
|
echo "mount -t ext4 /dev/sda2 $demo_mnt Failed"
|
|
exit 1
|
|
}
|
|
fi
|
|
}
|
|
|
|
bootloader_menu_config() {
|
|
# Update uboot Environment
|
|
prepare_boot_menu
|
|
}
|