Debian:PocketBeagle 2 入门指南(3)

接上文:Debian:PocketBeagle 2 入门指南(2)

使用 genimage 创建根文件系统

主机软件包要求
#user@localhost:~$
sudo apt update ; \
sudo apt-get install -y dosfstools genimage mtools
创建 genimage 工作目录
#user@localhost:~$
sudo mkdir -p ./input/.rootfs
复制根文件系统
#user@localhost:~$
sudo tar xfvp ./debian-*-*-arm64-*/arm64-rootfs-*.tar -C ./input/.rootfs/
sync
启用首次启动自定义配置
#user@localhost:~$
sudo cp ./input/.rootfs/etc/bbb.io/templates/sysconf.txt ./input/

用文本编辑器打开./input/sysconf.txt,修改用户设置:

  • user_name=
  • user_password=
  • hostname=
#user@localhost:~$
sudo nano ./input/sysconf.txt
配置 extlinux.conf
#user@localhost:~$
sudo sh -c "echo 'label Linux' > ./input/extlinux.conf"
sudo sh -c "echo '    kernel /Image.gz' >> ./input/extlinux.conf"
sudo sh -c "echo '    fdtdir /' >> ./input/extlinux.conf"
sudo sh -c "echo '    append console=ttyS2,115200n8 earlycon=ns16550a,mmio32,0x02860000 root=/dev/mmcblk1p2 ro rootfstype=ext4 rootwait net.ifnames=0' >> ./input/extlinux.conf"
复制内核镜像

内核镜像:

#user@localhost:~$
sudo cp -v ./kernelbuildscripts/deploy/${kernel_version}.Image ./input/Image.gz
复制内核设备树二进制文件
#user@localhost:~$
sudo mkdir -p ./input/dtbs/
sudo tar xfv ./kernelbuildscripts/deploy/${kernel_version}-dtbs.tar.gz -C ./input/dtbs/
sudo cp -v ./input/dtbs/ti/k3-am6232-pocketbeagle2.dtb ./input/k3-am6232-pocketbeagle2.dtb
复制内核模块
#user@localhost:~$
sudo tar xfv ./kernelbuildscripts/deploy/${kernel_version}-modules.tar.gz -C ./input/.rootfs/usr/
文件系统表(/etc/fstab)
#user@localhost:~/$
sudo sh -c "echo '/dev/mmcblk1p2  /  auto  errors=remount-ro  0  1' >> ./input/.rootfs/etc/fstab"
sudo sh -c "echo '/dev/mmcblk1p1  /boot/firmware  vfat user,uid=1000,gid=1000,defaults 0 2' >> ./input/.rootfs/etc/fstab"
检查分区大小

Verify Root File partition size, this can be used to modify the seek value below for size tweaking.

#user@localhost:~$
sudo du -sh ./input/.rootfs/
创建 rootfs.ext4
#user@localhost:~$
sudo dd if=/dev/zero of=./input/rootfs.ext4 bs=1 count=0 seek=1600M
sudo mkfs.ext4 -F ./input/rootfs.ext4 -d ./input/.rootfs/

使用 genimage 创建 sdcard.img

The genimage GitHub - pengutronix/genimage: tool to generate multiple filesystem and flash images from a tree tool is now used to generate a sdcard.img vs directly interfacing with the microSD.

创建 genimage.cfg 文件
#user@localhost:~$
nano genimage.cfg
#genimage.cfg
image boot.vfat {
        vfat {
            files = {
                    "tispl.bin",
                    "u-boot.img",
                    "Image.gz",
                    "sysconf.txt",
            }
            file tiboot3.bin {
                    image = tiboot3-am62x-hs-fs-evm.bin
            }
            file ti/k3-am6232-pocketbeagle2.dtb {
                    image = k3-am6232-pocketbeagle2.dtb
            }
            file extlinux/extlinux.conf {
                    image = extlinux.conf
            }
        }
        size = 256M
}
image sdcard.img {
        hdimage {
        }
        partition u-boot {
                partition-type = 0xC
                bootable = "true"
                image = "boot.vfat"
        }
        partition rootfs {
                partition-type = 0x83
                image = "rootfs.ext4"
        }
}

运行 genimage 生成镜像

#user@localhost:~$
sudo genimage --rootpath `mktemp` --config genimage.cfg

genimage 输出
sdcard.img 可通过 rpi-imager(https://github.com/raspberrypi/rpi-imager)
或其他镜像写入工具烧录到 microSD 卡。

#user@localhost:~$
tree images/
images/
└── sdcard.img

1 directory, 1 file

最终调整(扩展根文件系统分区)

  • 将根文件系统分区扩展以填充驱动器上的可用空间。
使用 growpart 扩展分区表中的分区
sudo growpart /dev/mmcblk1 2
voodoo@eewiki:~$ sudo growpart /dev/mmcblk1 2
CHANGED: partition=2 start=524289 old: size=3276800 end=3801088 new: size=61809630 end=62333918
首次重启
sudo reboot
使用 resize2fs 扩容现有文件系统
sudo resize2fs /dev/mmcblk1p2
voodoo@eewiki:~$ sudo resize2fs /dev/mmcblk1p2
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/mmcblk1p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 4
The filesystem on /dev/mmcblk1p2 is now 7726203 (4k) blocks long.
第二次重启

This last reboot will take awhile as fsck is checking the partition on bootup.

sudo reboot

更多内容: