diff --git a/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher b/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher index 0ae06ae0e70a65ae314c0eb045a35214e021ab4d..4fa22195d51a708e5366c467ca0677ebcb1c16df 100755 --- a/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher +++ b/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher @@ -292,12 +292,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache @@ -438,7 +438,7 @@ partition_drive () { copy_rootfs elif [ "x${rfs_partition}" = "xdual" ] ; then partition_one_start_mb=${rfs_boot_startmb:-"1"} - partition_one_size_mb=${rfs_boot_size_mb:-"128"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) diff --git a/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-boot-emmc-rootfs-nvme b/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-boot-emmc-rootfs-nvme index ea85c0fb406854cd9217a1b120ba673015c5cb7a..9a6be0e6413f9919c614d7d2df85d308bde5a881 100755 --- a/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-boot-emmc-rootfs-nvme +++ b/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-boot-emmc-rootfs-nvme @@ -267,12 +267,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-boot-mmc-rootfs-sda b/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-boot-mmc-rootfs-sda index 647c3ce36f1212b450db1440bb1421fba5f6c286..394a3c31a70ae4f7fca5511f16ca361c085f94a4 100755 --- a/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-boot-mmc-rootfs-sda +++ b/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-boot-mmc-rootfs-sda @@ -116,6 +116,17 @@ broadcast_over_display () { } example_failure () { + message="Example: /etc/default/beagle-flasher" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="source=/dev/mmcblk0" ; broadcast + message="destination=/dev/mmcblk1" ; broadcast + message="rfs_partition=dual" ; broadcast + message="rfs_boot_startmb=1" ; broadcast + message="rfs_boot_size_mb=256" ; broadcast + message="bootloader=/opt/u-boot/bb-u-boot-beagleboneai64/install-emmc.sh" ; broadcast + message="flash_back=bbai64-emmc-to-microsd" ; broadcast + message="extlinux=/opt/u-boot/bb-u-boot-beagleboneai64/emmc-extlinux.conf" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast exit 2 } @@ -267,12 +278,12 @@ copy_rootfs () { mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-mv-rootfs-to-nvme b/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-mv-rootfs-to-nvme index 144aa0b5693bc332c821a50c1591c34747980f4e..afaa02b14e20e9964ce769f7be10641d4f86fd5a 100755 --- a/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-mv-rootfs-to-nvme +++ b/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-mv-rootfs-to-nvme @@ -267,12 +267,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-mv-rootfs-to-sda b/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-mv-rootfs-to-sda index 7d8fff82f44624e548d7c4bb54bd7164c96b2b35..947e56f4e4aed4567bcc15cca41ebfaccfe5f9ff 100755 --- a/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-mv-rootfs-to-sda +++ b/bb-beagle-flasher/suite/bookworm/debian/beagle-flasher-mv-rootfs-to-sda @@ -267,12 +267,12 @@ copy_rootfs () { mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/bookworm/debian/changelog b/bb-beagle-flasher/suite/bookworm/debian/changelog index 9f0f83dfdcc89c72759a93e30a2f687637f4afb7..3a7cf90ddaac5ea929f4923adb36e99702746719 100644 --- a/bb-beagle-flasher/suite/bookworm/debian/changelog +++ b/bb-beagle-flasher/suite/bookworm/debian/changelog @@ -1,4 +1,4 @@ -bb-beagle-flasher (1.20240620.0-0~bookworm+20240620) bookworm; urgency=low +bb-beagle-flasher (1.20240718.0-0~bookworm+20240718) bookworm; urgency=low * SK-AM69, support microSD -> usb sata * BBIA64/BeaglePlay, use u-boot versions of script files @@ -8,5 +8,5 @@ bb-beagle-flasher (1.20240620.0-0~bookworm+20240620) bookworm; urgency=low * Remove beagle-flasher-init-shutdown.service, single user will now shutdown * e2fsprogs (1.47.0) disable orphan_file, needs v5.15.x kernel - -- Robert Nelson <robertcnelson@gmail.com> Thu, 20 Jun 2024 09:14:06 -0500 + -- Robert Nelson <robertcnelson@gmail.com> Thu, 18 Jul 2024 11:24:51 -0500 diff --git a/bb-beagle-flasher/suite/bookworm/debian/init-beagle-flasher b/bb-beagle-flasher/suite/bookworm/debian/init-beagle-flasher index 0ad2d3426b45c92c24c7b80ec079b1f79323203c..fdc503bda929070152c31a5502086efd7a9e94e9 100755 --- a/bb-beagle-flasher/suite/bookworm/debian/init-beagle-flasher +++ b/bb-beagle-flasher/suite/bookworm/debian/init-beagle-flasher @@ -115,6 +115,17 @@ broadcast_over_display () { } example_failure () { + message="Example: /etc/default/beagle-flasher" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="source=/dev/mmcblk0" ; broadcast + message="destination=/dev/mmcblk1" ; broadcast + message="rfs_partition=dual" ; broadcast + message="rfs_boot_startmb=1" ; broadcast + message="rfs_boot_size_mb=256" ; broadcast + message="bootloader=/opt/u-boot/bb-u-boot-beagleboneai64/install-emmc.sh" ; broadcast + message="flash_back=bbai64-emmc-to-microsd" ; broadcast + message="extlinux=/opt/u-boot/bb-u-boot-beagleboneai64/emmc-extlinux.conf" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast exit 2 } @@ -275,7 +286,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/bookworm/debian/init-beagle-flasher-mv-rootfs-to-nvme b/bb-beagle-flasher/suite/bookworm/debian/init-beagle-flasher-mv-rootfs-to-nvme index b8928798a5782ec44fabcfdf54312cc92cc7f586..f5dc6e1bf643fca9cb2b5eb76e9adede25fd6884 100755 --- a/bb-beagle-flasher/suite/bookworm/debian/init-beagle-flasher-mv-rootfs-to-nvme +++ b/bb-beagle-flasher/suite/bookworm/debian/init-beagle-flasher-mv-rootfs-to-nvme @@ -269,7 +269,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher b/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher index 29aeb3c85c80e60da8dea04f560c217a87e5d7f8..fd30d2ba55a9e4dc5dfa529bad6ce10cb8a57bdb 100755 --- a/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher +++ b/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher @@ -6,7 +6,7 @@ if ! id | grep -q root; then exit fi -version_message="1.20240308.0, vfat mount permissions..." +version_message="1.20240419.0, merged usr cleanups..." #Debian 12, Ubuntu Lunar, Mantic, Noble #https://packages.debian.org/source/bookworm/e2fsprogs @@ -215,10 +215,10 @@ check_running_system () { message="INFO: Generating: [/boot/initrd.img-$(uname -r)]" ; broadcast message="update-initramfs: Generating /boot/initrd.img-$(uname -r)" ; broadcast_over_display if [ -f /boot/initrd.img-$(uname -r) ] ; then - /usr/sbin/update-initramfs -u -k $(uname -r) || true + update-initramfs -u -k $(uname -r) || true message="--------------------------------------------------------------------------------" ; broadcast else - /usr/sbin/update-initramfs -c -k $(uname -r) || true + update-initramfs -c -k $(uname -r) || true message="--------------------------------------------------------------------------------" ; broadcast fi if [ -f /boot/firmware/initrd.img ] ; then @@ -237,22 +237,22 @@ check_running_system () { } format_boot () { - message="/sbin/mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast - LC_ALL=C /sbin/mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} + message="mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} + message="mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_single_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} + message="mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } @@ -291,20 +291,20 @@ copy_rootfs () { message="INFO: [mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: Copying: Kernel modules" ; broadcast mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true - message="INFO: /usr/bin/rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache @@ -418,12 +418,12 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,,${partition_one_fstype},* __EOF__ @@ -438,7 +438,7 @@ partition_drive () { copy_rootfs elif [ "x${rfs_partition}" = "xdual" ] ; then partition_one_start_mb=${rfs_boot_startmb:-"1"} - partition_one_size_mb=${rfs_boot_size_mb:-"128"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) @@ -454,25 +454,25 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast else - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast fi message="--------------------------------------------------------------------------------" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- ${partition_three_start_mb}M,,,- __EOF__ else - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,,,- __EOF__ @@ -492,7 +492,7 @@ partition_drive () { format_boot format_root if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/mkswap ${destination}p2 + LC_ALL=C mkswap ${destination}p2 fi message="INFO: Formatting: ${destination} complete" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast diff --git a/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-boot-emmc-rootfs-nvme b/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-boot-emmc-rootfs-nvme index 3cab872c9c3d304868534f90bd48ed4fae64e94d..5979873e87680dd1b2f8e12c69de2e04055a37b3 100755 --- a/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-boot-emmc-rootfs-nvme +++ b/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-boot-emmc-rootfs-nvme @@ -6,7 +6,7 @@ if ! id | grep -q root; then exit fi -version_message="1.20240308.0, vfat mount permissions..." +version_message="1.20240620.0, fix extlinux.conf location..." #Debian 12, Ubuntu Lunar, Mantic, Noble #https://packages.debian.org/source/bookworm/e2fsprogs @@ -116,17 +116,6 @@ broadcast_over_display () { } example_failure () { - message="Example: /etc/default/beagle-flasher" ; broadcast - message="--------------------------------------------------------------------------------" ; broadcast - message="source=/dev/mmcblk0" ; broadcast - message="destination=/dev/mmcblk1" ; broadcast - message="rfs_partition=dual" ; broadcast - message="rfs_boot_startmb=1" ; broadcast - message="rfs_boot_size_mb=256" ; broadcast - message="bootloader=/opt/u-boot/bb-u-boot-beagleboneai64/install-emmc.sh" ; broadcast - message="flash_back=bbai64-emmc-to-microsd" ; broadcast - message="extlinux=/opt/u-boot/bb-u-boot-beagleboneai64/emmc-extlinux.conf" ; broadcast - message="--------------------------------------------------------------------------------" ; broadcast exit 2 } @@ -215,10 +204,10 @@ check_running_system () { message="INFO: Generating: [/boot/initrd.img-$(uname -r)]" ; broadcast message="update-initramfs: Generating /boot/initrd.img-$(uname -r)" ; broadcast_over_display if [ -f /boot/initrd.img-$(uname -r) ] ; then - /usr/sbin/update-initramfs -u -k $(uname -r) || true + update-initramfs -u -k $(uname -r) || true message="--------------------------------------------------------------------------------" ; broadcast else - /usr/sbin/update-initramfs -c -k $(uname -r) || true + update-initramfs -c -k $(uname -r) || true message="--------------------------------------------------------------------------------" ; broadcast fi if [ -f /boot/firmware/initrd.img ] ; then @@ -237,26 +226,39 @@ check_running_system () { } format_boot () { - message="/sbin/mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast - LC_ALL=C /sbin/mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} + message="mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} + message="mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_single_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} + message="mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } +copy_boot_extlinux () { + message="Updating extlinux.conf" ; broadcast + + if [ -f ${extlinux} ] ; then + message="INFO: [/boot/firmware/extlinux/extlinux.conf]" ; broadcast + cp -v ${extlinux} /boot/firmware/extlinux/extlinux.conf + message="INFO: [cat /boot/firmware/extlinux/extlinux.conf]" ; broadcast + message="`cat /boot/firmware/extlinux/extlinux.conf`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + fi + flush_cache +} + copy_rootfs () { message="INFO: Copying: ${source}p${src_rfs_part} -> ${destination}p${dest_rfs_part}" ; broadcast mkdir -p /tmp/rootfs/ || true @@ -264,20 +266,20 @@ copy_rootfs () { message="INFO: [mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: Copying: Kernel modules" ; broadcast mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true - message="INFO: /usr/bin/rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache @@ -286,6 +288,9 @@ copy_rootfs () { echo "#" >> /tmp/rootfs/etc/fstab echo "${destination}p${dest_rfs_part} / ext4 noatime,errors=remount-ro 0 1" >> /tmp/rootfs/etc/fstab echo "${source}p1 /boot/firmware vfat ${rfs_boot_permissions} 0 0" >> /tmp/rootfs/etc/fstab + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + echo "${destination}p1 none swap sw 0 0" >>/tmp/rootfs/etc/fstab + fi echo "debugfs /sys/kernel/debug debugfs mode=755,uid=root,gid=gpio,defaults 0 0" >> /tmp/rootfs/etc/fstab message="INFO: [cat /tmp/rootfs/etc/fstab]" ; broadcast message="`cat /tmp/rootfs/etc/fstab`" ; broadcast @@ -350,12 +355,12 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,,${partition_one_fstype},* __EOF__ @@ -372,19 +377,46 @@ partition_drive () { src_rfs_part=${src_rfs_part:-"2"} dest_rfs_part="1" fi + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xhybrid_swap" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb="${rfs_swap_size_mb}" + partition_one_fstype=${rfs_sfdisk_fstype:-"0x82"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + rootfs_label=${rootfs_label:-"rootfs"} + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},- + ${partition_two_start_mb}M,,,- + __EOF__ + + flush_cache + + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="2" + + message="INFO: Formatting: ${destination}" ; broadcast + format_root + LC_ALL=C mkswap ${destination}p1 + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot_extlinux copy_rootfs - if [ "x${extlinux}" != "x" ] ; then - if [ -f ${extlinux} ] ; then - message="INFO: [/boot/firmware/extlinux/extlinux.conf]" ; broadcast - cp -v ${extlinux} /boot/firmware/extlinux/extlinux.conf - message="INFO: [cat /boot/firmware/extlinux/extlinux.conf]" ; broadcast - message="`cat /boot/firmware/extlinux/extlinux.conf`" ; broadcast - message="--------------------------------------------------------------------------------" ; broadcast - fi - fi elif [ "x${rfs_partition}" = "xdual" ] ; then partition_one_start_mb=${rfs_boot_startmb:-"1"} - partition_one_size_mb=${rfs_boot_size_mb:-"128"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) @@ -400,25 +432,25 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast else - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast fi message="--------------------------------------------------------------------------------" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- ${partition_three_start_mb}M,,,- __EOF__ else - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,,,- __EOF__ @@ -438,7 +470,7 @@ partition_drive () { format_boot format_root if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/mkswap ${destination}p2 + LC_ALL=C mkswap ${destination}p2 fi message="INFO: Formatting: ${destination} complete" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast diff --git a/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-boot-mmc-rootfs-sda b/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-boot-mmc-rootfs-sda index ae896d2953657f67793b6a0f06d06afa6e53c15c..e32a0c68ba689b408adf298a2892c04f904b010d 100755 --- a/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-boot-mmc-rootfs-sda +++ b/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-boot-mmc-rootfs-sda @@ -6,7 +6,7 @@ if ! id | grep -q root; then exit fi -version_message="1.20240308.0, vfat mount permissions..." +version_message="1.20240620.0, fix extlinux.conf location..." #Debian 12, Ubuntu Lunar, Mantic, Noble #https://packages.debian.org/source/bookworm/e2fsprogs @@ -215,10 +215,10 @@ check_running_system () { message="INFO: Generating: [/boot/initrd.img-$(uname -r)]" ; broadcast message="update-initramfs: Generating /boot/initrd.img-$(uname -r)" ; broadcast_over_display if [ -f /boot/initrd.img-$(uname -r) ] ; then - /usr/sbin/update-initramfs -u -k $(uname -r) || true + update-initramfs -u -k $(uname -r) || true message="--------------------------------------------------------------------------------" ; broadcast else - /usr/sbin/update-initramfs -c -k $(uname -r) || true + update-initramfs -c -k $(uname -r) || true message="--------------------------------------------------------------------------------" ; broadcast fi if [ -f /boot/firmware/initrd.img ] ; then @@ -237,26 +237,39 @@ check_running_system () { } format_boot () { - message="/sbin/mkfs.vfat -F 16 ${destination}1 -n ${boot_label}" ; broadcast - LC_ALL=C /sbin/mkfs.vfat -F 16 ${destination}1 -n ${boot_label} + message="mkfs.vfat -F 16 ${destination}1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}1 -n ${boot_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}${dest_rfs_part} -L ${rootfs_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}${dest_rfs_part} -L ${rootfs_label} + message="mkfs.ext4 ${ext4_options} ${destination}${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}${dest_rfs_part} -L ${rootfs_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_single_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}1 -L ${single_root_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}1 -L ${single_root_label} + message="mkfs.ext4 ${ext4_options} ${destination}1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}1 -L ${single_root_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } +copy_boot_extlinux () { + message="Updating extlinux.conf" ; broadcast + + if [ -f ${extlinux} ] ; then + message="INFO: [/boot/firmware/extlinux/extlinux.conf]" ; broadcast + cp -v ${extlinux} /boot/firmware/extlinux/extlinux.conf + message="INFO: [cat /boot/firmware/extlinux/extlinux.conf]" ; broadcast + message="`cat /boot/firmware/extlinux/extlinux.conf`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + fi + flush_cache +} + copy_rootfs () { message="INFO: Copying: ${source}p${src_rfs_part} -> ${destination}${dest_rfs_part}" ; broadcast mkdir -p /tmp/rootfs/ || true @@ -264,20 +277,20 @@ copy_rootfs () { message="INFO: [mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: Copying: Kernel modules" ; broadcast mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true - message="INFO: /usr/bin/rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache @@ -286,6 +299,9 @@ copy_rootfs () { echo "#" >> /tmp/rootfs/etc/fstab echo "${destination}${dest_rfs_part} / ext4 noatime,errors=remount-ro 0 1" >> /tmp/rootfs/etc/fstab echo "${source}p1 /boot/firmware vfat ${rfs_boot_permissions} 0 0" >> /tmp/rootfs/etc/fstab + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + echo "${destination}1 none swap sw 0 0" >>/tmp/rootfs/etc/fstab + fi echo "debugfs /sys/kernel/debug debugfs mode=755,uid=root,gid=gpio,defaults 0 0" >> /tmp/rootfs/etc/fstab message="INFO: [cat /tmp/rootfs/etc/fstab]" ; broadcast message="`cat /tmp/rootfs/etc/fstab`" ; broadcast @@ -350,12 +366,12 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,,${partition_one_fstype},* __EOF__ @@ -372,19 +388,46 @@ partition_drive () { src_rfs_part=${src_rfs_part:-"2"} dest_rfs_part="1" fi + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xhybrid_swap" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb="${rfs_swap_size_mb}" + partition_one_fstype=${rfs_sfdisk_fstype:-"0x82"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + rootfs_label=${rootfs_label:-"rootfs"} + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},- + ${partition_two_start_mb}M,,,- + __EOF__ + + flush_cache + + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="2" + + message="INFO: Formatting: ${destination}" ; broadcast + format_root + LC_ALL=C mkswap ${destination}1 + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot_extlinux copy_rootfs - if [ "x${extlinux}" != "x" ] ; then - if [ -f ${extlinux} ] ; then - message="INFO: [/boot/firmware/extlinux/extlinux.conf]" ; broadcast - cp -v ${extlinux} /boot/firmware/extlinux/extlinux.conf - message="INFO: [cat /boot/firmware/extlinux/extlinux.conf]" ; broadcast - message="`cat /boot/firmware/extlinux/extlinux.conf`" ; broadcast - message="--------------------------------------------------------------------------------" ; broadcast - fi - fi elif [ "x${rfs_partition}" = "xdual" ] ; then partition_one_start_mb=${rfs_boot_startmb:-"1"} - partition_one_size_mb=${rfs_boot_size_mb:-"128"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) @@ -400,25 +443,25 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast else - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast fi message="--------------------------------------------------------------------------------" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- ${partition_three_start_mb}M,,,- __EOF__ else - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,,,- __EOF__ @@ -438,7 +481,7 @@ partition_drive () { format_boot format_root if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/mkswap ${destination}2 + LC_ALL=C mkswap ${destination}2 fi message="INFO: Formatting: ${destination} complete" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast diff --git a/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-mv-rootfs-to-nvme b/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-mv-rootfs-to-nvme new file mode 100755 index 0000000000000000000000000000000000000000..a3840a9f16bb697ba23c8bc52b8820d32a4b1b0f --- /dev/null +++ b/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-mv-rootfs-to-nvme @@ -0,0 +1,503 @@ +#!/bin/bash -e + +if ! id | grep -q root; then + echo "beagle-flasher-mv-rootfs-to-nvme must be run as root:" + echo "sudo beagle-flasher-mv-rootfs-to-nvme" + exit +fi + +version_message="1.20240620.0, fix extlinux.conf location..." + +#Debian 12, Ubuntu Lunar, Mantic, Noble +#https://packages.debian.org/source/bookworm/e2fsprogs +#e2fsprogs (1.47.0) added orphan_file first added in v5.15.x +unset ext4_options +#ext4_options="-O ^orphan_file" + +cylon_leds() { + #ls /sys/class/leds/beaglebone\:green\:usr* + #cat /sys/class/leds/beaglebone\:green\:usr*/trigger + local leds_base=/sys/class/leds/beaglebone\:green\:usr + if [ -e ${leds_base}0/trigger ] ; then + echo none > ${leds_base}0/trigger || true + echo none > ${leds_base}1/trigger || true + echo none > ${leds_base}2/trigger || true + echo none > ${leds_base}3/trigger || true + + STATE=1 + while : ; do + case $STATE in + 1) + echo 1 > ${leds_base}0/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=2 + ;; + 2) + echo 1 > ${leds_base}1/brightness || true + echo 0 > ${leds_base}0/brightness || true + STATE=3 + ;; + 3) + echo 1 > ${leds_base}2/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=4 + ;; + 4) + echo 1 > ${leds_base}3/brightness || true + echo 0 > ${leds_base}2/brightness || true + STATE=5 + ;; + 5) + echo 1 > ${leds_base}2/brightness || true + echo 0 > ${leds_base}3/brightness || true + STATE=6 + ;; + 6) + echo 1 > ${leds_base}1/brightness || true + echo 0 > ${leds_base}2/brightness || true + STATE=1 + ;; + *) + echo 1 > ${leds_base}0/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=2 + ;; + esac + sleep 0.1 + done + fi +} + +reset_leds() { + if [ "x${has_usr_leds}" = "xenable" ] ; then + if [ -e /proc/$CYLON_PID ]; then + kill $CYLON_PID > /dev/null 2>&1 + fi + + leds_pattern0=${leds_pattern0:-"heartbeat"} + leds_pattern1=${leds_pattern1:-"mmc0"} + leds_pattern2=${leds_pattern2:-"activity"} + leds_pattern3=${leds_pattern3:-"mmc1"} + leds_base=/sys/class/leds/beaglebone\:green\:usr + + if [ -e ${leds_base}0/trigger ] ; then + echo ${leds_pattern0} > ${leds_base}0/trigger || true + echo ${leds_pattern1} > ${leds_base}1/trigger || true + echo ${leds_pattern2} > ${leds_base}2/trigger || true + echo ${leds_pattern3} > ${leds_base}3/trigger || true + fi + fi +} + +flush_cache () { + sync + if [ "x${destination}" != "x" ] ; then + message="INFO: flush_cache: [blockdev --flushbufs ${destination}]" ; broadcast + blockdev --flushbufs ${destination} || true + message="--------------------------------------------------------------------------------" ; broadcast + fi +} + +broadcast () { + if [ "x${message}" != "x" ] ; then + echo "${message}" + if [ "x${debug_over_display}" != "x" ] ; then + echo "${message}" > /dev/${debug_over_display} || true + fi + fi +} + +broadcast_over_display () { + if [ "x${message}" != "x" ] ; then + if [ "x${debug_over_display}" != "x" ] ; then + echo "${message}" > /dev/${debug_over_display} || true + fi + fi +} + +example_failure () { + exit 2 +} + +write_failure () { + message="ERROR: writing to [destination=${destination}] failed..." ; broadcast + + if [ "x${has_usr_leds}" = "xenable" ] ; then + if [ -e /proc/$CYLON_PID ]; then + kill $CYLON_PID > /dev/null 2>&1 + fi + + leds_pattern0=${leds_pattern0:-"heartbeat"} + leds_pattern1=${leds_pattern1:-"heartbeat"} + leds_pattern2=${leds_pattern2:-"heartbeat"} + leds_pattern3=${leds_pattern3:-"heartbeat"} + leds_base=/sys/class/leds/beaglebone\:green\:usr + + if [ -e ${leds_base}0/trigger ] ; then + echo ${leds_pattern0} > ${leds_base}0/trigger || true + echo ${leds_pattern1} > ${leds_base}1/trigger || true + echo ${leds_pattern2} > ${leds_base}2/trigger || true + echo ${leds_pattern3} > ${leds_base}3/trigger || true + fi + message="Debug: Setting Heartbeat" ; broadcast + fi + + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + if [ "x${destination}" != "x" ] ; then + umount ${destination}p1 > /dev/null 2>&1 || true + fi +} + +check_running_system () { + + message="INFO: /proc/cmdline" ; broadcast + message="INFO: [cat /proc/cmdline]" ; broadcast + cat /proc/cmdline + message="--------------------------------------------------------------------------------" ; broadcast + + has_usr_leds="enable" + + if [ "x${has_usr_leds}" = "xenable" ] ; then + cylon_leds & CYLON_PID=$! + fi + + if [ "x${source}" != "x" ] && [ "x${destination}" != "x" ] ; then + message="INFO: [lsblk -i]" ; broadcast + message="`lsblk -i || true`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="INFO: copying [${source}] -> [${destination}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + else + message="INFO: [lsblk -i]" ; broadcast + message="`lsblk -i || true`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="ERROR: Setup: [source] and [destination] in /etc/default/beagle-flasher" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + fi + + if [ ! -b "${source}" ] ; then + message="ERROR: [source=${source}] does not exist" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + else + message="INFO: [source=${source}] is a valid block device" ; broadcast + fi + + if [ ! -b "${destination}" ] ; then + message="ERROR: [destination=${destination}] does not exist" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + else + message="INFO: [destination=${destination}] is a valid block device" ; broadcast + fi + + if [ ! -f /boot/config-$(uname -r) ] ; then + zcat /proc/config.gz > /boot/config-$(uname -r) || true + message="INFO: Creating: [/boot/config-$(uname -r)]" ; broadcast + else + message="INFO: [/boot/config-$(uname -r)]" ; broadcast + fi + + if [ -f /usr/sbin/update-initramfs ] ; then + message="INFO: Generating: [/boot/initrd.img-$(uname -r)]" ; broadcast + message="update-initramfs: Generating /boot/initrd.img-$(uname -r)" ; broadcast_over_display + if [ -f /boot/initrd.img-$(uname -r) ] ; then + update-initramfs -u -k $(uname -r) || true + message="--------------------------------------------------------------------------------" ; broadcast + else + update-initramfs -c -k $(uname -r) || true + message="--------------------------------------------------------------------------------" ; broadcast + fi + if [ -f /boot/firmware/initrd.img ] ; then + cp -v /boot/initrd.img-$(uname -r) /boot/firmware/initrd.img + fi + fi + flush_cache + + if [ -f /etc/default/generic-sys-mods ] ; then + message="INFO: [cat /etc/default/generic-sys-mods]" ; broadcast + cat /etc/default/generic-sys-mods + . /etc/default/generic-sys-mods + src_rfs_part=${ROOT_PARTITION} + message="--------------------------------------------------------------------------------" ; broadcast + fi +} + +format_boot () { + message="mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +format_root () { + message="mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +format_single_root () { + message="mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +copy_boot_extlinux () { + message="Updating extlinux.conf" ; broadcast + + if [ -f ${extlinux} ] ; then + message="INFO: [/boot/firmware/extlinux/extlinux.conf]" ; broadcast + cp -v ${extlinux} /boot/firmware/extlinux/extlinux.conf + message="INFO: [cat /boot/firmware/extlinux/extlinux.conf]" ; broadcast + message="`cat /boot/firmware/extlinux/extlinux.conf`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + fi + flush_cache +} + +copy_rootfs () { + message="INFO: Copying: ${source}p${src_rfs_part} -> ${destination}p${dest_rfs_part}" ; broadcast + mkdir -p /tmp/rootfs/ || true + + message="INFO: [mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast + mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Copying: Kernel modules" ; broadcast + mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Generating: /etc/fstab" ; broadcast + echo "# /etc/fstab: static file system information." > /tmp/rootfs/etc/fstab + echo "#" >> /tmp/rootfs/etc/fstab + echo "${destination}p${dest_rfs_part} / ext4 noatime,errors=remount-ro 0 1" >> /tmp/rootfs/etc/fstab + echo "${source}p1 /boot/firmware vfat ${rfs_boot_permissions} 0 0" >> /tmp/rootfs/etc/fstab + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + echo "${destination}p1 none swap sw 0 0" >>/tmp/rootfs/etc/fstab + fi + echo "debugfs /sys/kernel/debug debugfs mode=755,uid=root,gid=gpio,defaults 0 0" >> /tmp/rootfs/etc/fstab + message="INFO: [cat /tmp/rootfs/etc/fstab]" ; broadcast + message="`cat /tmp/rootfs/etc/fstab`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + if [ -f /tmp/rootfs/etc/systemd/system/multi-user.target.wants/grow_partition.service ] ; then + rm -rf /tmp/rootfs/etc/systemd/system/multi-user.target.wants/grow_partition.service || true + fi + flush_cache + + message="Copying: ${source}p${src_rfs_part} -> ${destination}p${dest_rfs_part} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: [umount /tmp/rootfs/ || umount -l /tmp/rootfs/ || write_failure]" ; broadcast + umount /tmp/rootfs/ || umount -l /tmp/rootfs/ || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + + message="INFO: Force writeback of eMMC buffers by Syncing: ${destination}" ; broadcast + message="INFO: [dd if=${destination} of=/dev/null count=100000 status=progress]" ; broadcast + dd if=${destination} of=/dev/null count=100000 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + if [ "x${has_usr_leds}" = "xenable" ] ; then + reset_leds + fi +} + +partition_drive () { + message="INFO: Erasing: [${destination}]" ; broadcast + flush_cache + message="INFO: [dd if=/dev/zero of=${destination} bs=1M count=148 status=progress]" ; broadcast + dd if=/dev/zero of=${destination} bs=1M count=148 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + sync + message="INFO: [dd if=${destination} of=/dev/null bs=1M count=148 status=progress]" ; broadcast + dd if=${destination} of=/dev/null bs=1M count=148 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + sync + flush_cache + message="INFO: Erasing: [${destination}] complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${bootloader}" != "x" ] ; then + if [ -f ${bootloader} ] ; then + message="INFO: [/bin/bash ${bootloader}]" ; broadcast + /bin/bash ${bootloader} + message="--------------------------------------------------------------------------------" ; broadcast + fi + fi + + rfs_boot_permissions=${rfs_boot_permissions:-"defaults"} + + if [ "x${rfs_partition}" = "xhybrid" ] ; then + partition_one_start_mb=${rfs_rootfs_startmb:-"1"} + partition_one_fstype=${rfs_sfdisk_fstype:-"L"} + + single_root_label=${single_root_label:-"rootfs"} + + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,,${partition_one_fstype},* + __EOF__ + + flush_cache + message="INFO: Formatting: ${destination}" ; broadcast + format_single_root + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="1" + else + src_rfs_part=${src_rfs_part:-"2"} + dest_rfs_part="1" + fi + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xhybrid_swap" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb="${rfs_swap_size_mb}" + partition_one_fstype=${rfs_sfdisk_fstype:-"0x82"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + rootfs_label=${rootfs_label:-"rootfs"} + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},- + ${partition_two_start_mb}M,,,- + __EOF__ + + flush_cache + + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="2" + + message="INFO: Formatting: ${destination}" ; broadcast + format_root + LC_ALL=C mkswap ${destination}p1 + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xdual" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} + partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + partition_two_size_mb="${rfs_swap_size_mb}" + partition_three_start_mb=$(($partition_one_start_mb + $partition_one_size_mb + $partition_two_size_mb)) + fi + + boot_label=${boot_label:-"FIRMWARE"} + rootfs_label=${rootfs_label:-"rootfs"} + + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + else + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + fi + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* + ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- + ${partition_three_start_mb}M,,,- + __EOF__ + else + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* + ${partition_two_start_mb}M,,,- + __EOF__ + fi + + flush_cache + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="3" + else + src_rfs_part=${src_rfs_part:-"2"} + dest_rfs_part="2" + fi + + message="INFO: Formatting: ${destination}" ; broadcast + format_boot + format_root + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + LC_ALL=C mkswap ${destination}p2 + fi + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot + copy_rootfs + else + example_failure + fi +} + +###FIXME +if [ -f /etc/default/beagle-flasher ] ; then + . /etc/default/beagle-flasher + message="--------------------------------------------------------------------------------" ; broadcast + message="Version: [${version_message}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="cat /etc/default/beagle-flasher:" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="`cat /etc/default/beagle-flasher`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast +else + message="--------------------------------------------------------------------------------" ; broadcast + message="Version: [${version_message}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure +fi + +check_running_system +partition_drive diff --git a/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-mv-rootfs-to-sda b/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-mv-rootfs-to-sda new file mode 100755 index 0000000000000000000000000000000000000000..1e6015882ca412aa955c847788502585aecba6c3 --- /dev/null +++ b/bb-beagle-flasher/suite/bullseye/debian/beagle-flasher-mv-rootfs-to-sda @@ -0,0 +1,503 @@ +#!/bin/bash -e + +if ! id | grep -q root; then + echo "beagle-flasher-mv-rootfs-to-sda must be run as root:" + echo "sudo beagle-flasher-mv-rootfs-to-sda" + exit +fi + +version_message="1.20240620.0, fix extlinux.conf location..." + +#Debian 12, Ubuntu Lunar, Mantic, Noble +#https://packages.debian.org/source/bookworm/e2fsprogs +#e2fsprogs (1.47.0) added orphan_file first added in v5.15.x +unset ext4_options +#ext4_options="-O ^orphan_file" + +cylon_leds() { + #ls /sys/class/leds/beaglebone\:green\:usr* + #cat /sys/class/leds/beaglebone\:green\:usr*/trigger + local leds_base=/sys/class/leds/beaglebone\:green\:usr + if [ -e ${leds_base}0/trigger ] ; then + echo none > ${leds_base}0/trigger || true + echo none > ${leds_base}1/trigger || true + echo none > ${leds_base}2/trigger || true + echo none > ${leds_base}3/trigger || true + + STATE=1 + while : ; do + case $STATE in + 1) + echo 1 > ${leds_base}0/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=2 + ;; + 2) + echo 1 > ${leds_base}1/brightness || true + echo 0 > ${leds_base}0/brightness || true + STATE=3 + ;; + 3) + echo 1 > ${leds_base}2/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=4 + ;; + 4) + echo 1 > ${leds_base}3/brightness || true + echo 0 > ${leds_base}2/brightness || true + STATE=5 + ;; + 5) + echo 1 > ${leds_base}2/brightness || true + echo 0 > ${leds_base}3/brightness || true + STATE=6 + ;; + 6) + echo 1 > ${leds_base}1/brightness || true + echo 0 > ${leds_base}2/brightness || true + STATE=1 + ;; + *) + echo 1 > ${leds_base}0/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=2 + ;; + esac + sleep 0.1 + done + fi +} + +reset_leds() { + if [ "x${has_usr_leds}" = "xenable" ] ; then + if [ -e /proc/$CYLON_PID ]; then + kill $CYLON_PID > /dev/null 2>&1 + fi + + leds_pattern0=${leds_pattern0:-"heartbeat"} + leds_pattern1=${leds_pattern1:-"mmc0"} + leds_pattern2=${leds_pattern2:-"activity"} + leds_pattern3=${leds_pattern3:-"mmc1"} + leds_base=/sys/class/leds/beaglebone\:green\:usr + + if [ -e ${leds_base}0/trigger ] ; then + echo ${leds_pattern0} > ${leds_base}0/trigger || true + echo ${leds_pattern1} > ${leds_base}1/trigger || true + echo ${leds_pattern2} > ${leds_base}2/trigger || true + echo ${leds_pattern3} > ${leds_base}3/trigger || true + fi + fi +} + +flush_cache () { + sync + if [ "x${destination}" != "x" ] ; then + message="INFO: flush_cache: [blockdev --flushbufs ${destination}]" ; broadcast + blockdev --flushbufs ${destination} || true + message="--------------------------------------------------------------------------------" ; broadcast + fi +} + +broadcast () { + if [ "x${message}" != "x" ] ; then + echo "${message}" + if [ "x${debug_over_display}" != "x" ] ; then + echo "${message}" > /dev/${debug_over_display} || true + fi + fi +} + +broadcast_over_display () { + if [ "x${message}" != "x" ] ; then + if [ "x${debug_over_display}" != "x" ] ; then + echo "${message}" > /dev/${debug_over_display} || true + fi + fi +} + +example_failure () { + exit 2 +} + +write_failure () { + message="ERROR: writing to [destination=${destination}] failed..." ; broadcast + + if [ "x${has_usr_leds}" = "xenable" ] ; then + if [ -e /proc/$CYLON_PID ]; then + kill $CYLON_PID > /dev/null 2>&1 + fi + + leds_pattern0=${leds_pattern0:-"heartbeat"} + leds_pattern1=${leds_pattern1:-"heartbeat"} + leds_pattern2=${leds_pattern2:-"heartbeat"} + leds_pattern3=${leds_pattern3:-"heartbeat"} + leds_base=/sys/class/leds/beaglebone\:green\:usr + + if [ -e ${leds_base}0/trigger ] ; then + echo ${leds_pattern0} > ${leds_base}0/trigger || true + echo ${leds_pattern1} > ${leds_base}1/trigger || true + echo ${leds_pattern2} > ${leds_base}2/trigger || true + echo ${leds_pattern3} > ${leds_base}3/trigger || true + fi + message="Debug: Setting Heartbeat" ; broadcast + fi + + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + if [ "x${destination}" != "x" ] ; then + umount ${destination}1 > /dev/null 2>&1 || true + fi +} + +check_running_system () { + + message="INFO: /proc/cmdline" ; broadcast + message="INFO: [cat /proc/cmdline]" ; broadcast + cat /proc/cmdline + message="--------------------------------------------------------------------------------" ; broadcast + + has_usr_leds="enable" + + if [ "x${has_usr_leds}" = "xenable" ] ; then + cylon_leds & CYLON_PID=$! + fi + + if [ "x${source}" != "x" ] && [ "x${destination}" != "x" ] ; then + message="INFO: [lsblk -i]" ; broadcast + message="`lsblk -i || true`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="INFO: copying [${source}] -> [${destination}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + else + message="INFO: [lsblk -i]" ; broadcast + message="`lsblk -i || true`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="ERROR: Setup: [source] and [destination] in /etc/default/beagle-flasher" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + fi + + if [ ! -b "${source}" ] ; then + message="ERROR: [source=${source}] does not exist" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + else + message="INFO: [source=${source}] is a valid block device" ; broadcast + fi + + if [ ! -b "${destination}" ] ; then + message="ERROR: [destination=${destination}] does not exist" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + else + message="INFO: [destination=${destination}] is a valid block device" ; broadcast + fi + + if [ ! -f /boot/config-$(uname -r) ] ; then + zcat /proc/config.gz > /boot/config-$(uname -r) || true + message="INFO: Creating: [/boot/config-$(uname -r)]" ; broadcast + else + message="INFO: [/boot/config-$(uname -r)]" ; broadcast + fi + + if [ -f /usr/sbin/update-initramfs ] ; then + message="INFO: Generating: [/boot/initrd.img-$(uname -r)]" ; broadcast + message="update-initramfs: Generating /boot/initrd.img-$(uname -r)" ; broadcast_over_display + if [ -f /boot/initrd.img-$(uname -r) ] ; then + update-initramfs -u -k $(uname -r) || true + message="--------------------------------------------------------------------------------" ; broadcast + else + update-initramfs -c -k $(uname -r) || true + message="--------------------------------------------------------------------------------" ; broadcast + fi + if [ -f /boot/firmware/initrd.img ] ; then + cp -v /boot/initrd.img-$(uname -r) /boot/firmware/initrd.img + fi + fi + flush_cache + + if [ -f /etc/default/generic-sys-mods ] ; then + message="INFO: [cat /etc/default/generic-sys-mods]" ; broadcast + cat /etc/default/generic-sys-mods + . /etc/default/generic-sys-mods + src_rfs_part=${ROOT_PARTITION} + message="--------------------------------------------------------------------------------" ; broadcast + fi +} + +format_boot () { + message="mkfs.vfat -F 16 ${destination}1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}1 -n ${boot_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +format_root () { + message="mkfs.ext4 ${ext4_options} ${destination}${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}${dest_rfs_part} -L ${rootfs_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +format_single_root () { + message="mkfs.ext4 ${ext4_options} ${destination}1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}1 -L ${single_root_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +copy_boot_extlinux () { + message="Updating extlinux.conf" ; broadcast + + if [ -f ${extlinux} ] ; then + message="INFO: [/boot/firmware/extlinux/extlinux.conf]" ; broadcast + cp -v ${extlinux} /boot/firmware/extlinux/extlinux.conf + message="INFO: [cat /boot/firmware/extlinux/extlinux.conf]" ; broadcast + message="`cat /boot/firmware/extlinux/extlinux.conf`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + fi + flush_cache +} + +copy_rootfs () { + message="INFO: Copying: ${source}p${src_rfs_part} -> ${destination}${dest_rfs_part}" ; broadcast + mkdir -p /tmp/rootfs/ || true + + message="INFO: [mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast + mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Copying: Kernel modules" ; broadcast + mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Generating: /etc/fstab" ; broadcast + echo "# /etc/fstab: static file system information." > /tmp/rootfs/etc/fstab + echo "#" >> /tmp/rootfs/etc/fstab + echo "${destination}${dest_rfs_part} / ext4 noatime,errors=remount-ro 0 1" >> /tmp/rootfs/etc/fstab + echo "${source}p1 /boot/firmware vfat ${rfs_boot_permissions} 0 0" >> /tmp/rootfs/etc/fstab + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + echo "${destination}1 none swap sw 0 0" >>/tmp/rootfs/etc/fstab + fi + echo "debugfs /sys/kernel/debug debugfs mode=755,uid=root,gid=gpio,defaults 0 0" >> /tmp/rootfs/etc/fstab + message="INFO: [cat /tmp/rootfs/etc/fstab]" ; broadcast + message="`cat /tmp/rootfs/etc/fstab`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + if [ -f /tmp/rootfs/etc/systemd/system/multi-user.target.wants/grow_partition.service ] ; then + rm -rf /tmp/rootfs/etc/systemd/system/multi-user.target.wants/grow_partition.service || true + fi + flush_cache + + message="Copying: ${source}p${src_rfs_part} -> ${destination}${dest_rfs_part} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: [umount /tmp/rootfs/ || umount -l /tmp/rootfs/ || write_failure]" ; broadcast + umount /tmp/rootfs/ || umount -l /tmp/rootfs/ || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + + message="INFO: Force writeback of eMMC buffers by Syncing: ${destination}" ; broadcast + message="INFO: [dd if=${destination} of=/dev/null count=100000 status=progress]" ; broadcast + dd if=${destination} of=/dev/null count=100000 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + if [ "x${has_usr_leds}" = "xenable" ] ; then + reset_leds + fi +} + +partition_drive () { + message="INFO: Erasing: [${destination}]" ; broadcast + flush_cache + message="INFO: [dd if=/dev/zero of=${destination} bs=1M count=148 status=progress]" ; broadcast + dd if=/dev/zero of=${destination} bs=1M count=148 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + sync + message="INFO: [dd if=${destination} of=/dev/null bs=1M count=148 status=progress]" ; broadcast + dd if=${destination} of=/dev/null bs=1M count=148 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + sync + flush_cache + message="INFO: Erasing: [${destination}] complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${bootloader}" != "x" ] ; then + if [ -f ${bootloader} ] ; then + message="INFO: [/bin/bash ${bootloader}]" ; broadcast + /bin/bash ${bootloader} + message="--------------------------------------------------------------------------------" ; broadcast + fi + fi + + rfs_boot_permissions=${rfs_boot_permissions:-"defaults"} + + if [ "x${rfs_partition}" = "xhybrid" ] ; then + partition_one_start_mb=${rfs_rootfs_startmb:-"1"} + partition_one_fstype=${rfs_sfdisk_fstype:-"L"} + + single_root_label=${single_root_label:-"rootfs"} + + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,,${partition_one_fstype},* + __EOF__ + + flush_cache + message="INFO: Formatting: ${destination}" ; broadcast + format_single_root + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="1" + else + src_rfs_part=${src_rfs_part:-"2"} + dest_rfs_part="1" + fi + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xhybrid_swap" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb="${rfs_swap_size_mb}" + partition_one_fstype=${rfs_sfdisk_fstype:-"0x82"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + rootfs_label=${rootfs_label:-"rootfs"} + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},- + ${partition_two_start_mb}M,,,- + __EOF__ + + flush_cache + + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="2" + + message="INFO: Formatting: ${destination}" ; broadcast + format_root + LC_ALL=C mkswap ${destination}1 + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xdual" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} + partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + partition_two_size_mb="${rfs_swap_size_mb}" + partition_three_start_mb=$(($partition_one_start_mb + $partition_one_size_mb + $partition_two_size_mb)) + fi + + boot_label=${boot_label:-"FIRMWARE"} + rootfs_label=${rootfs_label:-"rootfs"} + + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + else + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + fi + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* + ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- + ${partition_three_start_mb}M,,,- + __EOF__ + else + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* + ${partition_two_start_mb}M,,,- + __EOF__ + fi + + flush_cache + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="3" + else + src_rfs_part=${src_rfs_part:-"2"} + dest_rfs_part="2" + fi + + message="INFO: Formatting: ${destination}" ; broadcast + format_boot + format_root + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + LC_ALL=C mkswap ${destination}2 + fi + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot + copy_rootfs + else + example_failure + fi +} + +###FIXME +if [ -f /etc/default/beagle-flasher ] ; then + . /etc/default/beagle-flasher + message="--------------------------------------------------------------------------------" ; broadcast + message="Version: [${version_message}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="cat /etc/default/beagle-flasher:" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="`cat /etc/default/beagle-flasher`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast +else + message="--------------------------------------------------------------------------------" ; broadcast + message="Version: [${version_message}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure +fi + +check_running_system +partition_drive diff --git a/bb-beagle-flasher/suite/bullseye/debian/changelog b/bb-beagle-flasher/suite/bullseye/debian/changelog index a74b559ba255cedf21610daa4885455b72fe68cb..1e1c35ca578debfa94dde08fde1200191e54fd8a 100644 --- a/bb-beagle-flasher/suite/bullseye/debian/changelog +++ b/bb-beagle-flasher/suite/bullseye/debian/changelog @@ -1,4 +1,4 @@ -bb-beagle-flasher (1.20240620.0-0~bullseye+20240620) bullseye; urgency=low +bb-beagle-flasher (1.20240718.0-0~bullseye+20240718) bullseye; urgency=low * SK-AM69, support microSD -> usb sata * BBIA64/BeaglePlay, use u-boot versions of script files @@ -8,5 +8,5 @@ bb-beagle-flasher (1.20240620.0-0~bullseye+20240620) bullseye; urgency=low * Remove beagle-flasher-init-shutdown.service, single user will now shutdown * e2fsprogs (1.47.0) disable orphan_file, needs v5.15.x kernel - -- Robert Nelson <robertcnelson@gmail.com> Thu, 20 Jun 2024 09:14:06 -0500 + -- Robert Nelson <robertcnelson@gmail.com> Thu, 18 Jul 2024 11:24:51 -0500 diff --git a/bb-beagle-flasher/suite/bullseye/debian/init-beagle-flasher b/bb-beagle-flasher/suite/bullseye/debian/init-beagle-flasher index 67f3b5a3470ed98b2449133080381d3c0c2f0f68..0a9c5dcc92dd844beb50cfc3762dc0f864fac2e8 100755 --- a/bb-beagle-flasher/suite/bullseye/debian/init-beagle-flasher +++ b/bb-beagle-flasher/suite/bullseye/debian/init-beagle-flasher @@ -5,7 +5,7 @@ if ! id | grep -q root; then exit fi -version_message="1.20240308.0, vfat mount permissions..." +version_message="1.20240620.0, fix extlinux.conf location..." #Debian 12, Ubuntu Lunar, Mantic, Noble #https://packages.debian.org/source/bookworm/e2fsprogs @@ -232,22 +232,22 @@ check_running_system () { } format_boot () { - message="/sbin/mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast - LC_ALL=C /sbin/mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} + message="mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} + message="mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_single_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} + message="mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } @@ -263,15 +263,13 @@ copy_boot () { rsync -aHAXx --human-readable --info=progress2 /boot/firmware/ /tmp/boot/ || write_failure flush_cache - if [ "x${extlinux}" != "x" ] ; then - if [ -f ${extlinux} ] ; then - message="INFO: [/boot/extlinux/extlinux.conf]" ; broadcast - mkdir -p /tmp/boot/extlinux/ || true - cp -v ${extlinux} /tmp/boot/extlinux/extlinux.conf - message="INFO: [cat /tmp/boot/extlinux/extlinux.conf]" ; broadcast - message="`cat /tmp/boot/extlinux/extlinux.conf`" ; broadcast - message="--------------------------------------------------------------------------------" ; broadcast - fi + if [ -f ${extlinux} ] ; then + message="INFO: [/boot/extlinux/extlinux.conf]" ; broadcast + mkdir -p /tmp/boot/extlinux/ || true + cp -v ${extlinux} /tmp/boot/extlinux/extlinux.conf + message="INFO: [cat /tmp/boot/extlinux/extlinux.conf]" ; broadcast + message="`cat /tmp/boot/extlinux/extlinux.conf`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast fi flush_cache @@ -287,15 +285,20 @@ copy_rootfs () { message="INFO: [mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: Copying: Kernel modules" ; broadcast mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true - message="INFO: /usr/bin/rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache @@ -455,12 +458,12 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,,${partition_one_fstype},* __EOF__ @@ -475,7 +478,7 @@ partition_drive () { copy_rootfs elif [ "x${rfs_partition}" = "xdual" ] ; then partition_one_start_mb=${rfs_boot_startmb:-"1"} - partition_one_size_mb=${rfs_boot_size_mb:-"128"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) @@ -491,25 +494,25 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast else - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast fi message="--------------------------------------------------------------------------------" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- ${partition_three_start_mb}M,,,- __EOF__ else - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,,,- __EOF__ @@ -529,7 +532,7 @@ partition_drive () { format_boot format_root if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/mkswap ${destination}p2 + LC_ALL=C mkswap ${destination}p2 fi message="INFO: Formatting: ${destination} complete" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast diff --git a/bb-beagle-flasher/suite/bullseye/debian/init-beagle-flasher-mv-rootfs-to-nvme b/bb-beagle-flasher/suite/bullseye/debian/init-beagle-flasher-mv-rootfs-to-nvme new file mode 100755 index 0000000000000000000000000000000000000000..f84a1327002f78b79186be818127672054709916 --- /dev/null +++ b/bb-beagle-flasher/suite/bullseye/debian/init-beagle-flasher-mv-rootfs-to-nvme @@ -0,0 +1,565 @@ +#!/bin/bash -e + +if ! id | grep -q root; then + echo "must be run as root:" + exit +fi + +version_message="1.20240620.0, fix extlinux.conf location..." + +#Debian 12, Ubuntu Lunar, Mantic, Noble +#https://packages.debian.org/source/bookworm/e2fsprogs +#e2fsprogs (1.47.0) added orphan_file first added in v5.15.x +unset ext4_options +#ext4_options="-O ^orphan_file" + +cylon_leds() { + #ls /sys/class/leds/beaglebone\:green\:usr* + #cat /sys/class/leds/beaglebone\:green\:usr*/trigger + local leds_base=/sys/class/leds/beaglebone\:green\:usr + if [ -e ${leds_base}0/trigger ] ; then + echo none > ${leds_base}0/trigger || true + echo none > ${leds_base}1/trigger || true + echo none > ${leds_base}2/trigger || true + echo none > ${leds_base}3/trigger || true + + STATE=1 + while : ; do + case $STATE in + 1) + echo 1 > ${leds_base}0/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=2 + ;; + 2) + echo 1 > ${leds_base}1/brightness || true + echo 0 > ${leds_base}0/brightness || true + STATE=3 + ;; + 3) + echo 1 > ${leds_base}2/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=4 + ;; + 4) + echo 1 > ${leds_base}3/brightness || true + echo 0 > ${leds_base}2/brightness || true + STATE=5 + ;; + 5) + echo 1 > ${leds_base}2/brightness || true + echo 0 > ${leds_base}3/brightness || true + STATE=6 + ;; + 6) + echo 1 > ${leds_base}1/brightness || true + echo 0 > ${leds_base}2/brightness || true + STATE=1 + ;; + *) + echo 1 > ${leds_base}0/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=2 + ;; + esac + sleep 0.1 + done + fi +} + +reset_leds() { + if [ "x${has_usr_leds}" = "xenable" ] ; then + if [ -e /proc/$CYLON_PID ]; then + kill $CYLON_PID > /dev/null 2>&1 + fi + + leds_pattern0=${leds_pattern0:-"heartbeat"} + leds_pattern1=${leds_pattern1:-"mmc0"} + leds_pattern2=${leds_pattern2:-"activity"} + leds_pattern3=${leds_pattern3:-"mmc1"} + leds_base=/sys/class/leds/beaglebone\:green\:usr + + if [ -e ${leds_base}0/trigger ] ; then + echo ${leds_pattern0} > ${leds_base}0/trigger || true + echo ${leds_pattern1} > ${leds_base}1/trigger || true + echo ${leds_pattern2} > ${leds_base}2/trigger || true + echo ${leds_pattern3} > ${leds_base}3/trigger || true + fi + fi +} + +flush_cache () { + sync + if [ "x${destination}" != "x" ] ; then + message="INFO: flush_cache: [blockdev --flushbufs ${destination}]" ; broadcast + blockdev --flushbufs ${destination} || true + message="--------------------------------------------------------------------------------" ; broadcast + fi +} + +broadcast () { + if [ "x${message}" != "x" ] ; then + echo "${message}" + if [ "x${debug_over_display}" != "x" ] ; then + echo "${message}" > /dev/${debug_over_display} || true + fi + fi +} + +broadcast_over_display () { + if [ "x${message}" != "x" ] ; then + if [ "x${debug_over_display}" != "x" ] ; then + echo "${message}" > /dev/${debug_over_display} || true + fi + fi +} + +example_failure () { + exit 2 +} + +write_failure () { + message="ERROR: writing to [destination=${destination}] failed..." ; broadcast + + if [ "x${has_usr_leds}" = "xenable" ] ; then + if [ -e /proc/$CYLON_PID ]; then + kill $CYLON_PID > /dev/null 2>&1 + fi + + leds_pattern0=${leds_pattern0:-"heartbeat"} + leds_pattern1=${leds_pattern1:-"heartbeat"} + leds_pattern2=${leds_pattern2:-"heartbeat"} + leds_pattern3=${leds_pattern3:-"heartbeat"} + leds_base=/sys/class/leds/beaglebone\:green\:usr + + if [ -e ${leds_base}0/trigger ] ; then + echo ${leds_pattern0} > ${leds_base}0/trigger || true + echo ${leds_pattern1} > ${leds_base}1/trigger || true + echo ${leds_pattern2} > ${leds_base}2/trigger || true + echo ${leds_pattern3} > ${leds_base}3/trigger || true + fi + message="Debug: Setting Heartbeat" ; broadcast + fi + + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + if [ "x${destination}" != "x" ] ; then + umount ${destination}p1 > /dev/null 2>&1 || true + fi +} + +check_running_system () { + message="INFO: Giving system time to stablize..." ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="5" ; broadcast + sleep 1 + message="4" ; broadcast + sleep 1 + message="3" ; broadcast + sleep 1 + message="2" ; broadcast + sleep 1 + message="1" ; broadcast + sleep 1 + message="--------------------------------------------------------------------------------" ; broadcast + + message="INFO: Preparing /tmp" ; broadcast + message="INFO: [mount -t tmpfs tmpfs /tmp]" ; broadcast + mount -t tmpfs tmpfs /tmp + message="--------------------------------------------------------------------------------" ; broadcast + + message="INFO: /proc/cmdline" ; broadcast + message="INFO: [cat /proc/cmdline]" ; broadcast + cat /proc/cmdline + message="--------------------------------------------------------------------------------" ; broadcast + + has_usr_leds="enable" + + if [ "x${has_usr_leds}" = "xenable" ] ; then + cylon_leds & CYLON_PID=$! + fi + + if [ "x${source}" != "x" ] && [ "x${destination}" != "x" ] ; then + message="INFO: [lsblk -i]" ; broadcast + message="`lsblk -i || true`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="INFO: copying [${source}] -> [${destination}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + else + message="INFO: [lsblk -i]" ; broadcast + message="`lsblk -i || true`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="ERROR: Setup: [source] and [destination] in /etc/default/beagle-flasher" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + fi + + if [ ! -b "${source}" ] ; then + message="ERROR: [source=${source}] does not exist" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + else + message="INFO: [source=${source}] is a valid block device" ; broadcast + fi + + if [ ! -b "${destination}" ] ; then + message="ERROR: [destination=${destination}] does not exist" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + else + message="INFO: [destination=${destination}] is a valid block device" ; broadcast + fi + flush_cache + + if [ -f /etc/default/generic-sys-mods ] ; then + message="INFO: [cat /etc/default/generic-sys-mods]" ; broadcast + cat /etc/default/generic-sys-mods + . /etc/default/generic-sys-mods + src_rfs_part=${ROOT_PARTITION} + message="--------------------------------------------------------------------------------" ; broadcast + fi +} + +format_boot () { + message="mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +format_root () { + message="mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +format_single_root () { + message="mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +copy_boot_extlinux () { + message="Updating extlinux.conf" ; broadcast + mkdir -p /tmp/boot/ || true + + mount ${source}p1 /tmp/boot/ -o sync + + if [ -f ${extlinux} ] ; then + message="INFO: [/boot/extlinux/extlinux.conf]" ; broadcast + mkdir -p /tmp/boot/extlinux/ || true + cp -v ${extlinux} /tmp/boot/extlinux/extlinux.conf + message="INFO: [cat /tmp/boot/extlinux/extlinux.conf]" ; broadcast + message="`cat /tmp/boot/extlinux/extlinux.conf`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + fi + flush_cache + + umount /tmp/boot/ || umount -l /tmp/boot/ || write_failure + flush_cache +} + +copy_rootfs () { + message="INFO: Copying: ${source}p${src_rfs_part} -> ${destination}p${dest_rfs_part}" ; broadcast + mkdir -p /tmp/rootfs/ || true + + message="INFO: [mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast + mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Copying: Kernel modules" ; broadcast + mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Generating: /etc/fstab" ; broadcast + echo "# /etc/fstab: static file system information." > /tmp/rootfs/etc/fstab + echo "#" >> /tmp/rootfs/etc/fstab + echo "${destination}p${dest_rfs_part} / ext4 noatime,errors=remount-ro 0 1" >> /tmp/rootfs/etc/fstab + echo "${source}p1 /boot/firmware vfat ${rfs_boot_permissions} 0 0" >> /tmp/rootfs/etc/fstab + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + echo "${destination}p1 none swap sw 0 0" >>/tmp/rootfs/etc/fstab + fi + echo "debugfs /sys/kernel/debug debugfs mode=755,uid=root,gid=gpio,defaults 0 0" >> /tmp/rootfs/etc/fstab + message="INFO: [cat /tmp/rootfs/etc/fstab]" ; broadcast + message="`cat /tmp/rootfs/etc/fstab`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + if [ "x${flash_back}" != "x" ] ; then + if [ -f ${flash_back} ] ; then + message="INFO: [cp -v ${flash_back} /tmp/rootfs/etc/default/beagle-flasher]" ; broadcast + cp -v ${flash_back} /tmp/rootfs/etc/default/beagle-flasher + message="--------------------------------------------------------------------------------" ; broadcast + else + if [ -f /etc/beagle-flasher/${flash_back} ] ; then + message="INFO: [cp -v /etc/beagle-flasher/${flash_back} /tmp/rootfs/etc/default/beagle-flasher]" ; broadcast + cp -v /etc/beagle-flasher/${flash_back} /tmp/rootfs/etc/default/beagle-flasher + message="--------------------------------------------------------------------------------" ; broadcast + fi + fi + fi + + if [ -f /tmp/rootfs/etc/systemd/system/multi-user.target.wants/grow_partition.service ] ; then + rm -rf /tmp/rootfs/etc/systemd/system/multi-user.target.wants/grow_partition.service || true + fi + flush_cache + + message="Copying: ${source}p${src_rfs_part} -> ${destination}p${dest_rfs_part} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: [umount /tmp/rootfs/ || umount -l /tmp/rootfs/ || write_failure]" ; broadcast + umount /tmp/rootfs/ || umount -l /tmp/rootfs/ || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + + message="INFO: [umount /tmp || true]" ; broadcast + umount /tmp || true + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Force writeback of eMMC buffers by Syncing: ${destination}" ; broadcast + message="INFO: [dd if=${destination} of=/dev/null count=100000 status=progress]" ; broadcast + dd if=${destination} of=/dev/null count=100000 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + if [ "x${has_usr_leds}" = "xenable" ] ; then + reset_leds + fi + + unset are_we_flasher + are_we_flasher=$(grep init-beagle-flasher /proc/cmdline || true) + if [ ! "x${are_we_flasher}" = "x" ] ; then + message="INFO: [We are init, trying to shutdown, we may crash, data is RO so safe]" ; broadcast + message="5" ; broadcast + sleep 1 + + if [ -f /proc/sysrq-trigger ] ; then + message="INFO: [found: /proc/sysrq-trigger]" ; broadcast + message="INFO: [found: echo s > /proc/sysrq-trigger" ; broadcast + message="INFO: [found: echo o > /proc/sysrq-trigger" ; broadcast + message="4" ; broadcast + sleep 1 + message="3" ; broadcast + sleep 1 + message="2" ; broadcast + sleep 1 + message="1" ; broadcast + sleep 1 + message="--------------------------------------------------------------------------------" ; broadcast + #For sync + echo s > /proc/sysrq-trigger + #For shutdown the system + echo o > /proc/sysrq-trigger + fi + + message="4" ; broadcast + sleep 1 + message="3" ; broadcast + sleep 1 + message="2" ; broadcast + sleep 1 + message="1" ; broadcast + sleep 1 + message="--------------------------------------------------------------------------------" ; broadcast + + #When run as init + exec /sbin/init + exit #We should not hit that + fi +} + +partition_drive () { + message="INFO: Erasing: [${destination}]" ; broadcast + flush_cache + message="INFO: [dd if=/dev/zero of=${destination} bs=1M count=148 status=progress]" ; broadcast + dd if=/dev/zero of=${destination} bs=1M count=148 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + sync + message="INFO: [dd if=${destination} of=/dev/null bs=1M count=148 status=progress]" ; broadcast + dd if=${destination} of=/dev/null bs=1M count=148 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + sync + flush_cache + message="INFO: Erasing: [${destination}] complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${bootloader}" != "x" ] ; then + if [ -f ${bootloader} ] ; then + message="INFO: [/bin/bash ${bootloader}]" ; broadcast + /bin/bash ${bootloader} + message="--------------------------------------------------------------------------------" ; broadcast + fi + fi + + rfs_boot_permissions=${rfs_boot_permissions:-"defaults"} + + if [ "x${rfs_partition}" = "xhybrid" ] ; then + partition_one_start_mb=${rfs_rootfs_startmb:-"1"} + partition_one_fstype=${rfs_sfdisk_fstype:-"L"} + + single_root_label=${single_root_label:-"rootfs"} + + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,,${partition_one_fstype},* + __EOF__ + + flush_cache + message="INFO: Formatting: ${destination}" ; broadcast + format_single_root + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="1" + else + src_rfs_part=${src_rfs_part:-"2"} + dest_rfs_part="1" + fi + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xhybrid_swap" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb="${rfs_swap_size_mb}" + partition_one_fstype=${rfs_sfdisk_fstype:-"0x82"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + rootfs_label=${rootfs_label:-"rootfs"} + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},- + ${partition_two_start_mb}M,,,- + __EOF__ + + flush_cache + + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="2" + + message="INFO: Formatting: ${destination}" ; broadcast + format_root + LC_ALL=C mkswap ${destination}p1 + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xdual" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} + partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + partition_two_size_mb="${rfs_swap_size_mb}" + partition_three_start_mb=$(($partition_one_start_mb + $partition_one_size_mb + $partition_two_size_mb)) + fi + + boot_label=${boot_label:-"FIRMWARE"} + rootfs_label=${rootfs_label:-"rootfs"} + + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + else + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + fi + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* + ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- + ${partition_three_start_mb}M,,,- + __EOF__ + else + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* + ${partition_two_start_mb}M,,,- + __EOF__ + fi + + flush_cache + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="3" + else + src_rfs_part=${src_rfs_part:-"2"} + dest_rfs_part="2" + fi + + message="INFO: Formatting: ${destination}" ; broadcast + format_boot + format_root + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + LC_ALL=C mkswap ${destination}p2 + fi + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot + copy_rootfs + else + example_failure + fi +} + +###FIXME +if [ -f /etc/default/beagle-flasher ] ; then + . /etc/default/beagle-flasher + message="--------------------------------------------------------------------------------" ; broadcast + message="Version: [${version_message}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="cat /etc/default/beagle-flasher:" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="`cat /etc/default/beagle-flasher`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast +else + message="--------------------------------------------------------------------------------" ; broadcast + message="Version: [${version_message}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure +fi + +check_running_system +partition_drive diff --git a/bb-beagle-flasher/suite/bullseye/debian/install b/bb-beagle-flasher/suite/bullseye/debian/install index d3547d33c0a0e1fc535eb2403de470f664541e8f..d8483c3f31326a0bb9c09e309a2bafd8350a13f1 100644 --- a/bb-beagle-flasher/suite/bullseye/debian/install +++ b/bb-beagle-flasher/suite/bullseye/debian/install @@ -1,8 +1,11 @@ debian/beagle-flasher /usr/sbin/ debian/beagle-flasher-boot-emmc-rootfs-nvme /usr/sbin/ debian/beagle-flasher-boot-mmc-rootfs-sda /usr/sbin/ +debian/beagle-flasher-mv-rootfs-to-nvme /usr/sbin/ +debian/beagle-flasher-mv-rootfs-to-sda /usr/sbin/ debian/enable-beagle-flasher /usr/sbin/ debian/init-beagle-flasher /usr/sbin/ +debian/init-beagle-flasher-mv-rootfs-to-nvme /usr/sbin/ debian/am62-emmc-to-microsd /etc/beagle-flasher/ debian/am62-microsd-to-emmc /etc/beagle-flasher/ debian/bbai64-emmc-to-microsd /etc/beagle-flasher/ diff --git a/bb-beagle-flasher/suite/jammy/debian/beagle-flasher b/bb-beagle-flasher/suite/jammy/debian/beagle-flasher index 29aeb3c85c80e60da8dea04f560c217a87e5d7f8..fd30d2ba55a9e4dc5dfa529bad6ce10cb8a57bdb 100755 --- a/bb-beagle-flasher/suite/jammy/debian/beagle-flasher +++ b/bb-beagle-flasher/suite/jammy/debian/beagle-flasher @@ -6,7 +6,7 @@ if ! id | grep -q root; then exit fi -version_message="1.20240308.0, vfat mount permissions..." +version_message="1.20240419.0, merged usr cleanups..." #Debian 12, Ubuntu Lunar, Mantic, Noble #https://packages.debian.org/source/bookworm/e2fsprogs @@ -215,10 +215,10 @@ check_running_system () { message="INFO: Generating: [/boot/initrd.img-$(uname -r)]" ; broadcast message="update-initramfs: Generating /boot/initrd.img-$(uname -r)" ; broadcast_over_display if [ -f /boot/initrd.img-$(uname -r) ] ; then - /usr/sbin/update-initramfs -u -k $(uname -r) || true + update-initramfs -u -k $(uname -r) || true message="--------------------------------------------------------------------------------" ; broadcast else - /usr/sbin/update-initramfs -c -k $(uname -r) || true + update-initramfs -c -k $(uname -r) || true message="--------------------------------------------------------------------------------" ; broadcast fi if [ -f /boot/firmware/initrd.img ] ; then @@ -237,22 +237,22 @@ check_running_system () { } format_boot () { - message="/sbin/mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast - LC_ALL=C /sbin/mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} + message="mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} + message="mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_single_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} + message="mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } @@ -291,20 +291,20 @@ copy_rootfs () { message="INFO: [mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: Copying: Kernel modules" ; broadcast mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true - message="INFO: /usr/bin/rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache @@ -418,12 +418,12 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,,${partition_one_fstype},* __EOF__ @@ -438,7 +438,7 @@ partition_drive () { copy_rootfs elif [ "x${rfs_partition}" = "xdual" ] ; then partition_one_start_mb=${rfs_boot_startmb:-"1"} - partition_one_size_mb=${rfs_boot_size_mb:-"128"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) @@ -454,25 +454,25 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast else - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast fi message="--------------------------------------------------------------------------------" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- ${partition_three_start_mb}M,,,- __EOF__ else - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,,,- __EOF__ @@ -492,7 +492,7 @@ partition_drive () { format_boot format_root if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/mkswap ${destination}p2 + LC_ALL=C mkswap ${destination}p2 fi message="INFO: Formatting: ${destination} complete" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast diff --git a/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-boot-emmc-rootfs-nvme b/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-boot-emmc-rootfs-nvme index 3cab872c9c3d304868534f90bd48ed4fae64e94d..5979873e87680dd1b2f8e12c69de2e04055a37b3 100755 --- a/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-boot-emmc-rootfs-nvme +++ b/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-boot-emmc-rootfs-nvme @@ -6,7 +6,7 @@ if ! id | grep -q root; then exit fi -version_message="1.20240308.0, vfat mount permissions..." +version_message="1.20240620.0, fix extlinux.conf location..." #Debian 12, Ubuntu Lunar, Mantic, Noble #https://packages.debian.org/source/bookworm/e2fsprogs @@ -116,17 +116,6 @@ broadcast_over_display () { } example_failure () { - message="Example: /etc/default/beagle-flasher" ; broadcast - message="--------------------------------------------------------------------------------" ; broadcast - message="source=/dev/mmcblk0" ; broadcast - message="destination=/dev/mmcblk1" ; broadcast - message="rfs_partition=dual" ; broadcast - message="rfs_boot_startmb=1" ; broadcast - message="rfs_boot_size_mb=256" ; broadcast - message="bootloader=/opt/u-boot/bb-u-boot-beagleboneai64/install-emmc.sh" ; broadcast - message="flash_back=bbai64-emmc-to-microsd" ; broadcast - message="extlinux=/opt/u-boot/bb-u-boot-beagleboneai64/emmc-extlinux.conf" ; broadcast - message="--------------------------------------------------------------------------------" ; broadcast exit 2 } @@ -215,10 +204,10 @@ check_running_system () { message="INFO: Generating: [/boot/initrd.img-$(uname -r)]" ; broadcast message="update-initramfs: Generating /boot/initrd.img-$(uname -r)" ; broadcast_over_display if [ -f /boot/initrd.img-$(uname -r) ] ; then - /usr/sbin/update-initramfs -u -k $(uname -r) || true + update-initramfs -u -k $(uname -r) || true message="--------------------------------------------------------------------------------" ; broadcast else - /usr/sbin/update-initramfs -c -k $(uname -r) || true + update-initramfs -c -k $(uname -r) || true message="--------------------------------------------------------------------------------" ; broadcast fi if [ -f /boot/firmware/initrd.img ] ; then @@ -237,26 +226,39 @@ check_running_system () { } format_boot () { - message="/sbin/mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast - LC_ALL=C /sbin/mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} + message="mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} + message="mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_single_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} + message="mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } +copy_boot_extlinux () { + message="Updating extlinux.conf" ; broadcast + + if [ -f ${extlinux} ] ; then + message="INFO: [/boot/firmware/extlinux/extlinux.conf]" ; broadcast + cp -v ${extlinux} /boot/firmware/extlinux/extlinux.conf + message="INFO: [cat /boot/firmware/extlinux/extlinux.conf]" ; broadcast + message="`cat /boot/firmware/extlinux/extlinux.conf`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + fi + flush_cache +} + copy_rootfs () { message="INFO: Copying: ${source}p${src_rfs_part} -> ${destination}p${dest_rfs_part}" ; broadcast mkdir -p /tmp/rootfs/ || true @@ -264,20 +266,20 @@ copy_rootfs () { message="INFO: [mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: Copying: Kernel modules" ; broadcast mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true - message="INFO: /usr/bin/rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache @@ -286,6 +288,9 @@ copy_rootfs () { echo "#" >> /tmp/rootfs/etc/fstab echo "${destination}p${dest_rfs_part} / ext4 noatime,errors=remount-ro 0 1" >> /tmp/rootfs/etc/fstab echo "${source}p1 /boot/firmware vfat ${rfs_boot_permissions} 0 0" >> /tmp/rootfs/etc/fstab + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + echo "${destination}p1 none swap sw 0 0" >>/tmp/rootfs/etc/fstab + fi echo "debugfs /sys/kernel/debug debugfs mode=755,uid=root,gid=gpio,defaults 0 0" >> /tmp/rootfs/etc/fstab message="INFO: [cat /tmp/rootfs/etc/fstab]" ; broadcast message="`cat /tmp/rootfs/etc/fstab`" ; broadcast @@ -350,12 +355,12 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,,${partition_one_fstype},* __EOF__ @@ -372,19 +377,46 @@ partition_drive () { src_rfs_part=${src_rfs_part:-"2"} dest_rfs_part="1" fi + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xhybrid_swap" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb="${rfs_swap_size_mb}" + partition_one_fstype=${rfs_sfdisk_fstype:-"0x82"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + rootfs_label=${rootfs_label:-"rootfs"} + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},- + ${partition_two_start_mb}M,,,- + __EOF__ + + flush_cache + + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="2" + + message="INFO: Formatting: ${destination}" ; broadcast + format_root + LC_ALL=C mkswap ${destination}p1 + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot_extlinux copy_rootfs - if [ "x${extlinux}" != "x" ] ; then - if [ -f ${extlinux} ] ; then - message="INFO: [/boot/firmware/extlinux/extlinux.conf]" ; broadcast - cp -v ${extlinux} /boot/firmware/extlinux/extlinux.conf - message="INFO: [cat /boot/firmware/extlinux/extlinux.conf]" ; broadcast - message="`cat /boot/firmware/extlinux/extlinux.conf`" ; broadcast - message="--------------------------------------------------------------------------------" ; broadcast - fi - fi elif [ "x${rfs_partition}" = "xdual" ] ; then partition_one_start_mb=${rfs_boot_startmb:-"1"} - partition_one_size_mb=${rfs_boot_size_mb:-"128"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) @@ -400,25 +432,25 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast else - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast fi message="--------------------------------------------------------------------------------" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- ${partition_three_start_mb}M,,,- __EOF__ else - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,,,- __EOF__ @@ -438,7 +470,7 @@ partition_drive () { format_boot format_root if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/mkswap ${destination}p2 + LC_ALL=C mkswap ${destination}p2 fi message="INFO: Formatting: ${destination} complete" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast diff --git a/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-boot-mmc-rootfs-sda b/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-boot-mmc-rootfs-sda index ae896d2953657f67793b6a0f06d06afa6e53c15c..e32a0c68ba689b408adf298a2892c04f904b010d 100755 --- a/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-boot-mmc-rootfs-sda +++ b/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-boot-mmc-rootfs-sda @@ -6,7 +6,7 @@ if ! id | grep -q root; then exit fi -version_message="1.20240308.0, vfat mount permissions..." +version_message="1.20240620.0, fix extlinux.conf location..." #Debian 12, Ubuntu Lunar, Mantic, Noble #https://packages.debian.org/source/bookworm/e2fsprogs @@ -215,10 +215,10 @@ check_running_system () { message="INFO: Generating: [/boot/initrd.img-$(uname -r)]" ; broadcast message="update-initramfs: Generating /boot/initrd.img-$(uname -r)" ; broadcast_over_display if [ -f /boot/initrd.img-$(uname -r) ] ; then - /usr/sbin/update-initramfs -u -k $(uname -r) || true + update-initramfs -u -k $(uname -r) || true message="--------------------------------------------------------------------------------" ; broadcast else - /usr/sbin/update-initramfs -c -k $(uname -r) || true + update-initramfs -c -k $(uname -r) || true message="--------------------------------------------------------------------------------" ; broadcast fi if [ -f /boot/firmware/initrd.img ] ; then @@ -237,26 +237,39 @@ check_running_system () { } format_boot () { - message="/sbin/mkfs.vfat -F 16 ${destination}1 -n ${boot_label}" ; broadcast - LC_ALL=C /sbin/mkfs.vfat -F 16 ${destination}1 -n ${boot_label} + message="mkfs.vfat -F 16 ${destination}1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}1 -n ${boot_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}${dest_rfs_part} -L ${rootfs_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}${dest_rfs_part} -L ${rootfs_label} + message="mkfs.ext4 ${ext4_options} ${destination}${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}${dest_rfs_part} -L ${rootfs_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_single_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}1 -L ${single_root_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}1 -L ${single_root_label} + message="mkfs.ext4 ${ext4_options} ${destination}1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}1 -L ${single_root_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } +copy_boot_extlinux () { + message="Updating extlinux.conf" ; broadcast + + if [ -f ${extlinux} ] ; then + message="INFO: [/boot/firmware/extlinux/extlinux.conf]" ; broadcast + cp -v ${extlinux} /boot/firmware/extlinux/extlinux.conf + message="INFO: [cat /boot/firmware/extlinux/extlinux.conf]" ; broadcast + message="`cat /boot/firmware/extlinux/extlinux.conf`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + fi + flush_cache +} + copy_rootfs () { message="INFO: Copying: ${source}p${src_rfs_part} -> ${destination}${dest_rfs_part}" ; broadcast mkdir -p /tmp/rootfs/ || true @@ -264,20 +277,20 @@ copy_rootfs () { message="INFO: [mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: Copying: Kernel modules" ; broadcast mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true - message="INFO: /usr/bin/rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache @@ -286,6 +299,9 @@ copy_rootfs () { echo "#" >> /tmp/rootfs/etc/fstab echo "${destination}${dest_rfs_part} / ext4 noatime,errors=remount-ro 0 1" >> /tmp/rootfs/etc/fstab echo "${source}p1 /boot/firmware vfat ${rfs_boot_permissions} 0 0" >> /tmp/rootfs/etc/fstab + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + echo "${destination}1 none swap sw 0 0" >>/tmp/rootfs/etc/fstab + fi echo "debugfs /sys/kernel/debug debugfs mode=755,uid=root,gid=gpio,defaults 0 0" >> /tmp/rootfs/etc/fstab message="INFO: [cat /tmp/rootfs/etc/fstab]" ; broadcast message="`cat /tmp/rootfs/etc/fstab`" ; broadcast @@ -350,12 +366,12 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,,${partition_one_fstype},* __EOF__ @@ -372,19 +388,46 @@ partition_drive () { src_rfs_part=${src_rfs_part:-"2"} dest_rfs_part="1" fi + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xhybrid_swap" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb="${rfs_swap_size_mb}" + partition_one_fstype=${rfs_sfdisk_fstype:-"0x82"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + rootfs_label=${rootfs_label:-"rootfs"} + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},- + ${partition_two_start_mb}M,,,- + __EOF__ + + flush_cache + + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="2" + + message="INFO: Formatting: ${destination}" ; broadcast + format_root + LC_ALL=C mkswap ${destination}1 + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot_extlinux copy_rootfs - if [ "x${extlinux}" != "x" ] ; then - if [ -f ${extlinux} ] ; then - message="INFO: [/boot/firmware/extlinux/extlinux.conf]" ; broadcast - cp -v ${extlinux} /boot/firmware/extlinux/extlinux.conf - message="INFO: [cat /boot/firmware/extlinux/extlinux.conf]" ; broadcast - message="`cat /boot/firmware/extlinux/extlinux.conf`" ; broadcast - message="--------------------------------------------------------------------------------" ; broadcast - fi - fi elif [ "x${rfs_partition}" = "xdual" ] ; then partition_one_start_mb=${rfs_boot_startmb:-"1"} - partition_one_size_mb=${rfs_boot_size_mb:-"128"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) @@ -400,25 +443,25 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast else - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast fi message="--------------------------------------------------------------------------------" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- ${partition_three_start_mb}M,,,- __EOF__ else - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,,,- __EOF__ @@ -438,7 +481,7 @@ partition_drive () { format_boot format_root if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/mkswap ${destination}2 + LC_ALL=C mkswap ${destination}2 fi message="INFO: Formatting: ${destination} complete" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast diff --git a/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-mv-rootfs-to-nvme b/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-mv-rootfs-to-nvme new file mode 100755 index 0000000000000000000000000000000000000000..a3840a9f16bb697ba23c8bc52b8820d32a4b1b0f --- /dev/null +++ b/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-mv-rootfs-to-nvme @@ -0,0 +1,503 @@ +#!/bin/bash -e + +if ! id | grep -q root; then + echo "beagle-flasher-mv-rootfs-to-nvme must be run as root:" + echo "sudo beagle-flasher-mv-rootfs-to-nvme" + exit +fi + +version_message="1.20240620.0, fix extlinux.conf location..." + +#Debian 12, Ubuntu Lunar, Mantic, Noble +#https://packages.debian.org/source/bookworm/e2fsprogs +#e2fsprogs (1.47.0) added orphan_file first added in v5.15.x +unset ext4_options +#ext4_options="-O ^orphan_file" + +cylon_leds() { + #ls /sys/class/leds/beaglebone\:green\:usr* + #cat /sys/class/leds/beaglebone\:green\:usr*/trigger + local leds_base=/sys/class/leds/beaglebone\:green\:usr + if [ -e ${leds_base}0/trigger ] ; then + echo none > ${leds_base}0/trigger || true + echo none > ${leds_base}1/trigger || true + echo none > ${leds_base}2/trigger || true + echo none > ${leds_base}3/trigger || true + + STATE=1 + while : ; do + case $STATE in + 1) + echo 1 > ${leds_base}0/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=2 + ;; + 2) + echo 1 > ${leds_base}1/brightness || true + echo 0 > ${leds_base}0/brightness || true + STATE=3 + ;; + 3) + echo 1 > ${leds_base}2/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=4 + ;; + 4) + echo 1 > ${leds_base}3/brightness || true + echo 0 > ${leds_base}2/brightness || true + STATE=5 + ;; + 5) + echo 1 > ${leds_base}2/brightness || true + echo 0 > ${leds_base}3/brightness || true + STATE=6 + ;; + 6) + echo 1 > ${leds_base}1/brightness || true + echo 0 > ${leds_base}2/brightness || true + STATE=1 + ;; + *) + echo 1 > ${leds_base}0/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=2 + ;; + esac + sleep 0.1 + done + fi +} + +reset_leds() { + if [ "x${has_usr_leds}" = "xenable" ] ; then + if [ -e /proc/$CYLON_PID ]; then + kill $CYLON_PID > /dev/null 2>&1 + fi + + leds_pattern0=${leds_pattern0:-"heartbeat"} + leds_pattern1=${leds_pattern1:-"mmc0"} + leds_pattern2=${leds_pattern2:-"activity"} + leds_pattern3=${leds_pattern3:-"mmc1"} + leds_base=/sys/class/leds/beaglebone\:green\:usr + + if [ -e ${leds_base}0/trigger ] ; then + echo ${leds_pattern0} > ${leds_base}0/trigger || true + echo ${leds_pattern1} > ${leds_base}1/trigger || true + echo ${leds_pattern2} > ${leds_base}2/trigger || true + echo ${leds_pattern3} > ${leds_base}3/trigger || true + fi + fi +} + +flush_cache () { + sync + if [ "x${destination}" != "x" ] ; then + message="INFO: flush_cache: [blockdev --flushbufs ${destination}]" ; broadcast + blockdev --flushbufs ${destination} || true + message="--------------------------------------------------------------------------------" ; broadcast + fi +} + +broadcast () { + if [ "x${message}" != "x" ] ; then + echo "${message}" + if [ "x${debug_over_display}" != "x" ] ; then + echo "${message}" > /dev/${debug_over_display} || true + fi + fi +} + +broadcast_over_display () { + if [ "x${message}" != "x" ] ; then + if [ "x${debug_over_display}" != "x" ] ; then + echo "${message}" > /dev/${debug_over_display} || true + fi + fi +} + +example_failure () { + exit 2 +} + +write_failure () { + message="ERROR: writing to [destination=${destination}] failed..." ; broadcast + + if [ "x${has_usr_leds}" = "xenable" ] ; then + if [ -e /proc/$CYLON_PID ]; then + kill $CYLON_PID > /dev/null 2>&1 + fi + + leds_pattern0=${leds_pattern0:-"heartbeat"} + leds_pattern1=${leds_pattern1:-"heartbeat"} + leds_pattern2=${leds_pattern2:-"heartbeat"} + leds_pattern3=${leds_pattern3:-"heartbeat"} + leds_base=/sys/class/leds/beaglebone\:green\:usr + + if [ -e ${leds_base}0/trigger ] ; then + echo ${leds_pattern0} > ${leds_base}0/trigger || true + echo ${leds_pattern1} > ${leds_base}1/trigger || true + echo ${leds_pattern2} > ${leds_base}2/trigger || true + echo ${leds_pattern3} > ${leds_base}3/trigger || true + fi + message="Debug: Setting Heartbeat" ; broadcast + fi + + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + if [ "x${destination}" != "x" ] ; then + umount ${destination}p1 > /dev/null 2>&1 || true + fi +} + +check_running_system () { + + message="INFO: /proc/cmdline" ; broadcast + message="INFO: [cat /proc/cmdline]" ; broadcast + cat /proc/cmdline + message="--------------------------------------------------------------------------------" ; broadcast + + has_usr_leds="enable" + + if [ "x${has_usr_leds}" = "xenable" ] ; then + cylon_leds & CYLON_PID=$! + fi + + if [ "x${source}" != "x" ] && [ "x${destination}" != "x" ] ; then + message="INFO: [lsblk -i]" ; broadcast + message="`lsblk -i || true`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="INFO: copying [${source}] -> [${destination}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + else + message="INFO: [lsblk -i]" ; broadcast + message="`lsblk -i || true`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="ERROR: Setup: [source] and [destination] in /etc/default/beagle-flasher" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + fi + + if [ ! -b "${source}" ] ; then + message="ERROR: [source=${source}] does not exist" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + else + message="INFO: [source=${source}] is a valid block device" ; broadcast + fi + + if [ ! -b "${destination}" ] ; then + message="ERROR: [destination=${destination}] does not exist" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + else + message="INFO: [destination=${destination}] is a valid block device" ; broadcast + fi + + if [ ! -f /boot/config-$(uname -r) ] ; then + zcat /proc/config.gz > /boot/config-$(uname -r) || true + message="INFO: Creating: [/boot/config-$(uname -r)]" ; broadcast + else + message="INFO: [/boot/config-$(uname -r)]" ; broadcast + fi + + if [ -f /usr/sbin/update-initramfs ] ; then + message="INFO: Generating: [/boot/initrd.img-$(uname -r)]" ; broadcast + message="update-initramfs: Generating /boot/initrd.img-$(uname -r)" ; broadcast_over_display + if [ -f /boot/initrd.img-$(uname -r) ] ; then + update-initramfs -u -k $(uname -r) || true + message="--------------------------------------------------------------------------------" ; broadcast + else + update-initramfs -c -k $(uname -r) || true + message="--------------------------------------------------------------------------------" ; broadcast + fi + if [ -f /boot/firmware/initrd.img ] ; then + cp -v /boot/initrd.img-$(uname -r) /boot/firmware/initrd.img + fi + fi + flush_cache + + if [ -f /etc/default/generic-sys-mods ] ; then + message="INFO: [cat /etc/default/generic-sys-mods]" ; broadcast + cat /etc/default/generic-sys-mods + . /etc/default/generic-sys-mods + src_rfs_part=${ROOT_PARTITION} + message="--------------------------------------------------------------------------------" ; broadcast + fi +} + +format_boot () { + message="mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +format_root () { + message="mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +format_single_root () { + message="mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +copy_boot_extlinux () { + message="Updating extlinux.conf" ; broadcast + + if [ -f ${extlinux} ] ; then + message="INFO: [/boot/firmware/extlinux/extlinux.conf]" ; broadcast + cp -v ${extlinux} /boot/firmware/extlinux/extlinux.conf + message="INFO: [cat /boot/firmware/extlinux/extlinux.conf]" ; broadcast + message="`cat /boot/firmware/extlinux/extlinux.conf`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + fi + flush_cache +} + +copy_rootfs () { + message="INFO: Copying: ${source}p${src_rfs_part} -> ${destination}p${dest_rfs_part}" ; broadcast + mkdir -p /tmp/rootfs/ || true + + message="INFO: [mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast + mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Copying: Kernel modules" ; broadcast + mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Generating: /etc/fstab" ; broadcast + echo "# /etc/fstab: static file system information." > /tmp/rootfs/etc/fstab + echo "#" >> /tmp/rootfs/etc/fstab + echo "${destination}p${dest_rfs_part} / ext4 noatime,errors=remount-ro 0 1" >> /tmp/rootfs/etc/fstab + echo "${source}p1 /boot/firmware vfat ${rfs_boot_permissions} 0 0" >> /tmp/rootfs/etc/fstab + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + echo "${destination}p1 none swap sw 0 0" >>/tmp/rootfs/etc/fstab + fi + echo "debugfs /sys/kernel/debug debugfs mode=755,uid=root,gid=gpio,defaults 0 0" >> /tmp/rootfs/etc/fstab + message="INFO: [cat /tmp/rootfs/etc/fstab]" ; broadcast + message="`cat /tmp/rootfs/etc/fstab`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + if [ -f /tmp/rootfs/etc/systemd/system/multi-user.target.wants/grow_partition.service ] ; then + rm -rf /tmp/rootfs/etc/systemd/system/multi-user.target.wants/grow_partition.service || true + fi + flush_cache + + message="Copying: ${source}p${src_rfs_part} -> ${destination}p${dest_rfs_part} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: [umount /tmp/rootfs/ || umount -l /tmp/rootfs/ || write_failure]" ; broadcast + umount /tmp/rootfs/ || umount -l /tmp/rootfs/ || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + + message="INFO: Force writeback of eMMC buffers by Syncing: ${destination}" ; broadcast + message="INFO: [dd if=${destination} of=/dev/null count=100000 status=progress]" ; broadcast + dd if=${destination} of=/dev/null count=100000 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + if [ "x${has_usr_leds}" = "xenable" ] ; then + reset_leds + fi +} + +partition_drive () { + message="INFO: Erasing: [${destination}]" ; broadcast + flush_cache + message="INFO: [dd if=/dev/zero of=${destination} bs=1M count=148 status=progress]" ; broadcast + dd if=/dev/zero of=${destination} bs=1M count=148 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + sync + message="INFO: [dd if=${destination} of=/dev/null bs=1M count=148 status=progress]" ; broadcast + dd if=${destination} of=/dev/null bs=1M count=148 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + sync + flush_cache + message="INFO: Erasing: [${destination}] complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${bootloader}" != "x" ] ; then + if [ -f ${bootloader} ] ; then + message="INFO: [/bin/bash ${bootloader}]" ; broadcast + /bin/bash ${bootloader} + message="--------------------------------------------------------------------------------" ; broadcast + fi + fi + + rfs_boot_permissions=${rfs_boot_permissions:-"defaults"} + + if [ "x${rfs_partition}" = "xhybrid" ] ; then + partition_one_start_mb=${rfs_rootfs_startmb:-"1"} + partition_one_fstype=${rfs_sfdisk_fstype:-"L"} + + single_root_label=${single_root_label:-"rootfs"} + + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,,${partition_one_fstype},* + __EOF__ + + flush_cache + message="INFO: Formatting: ${destination}" ; broadcast + format_single_root + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="1" + else + src_rfs_part=${src_rfs_part:-"2"} + dest_rfs_part="1" + fi + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xhybrid_swap" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb="${rfs_swap_size_mb}" + partition_one_fstype=${rfs_sfdisk_fstype:-"0x82"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + rootfs_label=${rootfs_label:-"rootfs"} + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},- + ${partition_two_start_mb}M,,,- + __EOF__ + + flush_cache + + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="2" + + message="INFO: Formatting: ${destination}" ; broadcast + format_root + LC_ALL=C mkswap ${destination}p1 + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xdual" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} + partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + partition_two_size_mb="${rfs_swap_size_mb}" + partition_three_start_mb=$(($partition_one_start_mb + $partition_one_size_mb + $partition_two_size_mb)) + fi + + boot_label=${boot_label:-"FIRMWARE"} + rootfs_label=${rootfs_label:-"rootfs"} + + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + else + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + fi + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* + ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- + ${partition_three_start_mb}M,,,- + __EOF__ + else + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* + ${partition_two_start_mb}M,,,- + __EOF__ + fi + + flush_cache + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="3" + else + src_rfs_part=${src_rfs_part:-"2"} + dest_rfs_part="2" + fi + + message="INFO: Formatting: ${destination}" ; broadcast + format_boot + format_root + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + LC_ALL=C mkswap ${destination}p2 + fi + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot + copy_rootfs + else + example_failure + fi +} + +###FIXME +if [ -f /etc/default/beagle-flasher ] ; then + . /etc/default/beagle-flasher + message="--------------------------------------------------------------------------------" ; broadcast + message="Version: [${version_message}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="cat /etc/default/beagle-flasher:" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="`cat /etc/default/beagle-flasher`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast +else + message="--------------------------------------------------------------------------------" ; broadcast + message="Version: [${version_message}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure +fi + +check_running_system +partition_drive diff --git a/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-mv-rootfs-to-sda b/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-mv-rootfs-to-sda new file mode 100755 index 0000000000000000000000000000000000000000..1e6015882ca412aa955c847788502585aecba6c3 --- /dev/null +++ b/bb-beagle-flasher/suite/jammy/debian/beagle-flasher-mv-rootfs-to-sda @@ -0,0 +1,503 @@ +#!/bin/bash -e + +if ! id | grep -q root; then + echo "beagle-flasher-mv-rootfs-to-sda must be run as root:" + echo "sudo beagle-flasher-mv-rootfs-to-sda" + exit +fi + +version_message="1.20240620.0, fix extlinux.conf location..." + +#Debian 12, Ubuntu Lunar, Mantic, Noble +#https://packages.debian.org/source/bookworm/e2fsprogs +#e2fsprogs (1.47.0) added orphan_file first added in v5.15.x +unset ext4_options +#ext4_options="-O ^orphan_file" + +cylon_leds() { + #ls /sys/class/leds/beaglebone\:green\:usr* + #cat /sys/class/leds/beaglebone\:green\:usr*/trigger + local leds_base=/sys/class/leds/beaglebone\:green\:usr + if [ -e ${leds_base}0/trigger ] ; then + echo none > ${leds_base}0/trigger || true + echo none > ${leds_base}1/trigger || true + echo none > ${leds_base}2/trigger || true + echo none > ${leds_base}3/trigger || true + + STATE=1 + while : ; do + case $STATE in + 1) + echo 1 > ${leds_base}0/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=2 + ;; + 2) + echo 1 > ${leds_base}1/brightness || true + echo 0 > ${leds_base}0/brightness || true + STATE=3 + ;; + 3) + echo 1 > ${leds_base}2/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=4 + ;; + 4) + echo 1 > ${leds_base}3/brightness || true + echo 0 > ${leds_base}2/brightness || true + STATE=5 + ;; + 5) + echo 1 > ${leds_base}2/brightness || true + echo 0 > ${leds_base}3/brightness || true + STATE=6 + ;; + 6) + echo 1 > ${leds_base}1/brightness || true + echo 0 > ${leds_base}2/brightness || true + STATE=1 + ;; + *) + echo 1 > ${leds_base}0/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=2 + ;; + esac + sleep 0.1 + done + fi +} + +reset_leds() { + if [ "x${has_usr_leds}" = "xenable" ] ; then + if [ -e /proc/$CYLON_PID ]; then + kill $CYLON_PID > /dev/null 2>&1 + fi + + leds_pattern0=${leds_pattern0:-"heartbeat"} + leds_pattern1=${leds_pattern1:-"mmc0"} + leds_pattern2=${leds_pattern2:-"activity"} + leds_pattern3=${leds_pattern3:-"mmc1"} + leds_base=/sys/class/leds/beaglebone\:green\:usr + + if [ -e ${leds_base}0/trigger ] ; then + echo ${leds_pattern0} > ${leds_base}0/trigger || true + echo ${leds_pattern1} > ${leds_base}1/trigger || true + echo ${leds_pattern2} > ${leds_base}2/trigger || true + echo ${leds_pattern3} > ${leds_base}3/trigger || true + fi + fi +} + +flush_cache () { + sync + if [ "x${destination}" != "x" ] ; then + message="INFO: flush_cache: [blockdev --flushbufs ${destination}]" ; broadcast + blockdev --flushbufs ${destination} || true + message="--------------------------------------------------------------------------------" ; broadcast + fi +} + +broadcast () { + if [ "x${message}" != "x" ] ; then + echo "${message}" + if [ "x${debug_over_display}" != "x" ] ; then + echo "${message}" > /dev/${debug_over_display} || true + fi + fi +} + +broadcast_over_display () { + if [ "x${message}" != "x" ] ; then + if [ "x${debug_over_display}" != "x" ] ; then + echo "${message}" > /dev/${debug_over_display} || true + fi + fi +} + +example_failure () { + exit 2 +} + +write_failure () { + message="ERROR: writing to [destination=${destination}] failed..." ; broadcast + + if [ "x${has_usr_leds}" = "xenable" ] ; then + if [ -e /proc/$CYLON_PID ]; then + kill $CYLON_PID > /dev/null 2>&1 + fi + + leds_pattern0=${leds_pattern0:-"heartbeat"} + leds_pattern1=${leds_pattern1:-"heartbeat"} + leds_pattern2=${leds_pattern2:-"heartbeat"} + leds_pattern3=${leds_pattern3:-"heartbeat"} + leds_base=/sys/class/leds/beaglebone\:green\:usr + + if [ -e ${leds_base}0/trigger ] ; then + echo ${leds_pattern0} > ${leds_base}0/trigger || true + echo ${leds_pattern1} > ${leds_base}1/trigger || true + echo ${leds_pattern2} > ${leds_base}2/trigger || true + echo ${leds_pattern3} > ${leds_base}3/trigger || true + fi + message="Debug: Setting Heartbeat" ; broadcast + fi + + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + if [ "x${destination}" != "x" ] ; then + umount ${destination}1 > /dev/null 2>&1 || true + fi +} + +check_running_system () { + + message="INFO: /proc/cmdline" ; broadcast + message="INFO: [cat /proc/cmdline]" ; broadcast + cat /proc/cmdline + message="--------------------------------------------------------------------------------" ; broadcast + + has_usr_leds="enable" + + if [ "x${has_usr_leds}" = "xenable" ] ; then + cylon_leds & CYLON_PID=$! + fi + + if [ "x${source}" != "x" ] && [ "x${destination}" != "x" ] ; then + message="INFO: [lsblk -i]" ; broadcast + message="`lsblk -i || true`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="INFO: copying [${source}] -> [${destination}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + else + message="INFO: [lsblk -i]" ; broadcast + message="`lsblk -i || true`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="ERROR: Setup: [source] and [destination] in /etc/default/beagle-flasher" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + fi + + if [ ! -b "${source}" ] ; then + message="ERROR: [source=${source}] does not exist" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + else + message="INFO: [source=${source}] is a valid block device" ; broadcast + fi + + if [ ! -b "${destination}" ] ; then + message="ERROR: [destination=${destination}] does not exist" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + else + message="INFO: [destination=${destination}] is a valid block device" ; broadcast + fi + + if [ ! -f /boot/config-$(uname -r) ] ; then + zcat /proc/config.gz > /boot/config-$(uname -r) || true + message="INFO: Creating: [/boot/config-$(uname -r)]" ; broadcast + else + message="INFO: [/boot/config-$(uname -r)]" ; broadcast + fi + + if [ -f /usr/sbin/update-initramfs ] ; then + message="INFO: Generating: [/boot/initrd.img-$(uname -r)]" ; broadcast + message="update-initramfs: Generating /boot/initrd.img-$(uname -r)" ; broadcast_over_display + if [ -f /boot/initrd.img-$(uname -r) ] ; then + update-initramfs -u -k $(uname -r) || true + message="--------------------------------------------------------------------------------" ; broadcast + else + update-initramfs -c -k $(uname -r) || true + message="--------------------------------------------------------------------------------" ; broadcast + fi + if [ -f /boot/firmware/initrd.img ] ; then + cp -v /boot/initrd.img-$(uname -r) /boot/firmware/initrd.img + fi + fi + flush_cache + + if [ -f /etc/default/generic-sys-mods ] ; then + message="INFO: [cat /etc/default/generic-sys-mods]" ; broadcast + cat /etc/default/generic-sys-mods + . /etc/default/generic-sys-mods + src_rfs_part=${ROOT_PARTITION} + message="--------------------------------------------------------------------------------" ; broadcast + fi +} + +format_boot () { + message="mkfs.vfat -F 16 ${destination}1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}1 -n ${boot_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +format_root () { + message="mkfs.ext4 ${ext4_options} ${destination}${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}${dest_rfs_part} -L ${rootfs_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +format_single_root () { + message="mkfs.ext4 ${ext4_options} ${destination}1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}1 -L ${single_root_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +copy_boot_extlinux () { + message="Updating extlinux.conf" ; broadcast + + if [ -f ${extlinux} ] ; then + message="INFO: [/boot/firmware/extlinux/extlinux.conf]" ; broadcast + cp -v ${extlinux} /boot/firmware/extlinux/extlinux.conf + message="INFO: [cat /boot/firmware/extlinux/extlinux.conf]" ; broadcast + message="`cat /boot/firmware/extlinux/extlinux.conf`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + fi + flush_cache +} + +copy_rootfs () { + message="INFO: Copying: ${source}p${src_rfs_part} -> ${destination}${dest_rfs_part}" ; broadcast + mkdir -p /tmp/rootfs/ || true + + message="INFO: [mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast + mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Copying: Kernel modules" ; broadcast + mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Generating: /etc/fstab" ; broadcast + echo "# /etc/fstab: static file system information." > /tmp/rootfs/etc/fstab + echo "#" >> /tmp/rootfs/etc/fstab + echo "${destination}${dest_rfs_part} / ext4 noatime,errors=remount-ro 0 1" >> /tmp/rootfs/etc/fstab + echo "${source}p1 /boot/firmware vfat ${rfs_boot_permissions} 0 0" >> /tmp/rootfs/etc/fstab + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + echo "${destination}1 none swap sw 0 0" >>/tmp/rootfs/etc/fstab + fi + echo "debugfs /sys/kernel/debug debugfs mode=755,uid=root,gid=gpio,defaults 0 0" >> /tmp/rootfs/etc/fstab + message="INFO: [cat /tmp/rootfs/etc/fstab]" ; broadcast + message="`cat /tmp/rootfs/etc/fstab`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + if [ -f /tmp/rootfs/etc/systemd/system/multi-user.target.wants/grow_partition.service ] ; then + rm -rf /tmp/rootfs/etc/systemd/system/multi-user.target.wants/grow_partition.service || true + fi + flush_cache + + message="Copying: ${source}p${src_rfs_part} -> ${destination}${dest_rfs_part} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: [umount /tmp/rootfs/ || umount -l /tmp/rootfs/ || write_failure]" ; broadcast + umount /tmp/rootfs/ || umount -l /tmp/rootfs/ || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + + message="INFO: Force writeback of eMMC buffers by Syncing: ${destination}" ; broadcast + message="INFO: [dd if=${destination} of=/dev/null count=100000 status=progress]" ; broadcast + dd if=${destination} of=/dev/null count=100000 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + if [ "x${has_usr_leds}" = "xenable" ] ; then + reset_leds + fi +} + +partition_drive () { + message="INFO: Erasing: [${destination}]" ; broadcast + flush_cache + message="INFO: [dd if=/dev/zero of=${destination} bs=1M count=148 status=progress]" ; broadcast + dd if=/dev/zero of=${destination} bs=1M count=148 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + sync + message="INFO: [dd if=${destination} of=/dev/null bs=1M count=148 status=progress]" ; broadcast + dd if=${destination} of=/dev/null bs=1M count=148 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + sync + flush_cache + message="INFO: Erasing: [${destination}] complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${bootloader}" != "x" ] ; then + if [ -f ${bootloader} ] ; then + message="INFO: [/bin/bash ${bootloader}]" ; broadcast + /bin/bash ${bootloader} + message="--------------------------------------------------------------------------------" ; broadcast + fi + fi + + rfs_boot_permissions=${rfs_boot_permissions:-"defaults"} + + if [ "x${rfs_partition}" = "xhybrid" ] ; then + partition_one_start_mb=${rfs_rootfs_startmb:-"1"} + partition_one_fstype=${rfs_sfdisk_fstype:-"L"} + + single_root_label=${single_root_label:-"rootfs"} + + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,,${partition_one_fstype},* + __EOF__ + + flush_cache + message="INFO: Formatting: ${destination}" ; broadcast + format_single_root + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="1" + else + src_rfs_part=${src_rfs_part:-"2"} + dest_rfs_part="1" + fi + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xhybrid_swap" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb="${rfs_swap_size_mb}" + partition_one_fstype=${rfs_sfdisk_fstype:-"0x82"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + rootfs_label=${rootfs_label:-"rootfs"} + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},- + ${partition_two_start_mb}M,,,- + __EOF__ + + flush_cache + + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="2" + + message="INFO: Formatting: ${destination}" ; broadcast + format_root + LC_ALL=C mkswap ${destination}1 + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xdual" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} + partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + partition_two_size_mb="${rfs_swap_size_mb}" + partition_three_start_mb=$(($partition_one_start_mb + $partition_one_size_mb + $partition_two_size_mb)) + fi + + boot_label=${boot_label:-"FIRMWARE"} + rootfs_label=${rootfs_label:-"rootfs"} + + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + else + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + fi + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* + ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- + ${partition_three_start_mb}M,,,- + __EOF__ + else + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* + ${partition_two_start_mb}M,,,- + __EOF__ + fi + + flush_cache + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="3" + else + src_rfs_part=${src_rfs_part:-"2"} + dest_rfs_part="2" + fi + + message="INFO: Formatting: ${destination}" ; broadcast + format_boot + format_root + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + LC_ALL=C mkswap ${destination}2 + fi + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot + copy_rootfs + else + example_failure + fi +} + +###FIXME +if [ -f /etc/default/beagle-flasher ] ; then + . /etc/default/beagle-flasher + message="--------------------------------------------------------------------------------" ; broadcast + message="Version: [${version_message}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="cat /etc/default/beagle-flasher:" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="`cat /etc/default/beagle-flasher`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast +else + message="--------------------------------------------------------------------------------" ; broadcast + message="Version: [${version_message}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure +fi + +check_running_system +partition_drive diff --git a/bb-beagle-flasher/suite/jammy/debian/changelog b/bb-beagle-flasher/suite/jammy/debian/changelog index 6e030f45e69b0bc25dc02fb83ba150339acce03c..b76fd61198c79ac57c80b0b3b58bc6ebc8a74eb2 100644 --- a/bb-beagle-flasher/suite/jammy/debian/changelog +++ b/bb-beagle-flasher/suite/jammy/debian/changelog @@ -1,4 +1,4 @@ -bb-beagle-flasher (1.20240620.0-0~jammy+20240620) jammy; urgency=low +bb-beagle-flasher (1.20240718.0-0~jammy+20240718) jammy; urgency=low * SK-AM69, support microSD -> usb sata * BBIA64/BeaglePlay, use u-boot versions of script files @@ -8,5 +8,5 @@ bb-beagle-flasher (1.20240620.0-0~jammy+20240620) jammy; urgency=low * Remove beagle-flasher-init-shutdown.service, single user will now shutdown * e2fsprogs (1.47.0) disable orphan_file, needs v5.15.x kernel - -- Robert Nelson <robertcnelson@gmail.com> Thu, 20 Jun 2024 09:14:06 -0500 + -- Robert Nelson <robertcnelson@gmail.com> Thu, 18 Jul 2024 11:24:51 -0500 diff --git a/bb-beagle-flasher/suite/jammy/debian/init-beagle-flasher b/bb-beagle-flasher/suite/jammy/debian/init-beagle-flasher index 67f3b5a3470ed98b2449133080381d3c0c2f0f68..0a9c5dcc92dd844beb50cfc3762dc0f864fac2e8 100755 --- a/bb-beagle-flasher/suite/jammy/debian/init-beagle-flasher +++ b/bb-beagle-flasher/suite/jammy/debian/init-beagle-flasher @@ -5,7 +5,7 @@ if ! id | grep -q root; then exit fi -version_message="1.20240308.0, vfat mount permissions..." +version_message="1.20240620.0, fix extlinux.conf location..." #Debian 12, Ubuntu Lunar, Mantic, Noble #https://packages.debian.org/source/bookworm/e2fsprogs @@ -232,22 +232,22 @@ check_running_system () { } format_boot () { - message="/sbin/mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast - LC_ALL=C /sbin/mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} + message="mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} + message="mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } format_single_root () { - message="/sbin/mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast - LC_ALL=C /sbin/mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} + message="mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} message="--------------------------------------------------------------------------------" ; broadcast flush_cache } @@ -263,15 +263,13 @@ copy_boot () { rsync -aHAXx --human-readable --info=progress2 /boot/firmware/ /tmp/boot/ || write_failure flush_cache - if [ "x${extlinux}" != "x" ] ; then - if [ -f ${extlinux} ] ; then - message="INFO: [/boot/extlinux/extlinux.conf]" ; broadcast - mkdir -p /tmp/boot/extlinux/ || true - cp -v ${extlinux} /tmp/boot/extlinux/extlinux.conf - message="INFO: [cat /tmp/boot/extlinux/extlinux.conf]" ; broadcast - message="`cat /tmp/boot/extlinux/extlinux.conf`" ; broadcast - message="--------------------------------------------------------------------------------" ; broadcast - fi + if [ -f ${extlinux} ] ; then + message="INFO: [/boot/extlinux/extlinux.conf]" ; broadcast + mkdir -p /tmp/boot/extlinux/ || true + cp -v ${extlinux} /tmp/boot/extlinux/extlinux.conf + message="INFO: [cat /tmp/boot/extlinux/extlinux.conf]" ; broadcast + message="`cat /tmp/boot/extlinux/extlinux.conf`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast fi flush_cache @@ -287,15 +285,20 @@ copy_rootfs () { message="INFO: [mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime - message="INFO: /usr/bin/rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: Copying: Kernel modules" ; broadcast mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true - message="INFO: /usr/bin/rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast - /usr/bin/rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache @@ -455,12 +458,12 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,,${partition_one_fstype},* __EOF__ @@ -475,7 +478,7 @@ partition_drive () { copy_rootfs elif [ "x${rfs_partition}" = "xdual" ] ; then partition_one_start_mb=${rfs_boot_startmb:-"1"} - partition_one_size_mb=${rfs_boot_size_mb:-"128"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) @@ -491,25 +494,25 @@ partition_drive () { sfdisk_options="--force --wipe-partitions always" message="INFO: Partitioning: ${destination}" ; broadcast - message="INFO: /sbin/sfdisk: [$(LC_ALL=C /sbin/sfdisk --version)]" ; broadcast - message="INFO: /sbin/sfdisk: [/sbin/sfdisk ${sfdisk_options} ${destination}]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast - message="INFO: /sbin/sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast else - message="INFO: /sbin/sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast fi message="--------------------------------------------------------------------------------" ; broadcast if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- ${partition_three_start_mb}M,,,- __EOF__ else - LC_ALL=C /sbin/sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* ${partition_two_start_mb}M,,,- __EOF__ @@ -529,7 +532,7 @@ partition_drive () { format_boot format_root if [ "x${rfs_swap_size_mb}" != "x" ] ; then - LC_ALL=C /sbin/mkswap ${destination}p2 + LC_ALL=C mkswap ${destination}p2 fi message="INFO: Formatting: ${destination} complete" ; broadcast message="--------------------------------------------------------------------------------" ; broadcast diff --git a/bb-beagle-flasher/suite/jammy/debian/init-beagle-flasher-mv-rootfs-to-nvme b/bb-beagle-flasher/suite/jammy/debian/init-beagle-flasher-mv-rootfs-to-nvme new file mode 100755 index 0000000000000000000000000000000000000000..f84a1327002f78b79186be818127672054709916 --- /dev/null +++ b/bb-beagle-flasher/suite/jammy/debian/init-beagle-flasher-mv-rootfs-to-nvme @@ -0,0 +1,565 @@ +#!/bin/bash -e + +if ! id | grep -q root; then + echo "must be run as root:" + exit +fi + +version_message="1.20240620.0, fix extlinux.conf location..." + +#Debian 12, Ubuntu Lunar, Mantic, Noble +#https://packages.debian.org/source/bookworm/e2fsprogs +#e2fsprogs (1.47.0) added orphan_file first added in v5.15.x +unset ext4_options +#ext4_options="-O ^orphan_file" + +cylon_leds() { + #ls /sys/class/leds/beaglebone\:green\:usr* + #cat /sys/class/leds/beaglebone\:green\:usr*/trigger + local leds_base=/sys/class/leds/beaglebone\:green\:usr + if [ -e ${leds_base}0/trigger ] ; then + echo none > ${leds_base}0/trigger || true + echo none > ${leds_base}1/trigger || true + echo none > ${leds_base}2/trigger || true + echo none > ${leds_base}3/trigger || true + + STATE=1 + while : ; do + case $STATE in + 1) + echo 1 > ${leds_base}0/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=2 + ;; + 2) + echo 1 > ${leds_base}1/brightness || true + echo 0 > ${leds_base}0/brightness || true + STATE=3 + ;; + 3) + echo 1 > ${leds_base}2/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=4 + ;; + 4) + echo 1 > ${leds_base}3/brightness || true + echo 0 > ${leds_base}2/brightness || true + STATE=5 + ;; + 5) + echo 1 > ${leds_base}2/brightness || true + echo 0 > ${leds_base}3/brightness || true + STATE=6 + ;; + 6) + echo 1 > ${leds_base}1/brightness || true + echo 0 > ${leds_base}2/brightness || true + STATE=1 + ;; + *) + echo 1 > ${leds_base}0/brightness || true + echo 0 > ${leds_base}1/brightness || true + STATE=2 + ;; + esac + sleep 0.1 + done + fi +} + +reset_leds() { + if [ "x${has_usr_leds}" = "xenable" ] ; then + if [ -e /proc/$CYLON_PID ]; then + kill $CYLON_PID > /dev/null 2>&1 + fi + + leds_pattern0=${leds_pattern0:-"heartbeat"} + leds_pattern1=${leds_pattern1:-"mmc0"} + leds_pattern2=${leds_pattern2:-"activity"} + leds_pattern3=${leds_pattern3:-"mmc1"} + leds_base=/sys/class/leds/beaglebone\:green\:usr + + if [ -e ${leds_base}0/trigger ] ; then + echo ${leds_pattern0} > ${leds_base}0/trigger || true + echo ${leds_pattern1} > ${leds_base}1/trigger || true + echo ${leds_pattern2} > ${leds_base}2/trigger || true + echo ${leds_pattern3} > ${leds_base}3/trigger || true + fi + fi +} + +flush_cache () { + sync + if [ "x${destination}" != "x" ] ; then + message="INFO: flush_cache: [blockdev --flushbufs ${destination}]" ; broadcast + blockdev --flushbufs ${destination} || true + message="--------------------------------------------------------------------------------" ; broadcast + fi +} + +broadcast () { + if [ "x${message}" != "x" ] ; then + echo "${message}" + if [ "x${debug_over_display}" != "x" ] ; then + echo "${message}" > /dev/${debug_over_display} || true + fi + fi +} + +broadcast_over_display () { + if [ "x${message}" != "x" ] ; then + if [ "x${debug_over_display}" != "x" ] ; then + echo "${message}" > /dev/${debug_over_display} || true + fi + fi +} + +example_failure () { + exit 2 +} + +write_failure () { + message="ERROR: writing to [destination=${destination}] failed..." ; broadcast + + if [ "x${has_usr_leds}" = "xenable" ] ; then + if [ -e /proc/$CYLON_PID ]; then + kill $CYLON_PID > /dev/null 2>&1 + fi + + leds_pattern0=${leds_pattern0:-"heartbeat"} + leds_pattern1=${leds_pattern1:-"heartbeat"} + leds_pattern2=${leds_pattern2:-"heartbeat"} + leds_pattern3=${leds_pattern3:-"heartbeat"} + leds_base=/sys/class/leds/beaglebone\:green\:usr + + if [ -e ${leds_base}0/trigger ] ; then + echo ${leds_pattern0} > ${leds_base}0/trigger || true + echo ${leds_pattern1} > ${leds_base}1/trigger || true + echo ${leds_pattern2} > ${leds_base}2/trigger || true + echo ${leds_pattern3} > ${leds_base}3/trigger || true + fi + message="Debug: Setting Heartbeat" ; broadcast + fi + + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + if [ "x${destination}" != "x" ] ; then + umount ${destination}p1 > /dev/null 2>&1 || true + fi +} + +check_running_system () { + message="INFO: Giving system time to stablize..." ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="5" ; broadcast + sleep 1 + message="4" ; broadcast + sleep 1 + message="3" ; broadcast + sleep 1 + message="2" ; broadcast + sleep 1 + message="1" ; broadcast + sleep 1 + message="--------------------------------------------------------------------------------" ; broadcast + + message="INFO: Preparing /tmp" ; broadcast + message="INFO: [mount -t tmpfs tmpfs /tmp]" ; broadcast + mount -t tmpfs tmpfs /tmp + message="--------------------------------------------------------------------------------" ; broadcast + + message="INFO: /proc/cmdline" ; broadcast + message="INFO: [cat /proc/cmdline]" ; broadcast + cat /proc/cmdline + message="--------------------------------------------------------------------------------" ; broadcast + + has_usr_leds="enable" + + if [ "x${has_usr_leds}" = "xenable" ] ; then + cylon_leds & CYLON_PID=$! + fi + + if [ "x${source}" != "x" ] && [ "x${destination}" != "x" ] ; then + message="INFO: [lsblk -i]" ; broadcast + message="`lsblk -i || true`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="INFO: copying [${source}] -> [${destination}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + else + message="INFO: [lsblk -i]" ; broadcast + message="`lsblk -i || true`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="ERROR: Setup: [source] and [destination] in /etc/default/beagle-flasher" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + fi + + if [ ! -b "${source}" ] ; then + message="ERROR: [source=${source}] does not exist" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + else + message="INFO: [source=${source}] is a valid block device" ; broadcast + fi + + if [ ! -b "${destination}" ] ; then + message="ERROR: [destination=${destination}] does not exist" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure + else + message="INFO: [destination=${destination}] is a valid block device" ; broadcast + fi + flush_cache + + if [ -f /etc/default/generic-sys-mods ] ; then + message="INFO: [cat /etc/default/generic-sys-mods]" ; broadcast + cat /etc/default/generic-sys-mods + . /etc/default/generic-sys-mods + src_rfs_part=${ROOT_PARTITION} + message="--------------------------------------------------------------------------------" ; broadcast + fi +} + +format_boot () { + message="mkfs.vfat -F 16 ${destination}p1 -n ${boot_label}" ; broadcast + LC_ALL=C mkfs.vfat -F 16 ${destination}p1 -n ${boot_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +format_root () { + message="mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p${dest_rfs_part} -L ${rootfs_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +format_single_root () { + message="mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label}" ; broadcast + LC_ALL=C mkfs.ext4 ${ext4_options} ${destination}p1 -L ${single_root_label} + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache +} + +copy_boot_extlinux () { + message="Updating extlinux.conf" ; broadcast + mkdir -p /tmp/boot/ || true + + mount ${source}p1 /tmp/boot/ -o sync + + if [ -f ${extlinux} ] ; then + message="INFO: [/boot/extlinux/extlinux.conf]" ; broadcast + mkdir -p /tmp/boot/extlinux/ || true + cp -v ${extlinux} /tmp/boot/extlinux/extlinux.conf + message="INFO: [cat /tmp/boot/extlinux/extlinux.conf]" ; broadcast + message="`cat /tmp/boot/extlinux/extlinux.conf`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + fi + flush_cache + + umount /tmp/boot/ || umount -l /tmp/boot/ || write_failure + flush_cache +} + +copy_rootfs () { + message="INFO: Copying: ${source}p${src_rfs_part} -> ${destination}p${dest_rfs_part}" ; broadcast + mkdir -p /tmp/rootfs/ || true + + message="INFO: [mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime]" ; broadcast + mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Copying: Kernel modules" ; broadcast + mkdir -p /tmp/rootfs/lib/modules/$(uname -r)/ || true + message="INFO: rsync: (-aHAXx) /lib/modules/$(uname -r)/ -> /tmp/rootfs/lib/modules/$(uname -r)/" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /lib/modules/$(uname -r)/* /tmp/rootfs/lib/modules/$(uname -r)/ || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Generating: /etc/fstab" ; broadcast + echo "# /etc/fstab: static file system information." > /tmp/rootfs/etc/fstab + echo "#" >> /tmp/rootfs/etc/fstab + echo "${destination}p${dest_rfs_part} / ext4 noatime,errors=remount-ro 0 1" >> /tmp/rootfs/etc/fstab + echo "${source}p1 /boot/firmware vfat ${rfs_boot_permissions} 0 0" >> /tmp/rootfs/etc/fstab + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + echo "${destination}p1 none swap sw 0 0" >>/tmp/rootfs/etc/fstab + fi + echo "debugfs /sys/kernel/debug debugfs mode=755,uid=root,gid=gpio,defaults 0 0" >> /tmp/rootfs/etc/fstab + message="INFO: [cat /tmp/rootfs/etc/fstab]" ; broadcast + message="`cat /tmp/rootfs/etc/fstab`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + if [ "x${flash_back}" != "x" ] ; then + if [ -f ${flash_back} ] ; then + message="INFO: [cp -v ${flash_back} /tmp/rootfs/etc/default/beagle-flasher]" ; broadcast + cp -v ${flash_back} /tmp/rootfs/etc/default/beagle-flasher + message="--------------------------------------------------------------------------------" ; broadcast + else + if [ -f /etc/beagle-flasher/${flash_back} ] ; then + message="INFO: [cp -v /etc/beagle-flasher/${flash_back} /tmp/rootfs/etc/default/beagle-flasher]" ; broadcast + cp -v /etc/beagle-flasher/${flash_back} /tmp/rootfs/etc/default/beagle-flasher + message="--------------------------------------------------------------------------------" ; broadcast + fi + fi + fi + + if [ -f /tmp/rootfs/etc/systemd/system/multi-user.target.wants/grow_partition.service ] ; then + rm -rf /tmp/rootfs/etc/systemd/system/multi-user.target.wants/grow_partition.service || true + fi + flush_cache + + message="Copying: ${source}p${src_rfs_part} -> ${destination}p${dest_rfs_part} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: [umount /tmp/rootfs/ || umount -l /tmp/rootfs/ || write_failure]" ; broadcast + umount /tmp/rootfs/ || umount -l /tmp/rootfs/ || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + + message="INFO: [umount /tmp || true]" ; broadcast + umount /tmp || true + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: Force writeback of eMMC buffers by Syncing: ${destination}" ; broadcast + message="INFO: [dd if=${destination} of=/dev/null count=100000 status=progress]" ; broadcast + dd if=${destination} of=/dev/null count=100000 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + if [ "x${has_usr_leds}" = "xenable" ] ; then + reset_leds + fi + + unset are_we_flasher + are_we_flasher=$(grep init-beagle-flasher /proc/cmdline || true) + if [ ! "x${are_we_flasher}" = "x" ] ; then + message="INFO: [We are init, trying to shutdown, we may crash, data is RO so safe]" ; broadcast + message="5" ; broadcast + sleep 1 + + if [ -f /proc/sysrq-trigger ] ; then + message="INFO: [found: /proc/sysrq-trigger]" ; broadcast + message="INFO: [found: echo s > /proc/sysrq-trigger" ; broadcast + message="INFO: [found: echo o > /proc/sysrq-trigger" ; broadcast + message="4" ; broadcast + sleep 1 + message="3" ; broadcast + sleep 1 + message="2" ; broadcast + sleep 1 + message="1" ; broadcast + sleep 1 + message="--------------------------------------------------------------------------------" ; broadcast + #For sync + echo s > /proc/sysrq-trigger + #For shutdown the system + echo o > /proc/sysrq-trigger + fi + + message="4" ; broadcast + sleep 1 + message="3" ; broadcast + sleep 1 + message="2" ; broadcast + sleep 1 + message="1" ; broadcast + sleep 1 + message="--------------------------------------------------------------------------------" ; broadcast + + #When run as init + exec /sbin/init + exit #We should not hit that + fi +} + +partition_drive () { + message="INFO: Erasing: [${destination}]" ; broadcast + flush_cache + message="INFO: [dd if=/dev/zero of=${destination} bs=1M count=148 status=progress]" ; broadcast + dd if=/dev/zero of=${destination} bs=1M count=148 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + sync + message="INFO: [dd if=${destination} of=/dev/null bs=1M count=148 status=progress]" ; broadcast + dd if=${destination} of=/dev/null bs=1M count=148 status=progress + message="--------------------------------------------------------------------------------" ; broadcast + sync + flush_cache + message="INFO: Erasing: [${destination}] complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${bootloader}" != "x" ] ; then + if [ -f ${bootloader} ] ; then + message="INFO: [/bin/bash ${bootloader}]" ; broadcast + /bin/bash ${bootloader} + message="--------------------------------------------------------------------------------" ; broadcast + fi + fi + + rfs_boot_permissions=${rfs_boot_permissions:-"defaults"} + + if [ "x${rfs_partition}" = "xhybrid" ] ; then + partition_one_start_mb=${rfs_rootfs_startmb:-"1"} + partition_one_fstype=${rfs_sfdisk_fstype:-"L"} + + single_root_label=${single_root_label:-"rootfs"} + + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,,${partition_one_fstype},*]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,,${partition_one_fstype},* + __EOF__ + + flush_cache + message="INFO: Formatting: ${destination}" ; broadcast + format_single_root + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="1" + else + src_rfs_part=${src_rfs_part:-"2"} + dest_rfs_part="1" + fi + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xhybrid_swap" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb="${rfs_swap_size_mb}" + partition_one_fstype=${rfs_sfdisk_fstype:-"0x82"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + rootfs_label=${rootfs_label:-"rootfs"} + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},-]" ; broadcast + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},- + ${partition_two_start_mb}M,,,- + __EOF__ + + flush_cache + + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="2" + + message="INFO: Formatting: ${destination}" ; broadcast + format_root + LC_ALL=C mkswap ${destination}p1 + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot_extlinux + copy_rootfs + elif [ "x${rfs_partition}" = "xdual" ] ; then + partition_one_start_mb=${rfs_boot_startmb:-"1"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} + partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} + + partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + partition_two_size_mb="${rfs_swap_size_mb}" + partition_three_start_mb=$(($partition_one_start_mb + $partition_one_size_mb + $partition_two_size_mb)) + fi + + boot_label=${boot_label:-"FIRMWARE"} + rootfs_label=${rootfs_label:-"rootfs"} + + sfdisk_options="--force --wipe-partitions always" + + message="INFO: Partitioning: ${destination}" ; broadcast + message="INFO: sfdisk: [$(LC_ALL=C sfdisk --version)]" ; broadcast + message="INFO: sfdisk: [sfdisk ${sfdisk_options} ${destination}]" ; broadcast + message="INFO: sfdisk: [${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},*]" ; broadcast + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + message="INFO: sfdisk: [${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,-]" ; broadcast + message="INFO: sfdisk: [${partition_three_start_mb}M,,,-]" ; broadcast + else + message="INFO: sfdisk: [${partition_two_start_mb}M,,,-]" ; broadcast + fi + message="--------------------------------------------------------------------------------" ; broadcast + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* + ${partition_two_start_mb}M,${partition_two_size_mb}M,0x82,- + ${partition_three_start_mb}M,,,- + __EOF__ + else + LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__ + ${partition_one_start_mb}M,${partition_one_size_mb}M,${partition_one_fstype},* + ${partition_two_start_mb}M,,,- + __EOF__ + fi + + flush_cache + + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + src_rfs_part=${src_rfs_part:-"3"} + dest_rfs_part="3" + else + src_rfs_part=${src_rfs_part:-"2"} + dest_rfs_part="2" + fi + + message="INFO: Formatting: ${destination}" ; broadcast + format_boot + format_root + if [ "x${rfs_swap_size_mb}" != "x" ] ; then + LC_ALL=C mkswap ${destination}p2 + fi + message="INFO: Formatting: ${destination} complete" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + + copy_boot + copy_rootfs + else + example_failure + fi +} + +###FIXME +if [ -f /etc/default/beagle-flasher ] ; then + . /etc/default/beagle-flasher + message="--------------------------------------------------------------------------------" ; broadcast + message="Version: [${version_message}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="cat /etc/default/beagle-flasher:" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="`cat /etc/default/beagle-flasher`" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast +else + message="--------------------------------------------------------------------------------" ; broadcast + message="Version: [${version_message}]" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + example_failure +fi + +check_running_system +partition_drive diff --git a/bb-beagle-flasher/suite/jammy/debian/install b/bb-beagle-flasher/suite/jammy/debian/install index d3547d33c0a0e1fc535eb2403de470f664541e8f..d8483c3f31326a0bb9c09e309a2bafd8350a13f1 100644 --- a/bb-beagle-flasher/suite/jammy/debian/install +++ b/bb-beagle-flasher/suite/jammy/debian/install @@ -1,8 +1,11 @@ debian/beagle-flasher /usr/sbin/ debian/beagle-flasher-boot-emmc-rootfs-nvme /usr/sbin/ debian/beagle-flasher-boot-mmc-rootfs-sda /usr/sbin/ +debian/beagle-flasher-mv-rootfs-to-nvme /usr/sbin/ +debian/beagle-flasher-mv-rootfs-to-sda /usr/sbin/ debian/enable-beagle-flasher /usr/sbin/ debian/init-beagle-flasher /usr/sbin/ +debian/init-beagle-flasher-mv-rootfs-to-nvme /usr/sbin/ debian/am62-emmc-to-microsd /etc/beagle-flasher/ debian/am62-microsd-to-emmc /etc/beagle-flasher/ debian/bbai64-emmc-to-microsd /etc/beagle-flasher/ diff --git a/bb-beagle-flasher/suite/noble/debian/beagle-flasher b/bb-beagle-flasher/suite/noble/debian/beagle-flasher index 0ae06ae0e70a65ae314c0eb045a35214e021ab4d..4fa22195d51a708e5366c467ca0677ebcb1c16df 100755 --- a/bb-beagle-flasher/suite/noble/debian/beagle-flasher +++ b/bb-beagle-flasher/suite/noble/debian/beagle-flasher @@ -292,12 +292,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache @@ -438,7 +438,7 @@ partition_drive () { copy_rootfs elif [ "x${rfs_partition}" = "xdual" ] ; then partition_one_start_mb=${rfs_boot_startmb:-"1"} - partition_one_size_mb=${rfs_boot_size_mb:-"128"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) diff --git a/bb-beagle-flasher/suite/noble/debian/beagle-flasher-boot-emmc-rootfs-nvme b/bb-beagle-flasher/suite/noble/debian/beagle-flasher-boot-emmc-rootfs-nvme index ea85c0fb406854cd9217a1b120ba673015c5cb7a..9a6be0e6413f9919c614d7d2df85d308bde5a881 100755 --- a/bb-beagle-flasher/suite/noble/debian/beagle-flasher-boot-emmc-rootfs-nvme +++ b/bb-beagle-flasher/suite/noble/debian/beagle-flasher-boot-emmc-rootfs-nvme @@ -267,12 +267,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/noble/debian/beagle-flasher-boot-mmc-rootfs-sda b/bb-beagle-flasher/suite/noble/debian/beagle-flasher-boot-mmc-rootfs-sda index 647c3ce36f1212b450db1440bb1421fba5f6c286..394a3c31a70ae4f7fca5511f16ca361c085f94a4 100755 --- a/bb-beagle-flasher/suite/noble/debian/beagle-flasher-boot-mmc-rootfs-sda +++ b/bb-beagle-flasher/suite/noble/debian/beagle-flasher-boot-mmc-rootfs-sda @@ -116,6 +116,17 @@ broadcast_over_display () { } example_failure () { + message="Example: /etc/default/beagle-flasher" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="source=/dev/mmcblk0" ; broadcast + message="destination=/dev/mmcblk1" ; broadcast + message="rfs_partition=dual" ; broadcast + message="rfs_boot_startmb=1" ; broadcast + message="rfs_boot_size_mb=256" ; broadcast + message="bootloader=/opt/u-boot/bb-u-boot-beagleboneai64/install-emmc.sh" ; broadcast + message="flash_back=bbai64-emmc-to-microsd" ; broadcast + message="extlinux=/opt/u-boot/bb-u-boot-beagleboneai64/emmc-extlinux.conf" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast exit 2 } @@ -267,12 +278,12 @@ copy_rootfs () { mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/noble/debian/beagle-flasher-mv-rootfs-to-nvme b/bb-beagle-flasher/suite/noble/debian/beagle-flasher-mv-rootfs-to-nvme index 144aa0b5693bc332c821a50c1591c34747980f4e..afaa02b14e20e9964ce769f7be10641d4f86fd5a 100755 --- a/bb-beagle-flasher/suite/noble/debian/beagle-flasher-mv-rootfs-to-nvme +++ b/bb-beagle-flasher/suite/noble/debian/beagle-flasher-mv-rootfs-to-nvme @@ -267,12 +267,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/noble/debian/beagle-flasher-mv-rootfs-to-sda b/bb-beagle-flasher/suite/noble/debian/beagle-flasher-mv-rootfs-to-sda index 7d8fff82f44624e548d7c4bb54bd7164c96b2b35..947e56f4e4aed4567bcc15cca41ebfaccfe5f9ff 100755 --- a/bb-beagle-flasher/suite/noble/debian/beagle-flasher-mv-rootfs-to-sda +++ b/bb-beagle-flasher/suite/noble/debian/beagle-flasher-mv-rootfs-to-sda @@ -267,12 +267,12 @@ copy_rootfs () { mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/noble/debian/changelog b/bb-beagle-flasher/suite/noble/debian/changelog index 1a3ca7064d5be8cf0e314d37d8912ed6d286353e..4f2daf9dcbe7b45b46e4dab934f6947dce008dd6 100644 --- a/bb-beagle-flasher/suite/noble/debian/changelog +++ b/bb-beagle-flasher/suite/noble/debian/changelog @@ -1,4 +1,4 @@ -bb-beagle-flasher (1.20240620.0-0~noble+20240620) noble; urgency=low +bb-beagle-flasher (1.20240718.0-0~noble+20240718) noble; urgency=low * SK-AM69, support microSD -> usb sata * BBIA64/BeaglePlay, use u-boot versions of script files @@ -8,5 +8,5 @@ bb-beagle-flasher (1.20240620.0-0~noble+20240620) noble; urgency=low * Remove beagle-flasher-init-shutdown.service, single user will now shutdown * e2fsprogs (1.47.0) disable orphan_file, needs v5.15.x kernel - -- Robert Nelson <robertcnelson@gmail.com> Thu, 20 Jun 2024 09:14:06 -0500 + -- Robert Nelson <robertcnelson@gmail.com> Thu, 18 Jul 2024 11:24:51 -0500 diff --git a/bb-beagle-flasher/suite/noble/debian/init-beagle-flasher b/bb-beagle-flasher/suite/noble/debian/init-beagle-flasher index 0ad2d3426b45c92c24c7b80ec079b1f79323203c..fdc503bda929070152c31a5502086efd7a9e94e9 100755 --- a/bb-beagle-flasher/suite/noble/debian/init-beagle-flasher +++ b/bb-beagle-flasher/suite/noble/debian/init-beagle-flasher @@ -115,6 +115,17 @@ broadcast_over_display () { } example_failure () { + message="Example: /etc/default/beagle-flasher" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="source=/dev/mmcblk0" ; broadcast + message="destination=/dev/mmcblk1" ; broadcast + message="rfs_partition=dual" ; broadcast + message="rfs_boot_startmb=1" ; broadcast + message="rfs_boot_size_mb=256" ; broadcast + message="bootloader=/opt/u-boot/bb-u-boot-beagleboneai64/install-emmc.sh" ; broadcast + message="flash_back=bbai64-emmc-to-microsd" ; broadcast + message="extlinux=/opt/u-boot/bb-u-boot-beagleboneai64/emmc-extlinux.conf" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast exit 2 } @@ -275,7 +286,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/noble/debian/init-beagle-flasher-mv-rootfs-to-nvme b/bb-beagle-flasher/suite/noble/debian/init-beagle-flasher-mv-rootfs-to-nvme index b8928798a5782ec44fabcfdf54312cc92cc7f586..f5dc6e1bf643fca9cb2b5eb76e9adede25fd6884 100755 --- a/bb-beagle-flasher/suite/noble/debian/init-beagle-flasher-mv-rootfs-to-nvme +++ b/bb-beagle-flasher/suite/noble/debian/init-beagle-flasher-mv-rootfs-to-nvme @@ -269,7 +269,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/trixie/debian/beagle-flasher b/bb-beagle-flasher/suite/trixie/debian/beagle-flasher index 0ae06ae0e70a65ae314c0eb045a35214e021ab4d..4fa22195d51a708e5366c467ca0677ebcb1c16df 100755 --- a/bb-beagle-flasher/suite/trixie/debian/beagle-flasher +++ b/bb-beagle-flasher/suite/trixie/debian/beagle-flasher @@ -292,12 +292,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache @@ -438,7 +438,7 @@ partition_drive () { copy_rootfs elif [ "x${rfs_partition}" = "xdual" ] ; then partition_one_start_mb=${rfs_boot_startmb:-"1"} - partition_one_size_mb=${rfs_boot_size_mb:-"128"} + partition_one_size_mb=${rfs_boot_size_mb:-"256"} partition_one_fstype=${rfs_sfdisk_fstype:-"0xc"} partition_two_start_mb=$(($partition_one_start_mb + $partition_one_size_mb)) diff --git a/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-boot-emmc-rootfs-nvme b/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-boot-emmc-rootfs-nvme index ea85c0fb406854cd9217a1b120ba673015c5cb7a..9a6be0e6413f9919c614d7d2df85d308bde5a881 100755 --- a/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-boot-emmc-rootfs-nvme +++ b/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-boot-emmc-rootfs-nvme @@ -267,12 +267,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-boot-mmc-rootfs-sda b/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-boot-mmc-rootfs-sda index 647c3ce36f1212b450db1440bb1421fba5f6c286..394a3c31a70ae4f7fca5511f16ca361c085f94a4 100755 --- a/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-boot-mmc-rootfs-sda +++ b/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-boot-mmc-rootfs-sda @@ -116,6 +116,17 @@ broadcast_over_display () { } example_failure () { + message="Example: /etc/default/beagle-flasher" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="source=/dev/mmcblk0" ; broadcast + message="destination=/dev/mmcblk1" ; broadcast + message="rfs_partition=dual" ; broadcast + message="rfs_boot_startmb=1" ; broadcast + message="rfs_boot_size_mb=256" ; broadcast + message="bootloader=/opt/u-boot/bb-u-boot-beagleboneai64/install-emmc.sh" ; broadcast + message="flash_back=bbai64-emmc-to-microsd" ; broadcast + message="extlinux=/opt/u-boot/bb-u-boot-beagleboneai64/emmc-extlinux.conf" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast exit 2 } @@ -267,12 +278,12 @@ copy_rootfs () { mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-mv-rootfs-to-nvme b/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-mv-rootfs-to-nvme index 144aa0b5693bc332c821a50c1591c34747980f4e..afaa02b14e20e9964ce769f7be10641d4f86fd5a 100755 --- a/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-mv-rootfs-to-nvme +++ b/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-mv-rootfs-to-nvme @@ -267,12 +267,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-mv-rootfs-to-sda b/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-mv-rootfs-to-sda index 7d8fff82f44624e548d7c4bb54bd7164c96b2b35..947e56f4e4aed4567bcc15cca41ebfaccfe5f9ff 100755 --- a/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-mv-rootfs-to-sda +++ b/bb-beagle-flasher/suite/trixie/debian/beagle-flasher-mv-rootfs-to-sda @@ -267,12 +267,12 @@ copy_rootfs () { mount ${destination}${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/trixie/debian/changelog b/bb-beagle-flasher/suite/trixie/debian/changelog index 7c9e7539a02250fce48910ed48e34d3c78ec2be9..7653794f6d9261dcca3ebdf1f36dffa4f01f60bc 100644 --- a/bb-beagle-flasher/suite/trixie/debian/changelog +++ b/bb-beagle-flasher/suite/trixie/debian/changelog @@ -1,4 +1,4 @@ -bb-beagle-flasher (1.20240620.0-0~trixie+20240620) trixie; urgency=low +bb-beagle-flasher (1.20240718.0-0~trixie+20240718) trixie; urgency=low * SK-AM69, support microSD -> usb sata * BBIA64/BeaglePlay, use u-boot versions of script files @@ -8,5 +8,5 @@ bb-beagle-flasher (1.20240620.0-0~trixie+20240620) trixie; urgency=low * Remove beagle-flasher-init-shutdown.service, single user will now shutdown * e2fsprogs (1.47.0) disable orphan_file, needs v5.15.x kernel - -- Robert Nelson <robertcnelson@gmail.com> Thu, 20 Jun 2024 09:14:06 -0500 + -- Robert Nelson <robertcnelson@gmail.com> Thu, 18 Jul 2024 11:24:51 -0500 diff --git a/bb-beagle-flasher/suite/trixie/debian/init-beagle-flasher b/bb-beagle-flasher/suite/trixie/debian/init-beagle-flasher index 0ad2d3426b45c92c24c7b80ec079b1f79323203c..fdc503bda929070152c31a5502086efd7a9e94e9 100755 --- a/bb-beagle-flasher/suite/trixie/debian/init-beagle-flasher +++ b/bb-beagle-flasher/suite/trixie/debian/init-beagle-flasher @@ -115,6 +115,17 @@ broadcast_over_display () { } example_failure () { + message="Example: /etc/default/beagle-flasher" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast + message="source=/dev/mmcblk0" ; broadcast + message="destination=/dev/mmcblk1" ; broadcast + message="rfs_partition=dual" ; broadcast + message="rfs_boot_startmb=1" ; broadcast + message="rfs_boot_size_mb=256" ; broadcast + message="bootloader=/opt/u-boot/bb-u-boot-beagleboneai64/install-emmc.sh" ; broadcast + message="flash_back=bbai64-emmc-to-microsd" ; broadcast + message="extlinux=/opt/u-boot/bb-u-boot-beagleboneai64/emmc-extlinux.conf" ; broadcast + message="--------------------------------------------------------------------------------" ; broadcast exit 2 } @@ -275,7 +286,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/suite/trixie/debian/init-beagle-flasher-mv-rootfs-to-nvme b/bb-beagle-flasher/suite/trixie/debian/init-beagle-flasher-mv-rootfs-to-nvme index b8928798a5782ec44fabcfdf54312cc92cc7f586..f5dc6e1bf643fca9cb2b5eb76e9adede25fd6884 100755 --- a/bb-beagle-flasher/suite/trixie/debian/init-beagle-flasher-mv-rootfs-to-nvme +++ b/bb-beagle-flasher/suite/trixie/debian/init-beagle-flasher-mv-rootfs-to-nvme @@ -269,7 +269,12 @@ copy_rootfs () { mount ${destination}p${dest_rfs_part} /tmp/rootfs/ -o async,noatime message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast - rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure + message="--------------------------------------------------------------------------------" ; broadcast + flush_cache + + message="INFO: rsync: (-aHAXx) [/ -> /tmp/rootfs/]" ; broadcast + rsync -aHAXx --human-readable --info=progress2 /* /tmp/rootfs/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/media/*,/lost+found,/lib/modules/*,/boot/firmware/*} || write_failure message="--------------------------------------------------------------------------------" ; broadcast flush_cache diff --git a/bb-beagle-flasher/version.sh b/bb-beagle-flasher/version.sh index d276e7ff3e0aafc8516f0a7b83921aa07148e3db..b0c18b82f8b32cb5c0285baf664cda096e7a12d8 100644 --- a/bb-beagle-flasher/version.sh +++ b/bb-beagle-flasher/version.sh @@ -2,7 +2,7 @@ package_name="bb-beagle-flasher" debian_pkg_name="${package_name}" -package_version="1.20240620.0" +package_version="1.20240718.0" package_source="" src_dir="" @@ -17,8 +17,8 @@ debian_patch="" clear_changelog="enable" -bullseye_version="~bullseye+20240620" -bookworm_version="~bookworm+20240620" -trixie_version="~trixie+20240620" -jammy_version="~jammy+20240620" -noble_version="~noble+20240620" +bullseye_version="~bullseye+20240718" +bookworm_version="~bookworm+20240718" +trixie_version="~trixie+20240718" +jammy_version="~jammy+20240718" +noble_version="~noble+20240718"