Debian/Ubuntu image creation

The script creates an image,no access to sdcard is needed. All ist done in local filesystem.

There are 6 partitions created (in atf branch of uboot-repo) first 4 are predefined by mtk,the 5th is BPI-BOOT which contains kernel and uboot config if needed, 6th is rootfs

Have you updated the script from git? I have open ears for better ideas :slight_smile:

You will see, at first it is too simple, to execute… but it does not say how it is going to do it.

and when it does it in a local directory of a virtual machine I get that error that I have put before.

What is needed for a device that is possibly going to work as a router are security modules since it does not make much sense not to defend a computer without these, as well as being able to do installations such as webmin, zenarmor and others, or even work as a VoIP application .

But first let’s see if I can make the image that is resisting compared to other devices.

It has the error that gives me further back in this thread

as I told you, the sd is big to be able to do many things

I have changed the script a bit so the error schould look differnt now,it checks for some packages now too

why this error?

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
         LANGUAGE = "en:en",
         LC_ALL = (unset),
         LC_PAPER = "es_ES.UTF-8",
         LC_NUMERIC = "es_ES.UTF-8",
         LC_IDENTIFICATION = "es_ES.UTF-8",
         LC_MEASUREMENT = "es_ES.UTF-8",
         LC_NAME = "es_ES.UTF-8",
         LC_TELEPHONE = "es_ES.UTF-8",
         LC_ADDRESS = "es_ES.UTF-8",
         LC_MONETARY = "es_ES.UTF-8",
         LC_TIME = "es_ES.UTF-8",
         LANG="C"
     are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
Preconfiguring packages ...




E: Can not write log (Is /dev/pts mounted?) - posix_openpt (19: No such device)




it gives an error below




After this operation, 5108 kB of additional disk space will be used.
Get:1 http://ftp.de.debian.org/debian bookworm/main arm64 libnl-3-200 arm64 3.7.0-0.2+b1 [60.2 kB]
Get:2 http://ftp.de.debian.org/debian bookworm/main arm64 libnl-genl-3-200 arm64 3.7.0-0.2+b1 [21.3 kB]
Get:3 http://ftp.de.debian.org/debian bookworm/main arm64 libnl-route-3-200 arm64 3.7.0-0.2+b1 [168 kB]
Get:4 http://ftp.de.debian.org/debian bookworm/main arm64 hostapd arm64 2:2.10-12 [797 kB]
Get:5 http://ftp.de.debian.org/debian bookworm/main arm64 xz-utils arm64 5.4.1-0.2 [469 kB]
Get:6 http://ftp.de.debian.org/debian bookworm/main arm64 iw arm64 5.19-1 [99.8 kB]
Fetched 1616 kB in 1s (1702 kB/s)
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
         LANGUAGE = "en:en",
         LC_ALL = (unset),
         LC_PAPER = "es_ES.UTF-8",
         LC_NUMERIC = "es_ES.UTF-8",
         LC_IDENTIFICATION = "es_ES.UTF-8",
         LC_MEASUREMENT = "es_ES.UTF-8",
         LC_NAME = "es_ES.UTF-8",
         LC_TELEPHONE = "es_ES.UTF-8",
         LC_ADDRESS = "es_ES.UTF-8",
         LC_MONETARY = "es_ES.UTF-8",
         LC_TIME = "es_ES.UTF-8",
         LANG="C"
     are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
E: Can not write log (Is /dev/pts mounted?) - posix_openpt (19: No such device)
Selecting previously unselected package libnl-3-200:arm64.



