Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5032

Raspberry Pi OS • Re: Installing new software directly to an image in a chroot (Botspot)

$
0
0
Using this script:

Code:

#!/bin/bash## $1: name of IMG to mount and systemd-nspawn into# $2: mount point (/mnt/$2)#function cleanup() {    if [[ "$mpt" != "" ]] && [[ "$loopdev" != "" ]]    then        if [ -d /mnt/$mpt/boot/firmware ]        then            umount /mnt/$mpt/{boot/firmware,}        else            umount /mnt/$mpt/{boot,}        fi        losetup -d $loopdev        [ "$mpt" != "sdm" ] && rm -rf /mnt/$mpt        mpt=""    fi}function errexit() {    echo -e "$1"    cleanup    exit 1}function doexit() {    cleanup    exit 0}img="$1"mpt="$2"[ "$img" == "" ] && errexit "? Missing IMG filename"[ "$mpt" == "" ] && mpt="sdm"[ -f $img ] || errexit "? File '$img' cannot be accessed"[ "$(which systemd-nspawn)" == "" ] && errexit "? sudo apt install systemd-container"[ "$(which sdm)" != "" ] && sdm --ppart $imgtrap "doexit" EXITloopdev=$(losetup --show -P -f $img)mkdir -p /mnt/$mpt/mount -v ${loopdev}p2 /mnt/$mptif [ -d /mnt/$mpt/boot/firmware ]then    mount -v ${loopdev}p1 /mnt/$mpt/boot/firmwareelse    mount -v ${loopdev}p1 /mnt/$mpt/bootfisystemd-nspawn --directory /mnt/$mpt < $(tty)sts=$?if [ $sts -eq 127 ]then    echo "? Cannot nspawn into 32-bit IMG on Pi5 16KB page system"fitrap EXITif [ -d /mnt/$mpt/boot/firmware ]then    umount /mnt/$mpt/{boot/firmware,}else    umount /mnt/$mpt/{boot,}filosetup -d $loopdev
apt update works for me:

Code:

pw/ssdy/work# /l/work/sdm/mini-nspawn 2024-11-19-raspios-bookworm-arm64-lite.img * Human-readable partition listModel:  (file)Disk /ssdy/work/2024-11-19-raspios-bookworm-arm64-lite.img: 7479297sSector size (logical/physical): 512B/512BPartition Table: msdosDisk Flags: Number  Start     End       Size      Type     File system  Flags 1      8192s     1056767s  1048576s  primary  fat32        lba 2      1056768s  7478515s  6421748s  primary  ext4* Machine-readable partition listBYT;/ssdy/work/2024-11-19-raspios-bookworm-arm64-lite.img:7479297s:file:512:512:msdos::;1:8192s:1056767s:1048576s:fat32::lba;2:1056768s:7478515s:6421748s:ext4::;mount: /dev/loop0p2 mounted on /mnt/sdm.mount: /dev/loop0p1 mounted on /mnt/sdm/boot/firmware.Spawning container sdm on /mnt/sdm.Press ^] three times within 1s to kill container....sdm~# apt updateHit:1 http://deb.debian.org/debian bookworm InReleaseHit:2 http://deb.debian.org/debian-security bookworm-security InReleaseHit:3 http://deb.debian.org/debian bookworm-updates InReleaseHit:4 http://archive.raspberrypi.com/debian bookworm InReleaseReading package lists... DoneBuilding dependency tree... DoneReading state information... Done1 package can be upgraded. Run 'apt list --upgradable' to see it.sdm~# dfFilesystem     1K-blocks    Used Available Use% Mounted on/dev/loop0p2     3092236 1993052    935364  69% //dev/loop0p1      522230   65526    456704  13% /boot/firmwaretmpfs             825776       0    825776   0% /tmptmpfs               4096       0      4096   0% /devtmpfs             825776       0    825776   0% /dev/shmtmpfs            1651536      48   1651488   1% /run/dev/sda2      461157304 6459816 435933740   2% /run/host/os-releasetmpfs             825776    5632    820144   1% /run/host/incomingsdm~# exitlogoutContainer sdm exited successfully.pw/ssdy/work# 
I'll leave it to you to sort out the difference(s)

Statistics: Posted by bls — Wed Dec 18, 2024 2:40 pm



Viewing all articles
Browse latest Browse all 5032

Trending Articles