The following NEW packages will be installed:
  dbus dbus-bin dbus-daemon dbus-session-bus-common dbus-system-bus-common libdbus-1-3 libexpat1 libnss-myhostname libnss-resolve
  systemd-resolved
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 1259 kB of archives.
After this operation, 3724 kB of additional disk space will be used.
Get:1 http://ftp.de.debian.org/debian bookworm/main arm64 libdbus-1-3 arm64 1.14.8-2~deb12u1 [193 kB]
Get:2 http://ftp.de.debian.org/debian bookworm/main arm64 dbus-bin arm64 1.14.8-2~deb12u1 [103 kB]
Get:3 http://ftp.de.debian.org/debian bookworm/main arm64 dbus-session-bus-common all 1.14.8-2~deb12u1 [77.5 kB]
Get:4 http://ftp.de.debian.org/debian bookworm/main arm64 libexpat1 arm64 2.5.0-1 [84.8 kB]
Get:5 http://ftp.de.debian.org/debian bookworm/main arm64 dbus-daemon arm64 1.14.8-2~deb12u1 [175 kB]
Get:6 http://ftp.de.debian.org/debian bookworm/main arm64 dbus-system-bus-common all 1.14.8-2~deb12u1 [78.5 kB]
Get:7 http://ftp.de.debian.org/debian bookworm/main arm64 dbus arm64 1.14.8-2~deb12u1 [95.3 kB]
Get:8 http://ftp.de.debian.org/debian bookworm/main arm64 libnss-myhostname arm64 252.12-1~deb12u1 [80.8 kB]
Get:9 http://ftp.de.debian.org/debian bookworm/main arm64 systemd-resolved arm64 252.12-1~deb12u1 [279 kB]
Get:10 http://ftp.de.debian.org/debian bookworm/main arm64 libnss-resolve arm64 252.12-1~deb12u1 [92.3 kB]
Fetched 1259 kB in 1s (986 kB/s)
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "es:en",
        LC_ALL = (unset),
        LC_PAPER = "es_ES.UTF-8",
        LC_NUMERIC = "es_ES.UTF-8",
        LC_IDENTIFICATION = "es_ES.UTF-8",
        LC_MEASUREMENT = "es_ES.UTF-8",
        LC_NAME = "es_ES.UTF-8",
        LC_TELEPHONE = "es_ES.UTF-8",
        LC_ADDRESS = "es_ES.UTF-8",
        LC_MONETARY = "es_ES.UTF-8",
        LC_TIME = "es_ES.UTF-8",
        LANG = "C"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
E: Can not write log (Is /dev/pts mounted?) - posix_openpt (19: No such device)
Selecting previously unselected package libdbus-1-3:arm64.
(Reading database ... 11670 files and directories currently installed.)

it tries to write a log we do not need here…the changes are done in a chroot environment where i have not mounted local /dev/pts into the chroot…just ignore this one

and locale is unconfigured at this point as every user wants a different one…so i just leave it as it was

A good idea here is to calculate what space we have at the time of writing so that there is no space error when wanting storage and distribute it with the writing of the image so as not to have to modify the partitions that I suppose they have the same problem as the image that exists, which does not allow anything to be put

SIZE=$(sudo fdisk -l $SDCARD | awk ‘/Disk /dev/ {gsub(/[^0-9]/, “”, $3); print $3}’)

image

The image created is 7gb in size so that it fits on emmc too. Yes i can check if these 7g are available (or 8 because of other files downloaded/generated).

As i said…the script does nothing with a sdcard…it is local storage only,creates a image that can be wrotten to sdcard after script is finished. And there is no way to modify partitions here as they are created before

How about leaving the root partition as is, create a home partition that fills the rest of the card and use /etc/fstab to mount /home on it.

Every user can add a data partition till the end of the card after the image is written to the card.

At time of image creation nothing is known about the card image will be written to

Exactly what I meant

It generates other partitions apart from rootfs and boot, what are those partitions for? Of all of them, which one is the swap one or where is it?

It creates partitions used for bootchain (bl2,fip) a partition for uboot environment and recovery system (factory).

All partitions and their position and size are predefined by mtk. User partitions are only kernel (BPI-BOOT) and rootfs (BPI-ROOT). Swap makes not much sense on sdcard.

What wins or loses if you add swap to the SD, in your opinion?

swap-partition on sdcard creates many write-access (not good for flash) and it is not needed on a device having 2GB RAM

btw. my plan is to run the OS from nvme (using a lvm2 structure)

That got me curious what your plan is. But after reading this from Archlinux wiki (the wiki which I was already using a lot when running on ubuntu), I will stick with btrfs on nvme. I have that on my rockchip version of the script, but not on mediatek version yet…

https://wiki.archlinux.org/title/LVM#Disadvantages

That sounds very good, and with many more possibilities than an SD.

As you well know, and I sent you my SD, it is large, so nothing that I put with the original installation without a 6 or 8 Gb rootfs partition cannot add services such as ntp or adguardhome, or more services that this device can do

I have been able to expand the partition from another device but it is very cumbersome in the event of a device accident because it requires saving an image that becomes old and a repetitive task at best and turns the task into something tedious if you have to redo the whole process.

Whether it is an SD or a hard drive, the base partition by understanding and installation should be small to later expand, if not, unfortunately this blocks any service that you want to add Unbound, dnscrypt proxy, Tor, htop, tcdpdump, samba, webmin, zenarmor… etc

I think it’s a good idea to separate the user files, although I don’t think it’s a good team to have many of these files.

A hard drive will give more possibilities to this device, such as adding some modules such as 6.1.50-bpi-r3-main or QoS, security and drivers modules, although I did not load them.

When you start for the first time it should change the machine ID sudo rm -f /etc/machine-id sudo dbus-uuidgen --ensure=/etc/machine-idf sudo rm /var/lib/dbus/machine-id sudo dbus-uuidgen --ensure

could be useful.

Feel free changing the script in your fork like you want.

As i said partitions are created in uboot repo mtk-atf branch,but you can copy the code,remove existing rootfs partition and add a new bigger one.

Hi, I am really a no-nice here - but i managed to build the image and put it to the SD card, but it will not boot :frowning: The image from the googledrive seems to boot ok.

Here is the boot output: 1. Enter kernel-name to boot from SD/EMMC. 2. Boot kernel from TFTP. 3. Boot from SD/EMMC. U-Boot console

Press UP/DOWN to move, ENTER to select, ESC to quit

Error: “initrd” not defined

PARTITION_CONFIG only exists on eMMC sd available jedec_spi_nor spi_nor@0: unrecognized JEDEC id bytes: ff, ef, aa Failed to initialize SPI flash at 0:0 (error 0) NAND available sd nand fit=bpi-r3.itb Failed to load ‘bpi-r3.itb’ BPI-R3> BPI-R3> F0: 102B 0000 FA: 1040 0000 FA: 1040 0000 [0200] F9: 103F 0000 F3: 1001 0000 [0200] F3: 1001 0000 F6: 300C 0028 F5: 0000 0000 V0: 0000 0000 [0001] 00: 0000 0000 BP: 2400 0041 [0000] G0: 1190 0000 EC: 0000 0000 [3000] T0: 0000 01BD [010F] Jump to BL

NOTICE: BL2: v2.7(release):b1d713782 sdmmc NOTICE: BL2: Built : 08:16:49, Oct 3 2023 NOTICE: WDT: disabled NOTICE: CPU: MT7986 (2000MHz) NOTICE: EMI: Using DDR4 settings NOTICE: EMI: Detected DRAM size: 2048MB NOTICE: EMI: complex R/W mem test passed NOTICE: BL2: Booting BL31 NOTICE: BL31: v2.7(release):b1d713782 sdmmc NOTICE: BL31: Built : 08:16:54, Oct 3 2023

U-Boot 2023.10-bpi-g3252e0330-dirty (Oct 03 2023 - 08:16:07 +0000)

CPU: MediaTek MT7986 Model: BananaPi BPi-R3 DRAM: 2 GiB Core: 43 devices, 19 uclasses, devicetree: separate MMC: mmc@11230000: 0 Loading Environment from MMC… *** Warning - bad CRC, using default environment

In: serial@11002000 Out: serial@11002000 Err: serial@11002000 Net: Warning: ethernet@15100000 (eth0) using random MAC address - 3e:11:b9:9c:67:f4 eth0: ethernet@15100000 Hit any key to stop autoboot: 0

*** U-Boot Boot Menu ***

  1. Enter kernel-name to boot from SD/EMMC.
  2. Boot kernel from TFTP.
  3. Boot from SD/EMMC.
  U-Boot console

Press UP/DOWN to move, ENTER to select, ESC to quit

Error: “initrd” not defined

PARTITION_CONFIG only exists on eMMC sd available jedec_spi_nor spi_nor@0: unrecognized JEDEC id bytes: ff, ef, aa Failed to initialize SPI flash at 0:0 (error 0) NAND available sd nand fit=bpi-r3.itb Failed to load ‘bpi-r3.itb’ BPI-R3>

You have a bpi-r3.itb in root of BPI-BOOT partition? If yes i guess you fall into the u-boot mmc issue…i had this too but not reproducable…mostly it works,sometimes not with my sandisk cards…some users fixed it by using different cards

Hi, Oki, i took the same SD card, same IMG file, put it on windows and used WIN32DISK imager to put it on SD card - that seems to work… luck? no idea… /Kasper