用的JP 7.2(39.2.0) 生成镜像有AB分区,A分区nvme0n1p1,B分区nvme0n1p2,用usb线刷原始的镜像system.img会烧录到nvme0n1p1,system.img_b会烧录到nvme0n1p2。我们有一个需求system.img的/mnt目录存放了10G内容刷写到nvme0n1p7,剩余的部分刷写到nvme0n1p1;system.img_b的/mnt目录存放了10G内容刷写到nvme0n1p11,剩余的部分刷写到nvme0n1p2;如何实现?
Hi,
One possible approach is to prepare separate images for the /mnt contents before USB flashing. This uses the partition XML’s <filename> field, which specifies the image to write to each partition.
- Prepare separate images: Create
mnt_a.imgandmnt_b.imgas filesystem images containing the respective A/B/mntcontents. Rebuildsystem.imgandsystem.img_bwith an empty/mntdirectory as the mount point. - Configure partition mappings: Assign each data image to its corresponding data partition in the XML. We need to confirm the existing purposes of
nvme0n1p7andnvme0n1p11before using them. - Configure mounts: In each rootfs’s
/etc/fstab, mount the corresponding data filesystem at/mntusing its unique filesystem UUID.
This customization needs validation on your configuration, particularly to confirm that /mnt uses the correct data partition after switching between A and B.
Recommendation: Please share the NVMe partition-layout XML used to generate these images so we can check the purposes and image mappings of p7/p11.
Reference: Jetson Linux R39.2 — Partition Configuration
Thanks.
确认p7和p11没有被占用。目前制作镜像的脚本 是 sudo EXT_NUM_SECTORS=239075328 SKIP_EEPROM_CHECK=1 UNIFIED_FLASH=1 ROOTFS_AB=1 ./tools/kernel_flash/l4t_initrd_flash.sh --no-flash p3834-0008-p4071-0000-nvme external 2>&1 | tee host-log_nvme.txt ,烧录脚本是sudo EXT_NUM_SECTORS=239075328 SKIP_EEPROM_CHECK=1 UNIFIED_FLASH=1 ROOTFS_AB=1 ./tools/kernel_flash/l4t_initrd_flash.sh --flash-only --external-device nvme1n1 -c tools/kernel_flash/flash_l4t_t264_nvme_rootfs_ab.xml --showlogs --erase-all p3834-0008-p4071-0000-nvme nvme1n1p1;实现这个需求是否需要修改你们的脚本?能否通过命令实现?
Hi,
Thanks for confirming that p7 and p11 are unused.
Based on the documented image-to-partition mapping, this should be achievable with image-preparation commands and XML/fstab changes, without modifying NVIDIA’s flashing-script source. Your specific configuration still needs validation.
The separate data images and their XML mappings need to be included when generating the flash package. --flash-only uses the images already generated; it does not perform the directory split.
Please attach the actual tools/kernel_flash/flash_l4t_t264_nvme_rootfs_ab.xml file used in your BSP so we can review the partition entries and identify the required changes.
Thank you.
xml
<?xml version="1.0"?>
<!--
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES.
# All rights reserved.
# SPDX-License-Identifier: LicenseRef-NvidiaProprietary
#
# NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
# property and proprietary rights in and to this material, related
# documentation and any modifications thereto. Any use, reproduction,
# disclosure or distribution of this material and related documentation
# without an express license agreement from NVIDIA CORPORATION or
# its affiliates is strictly prohibited.
-->
<!-- Nvidia Tegra Partition Layout Version 1.0.0 -->
<partition_layout version="01.00.0000">
<device type="external" instance="0" sector_size="512" num_sectors="EXT_NUM_SECTORS" >
<partition name="master_boot_record" type="protective_master_boot_record">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 512 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
</partition>
<partition name="primary_gpt" type="primary_gpt">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 19968 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
</partition>
<partition name="RECNAME" id="3" type="kernel">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> RECSIZE </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<filename> RECFILE </filename>
</partition>
<partition name="RECDTB-NAME" type="kernel_dtb">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 786432 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<filename> RECDTB_FILE </filename>
</partition>
<partition name="esp" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 536870912 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 0x8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<filename> ESP_FILE </filename>
<partition_type_guid> C12A7328-F81F-11D2-BA4B-00A0C93EC93B </partition_type_guid>
<description> **Required.** EFI system partition with L4T Launcher. </description>
</partition>
<partition name="A_reserved_on_user" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<!-- <size> 403439616 </size> -->
<!-- <size> 16106127360 </size> -->
<!-- <size> 21474836480 </size> -->
<size> 5368709120 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
</partition>
<partition name="RECNAME_alt" type="kernel">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> RECSIZE </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<filename> REC_ALT_FILE </filename>
</partition>
<partition name="RECDTB-NAME_alt" type="kernel_dtb">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 786432 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<filename> RECDTB_ALT_FILE </filename>
</partition>
<partition name="esp_alt" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 536870912 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 0x8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<filename> ESP_ALT_FILE </filename>
<description> **Required.** EFI system partition for fail-safe ESP update. </description>
</partition>
<partition name="B_reserved_on_user" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<!-- <size> 403439616 </size> -->
<!-- <size> 16106127360 </size> -->
<!-- <size> 21474836480 </size> -->
<size> 5368709120 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
</partition>
<partition name="UDA" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 419430400 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<align_boundary> 16384 </align_boundary>
<description> **Required.** This partition may be mounted and used to store user
data. </description>
</partition>
<partition name="reserved" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<!-- <size> 351272960 </size> -->
<size> 351272960 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<description> **Required.** Reserve space in case there is any partition change
required in the future, for example, adding new partitions or increasing size
of some partitions. </description>
</partition>
<partition name="APP" id="1" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> APPSIZE </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 0x8 </allocation_attribute>
<align_boundary> 16384 </align_boundary>
<percent_reserved> 0 </percent_reserved>
<unique_guid> APPUUID </unique_guid>
<filename> APPFILE </filename>
<description> **Required.** Contains the rootfs. This partition must be assigned
the "1" for id as it is physically put to the end of the device, so that it
can be accessed as the fixed known special device `/dev/nvme0n1p1`. </description>
</partition>
<partition name="APP_b" id="2" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> APPSIZE </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 0x8 </allocation_attribute>
<align_boundary> 16384 </align_boundary>
<percent_reserved> 0 </percent_reserved>
<unique_guid> APPUUID_b </unique_guid>
<filename> APPFILE_b </filename>
<description> **Required.** Contains the rootfs. This partition must be assigned
the "2" for id as it is physically put to the end of the device, so that it
can be accessed as the fixed known special device `/dev/nvme0n1p2`. </description>
</partition>
<partition name="secondary_gpt" type="secondary_gpt">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 0xFFFFFFFFFFFFFFFF </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
</partition>
</device>
</partition_layout>
Hi,
Thanks for sharing the XML. You can try preparing a separate data image with standard Linux commands, then mapping it to a dedicated user-data partition in your XML.
For example, run the following in a new working directory on the host. Replace /path/to/rootfs_a/mnt with the directory containing your A-slot data:
truncate -s 12G mnt_a.img
sudo mkfs.ext4 -F -L mnt_a -d /path/to/rootfs_a/mnt mnt_a.img
sudo blkid -p -s UUID -o value mnt_a.img
This creates a 12 GiB ext4 image containing that directory’s contents and prints its filesystem UUID. Adjust the image size for your data, and ensure the destination partition is at least as large. The -d option is described in the mke2fs documentation.
In the selected user-data partition’s XML entry, set:
<filename>mnt_a.img</filename>
Use a dedicated type="data" partition; preserve the recovery and EFI entries. Repeat for B using mnt_b.img and its own UUID.
Rebuild each rootfs with an empty /mnt directory, and add the corresponding data image’s UUID to that rootfs’s /etc/fstab:
UUID=<data-image-UUID> /mnt ext4 defaults 0 2
Include the data images and updated XML when regenerating the flash package. This example needs validation on your setup, including correct /mnt contents when booting either slot.
Reference: R39.2 Partition Configuration.
This request concerns a custom Linux filesystem layout and image preparation. No NVIDIA product defect has been demonstrated. The example above concludes our assistance with this customization. Implementation, testing, and maintenance are your responsibility; we will not provide further development or debugging support for this custom layout.
Thanks.
1、truncate -s 12G mnt_a.img
sudo mkfs.ext4 -F -L mnt_a -d /path/to/rootfs_a/mnt mnt_a.img
sudo blkid -p -s UUID -o value mnt_a.img 这三条命令是在 执行sudo EXT_NUM_SECTORS=239075328 SKIP_EEPROM_CHECK=1 UNIFIED_FLASH=1 ROOTFS_AB=1 ./tools/kernel_flash/l4t_initrd_flash.sh --no-flash p3834-0008-p4071-0000-nvme external 2>&1 | tee host-log_nvme.txt,之前执行么?
2、mnt_a.img 是在哪个XML修改?具体名称是什么?
修改后的
<partition_layout version=“01.00.0000”>
<device type="external" instance="0" sector_size="512" num_sectors="EXT_NUM_SECTORS" >
<partition name="master_boot_record" type="protective_master_boot_record">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 512 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
</partition>
<partition name="primary_gpt" type="primary_gpt">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 19968 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
</partition>
<partition name="RECNAME" id="3" type="kernel">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> RECSIZE </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<filename> RECFILE </filename>
</partition>
<partition name="RECDTB-NAME" type="kernel_dtb">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 786432 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<filename> RECDTB_FILE </filename>
</partition>
<partition name="esp" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 536870912 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 0x8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<filename> ESP_FILE </filename>
<partition_type_guid> C12A7328-F81F-11D2-BA4B-00A0C93EC93B </partition_type_guid>
<description> \*\*Required.\*\* EFI system partition with L4T Launcher. </description>
</partition>
<partition name="A_reserved_on_user" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<!-- <size> 403439616 </size> -->
<!-- <size> 16106127360 </size> -->
<!-- <size> 21474836480 </size> -->
<size> 5368709120 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
</partition>
<partition name="RECNAME_alt" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 22658678784 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<filename> mnt_a.img </filename>
</partition>
<partition name="RECDTB-NAME_alt" type="kernel_dtb">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 786432 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<filename> RECDTB_ALT_FILE </filename>
</partition>
<partition name="esp_alt" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 536870912 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 0x8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<filename> ESP_ALT_FILE </filename>
<description> \*\*Required.\*\* EFI system partition for fail-safe ESP update. </description>
</partition>
<partition name="B_reserved_on_user" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<!-- <size> 403439616 </size> -->
<!-- <size> 16106127360 </size> -->
<!-- <size> 21474836480 </size> -->
<size> 5368709120 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
</partition>
<partition name="UDA" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 22978075034 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<align_boundary> 16384 </align_boundary>
<description> \*\*Required.\*\* This partition may be mounted and used to store user
data. </description>
<filename> mnt_b.img </filename>
</partition>
<partition name="reserved" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<!-- <size> 351272960 </size> -->
<size> 2499063808 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<description> \*\*Required.\*\* Reserve space in case there is any partition change
required in the future, for example, adding new partitions or increasing size
of some partitions. </description>
</partition>
<partition name="APP" id="1" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> APPSIZE </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 0x8 </allocation_attribute>
<align_boundary> 16384 </align_boundary>
<percent_reserved> 0 </percent_reserved>
<unique_guid> APPUUID </unique_guid>
<filename> APPFILE </filename>
<description> \*\*Required.\*\* Contains the rootfs. This partition must be assigned
the "1" for id as it is physically put to the end of the device, so that it
can be accessed as the fixed known special device \`/dev/nvme0n1p1\`. </description>
</partition>
<partition name="APP_b" id="2" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> APPSIZE </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 0x8 </allocation_attribute>
<align_boundary> 16384 </align_boundary>
<percent_reserved> 0 </percent_reserved>
<unique_guid> APPUUID_b </unique_guid>
<filename> APPFILE_b </filename>
<description> \*\*Required.\*\* Contains the rootfs. This partition must be assigned
the "2" for id as it is physically put to the end of the device, so that it
can be accessed as the fixed known special device \`/dev/nvme0n1p2\`. </description>
</partition>
<partition name="secondary_gpt" type="secondary_gpt">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 0xFFFFFFFFFFFFFFFF </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
</partition>
</device>
</partition_layout> 目前sudo mkfs.ext4 -F -L mnt_a -d /path/to/rootfs_a/mnt mnt_a.img后 mnt_a.img只用了1G空间,但是无法烧录到nvme0n1p7,需要把mnt_a.img和mnt_b.img 放到哪个目录下面?
修改上面的内容 制作镜像会会有错误
This might work.
cp mnt_a.img Linux_for_Tegra/bootloader/
Do not modify RECNAME_alt. nvme0n1p7 is the alternate recovery-kernel partition.
flash_l4t_t264_nvme_rootfs_ab.xml.txt (8.6 KB)
-<partition name="reserved" type="data">
- <allocation_policy> sequential </allocation_policy>
- <filesystem_type> basic </filesystem_type>
- <size> 351272960 </size>
- <file_system_attribute> 0 </file_system_attribute>
- <allocation_attribute> 8 </allocation_attribute>
- <percent_reserved> 0 </percent_reserved>
- <description> **Required.** Reserve space in case there is any partition change
- required in the future, for example, adding new partitions or increasing size
- of some partitions. </description>
-</partition>
+ <partition name="mnt_a" type="data">
+ <allocation_policy> sequential </allocation_policy>
+ <filesystem_type> basic </filesystem_type>
+ <size> 22658678784 </size>
+ <file_system_attribute> 0 </file_system_attribute>
+ <allocation_attribute> 8 </allocation_attribute>
+ <percent_reserved> 0 </percent_reserved>
+ <align_boundary> 16384 </align_boundary>
+ <filename> mnt_a.img </filename>
+ <description> User-defined data partition containing mnt_a.img. </description>
+ </partition>
You may already be past this, but here it is. If you modify this example to your information it may do what you want. Instead of git clone, use du -h to the directory holding your data for mnt_a.img
You may also need to do @wichiu steps for mnt_b.img using same commands used to create mnt_a.img and add a second partition name=“mnt_b” added to flash_l4t_t264_nvme_rootfs_ab.xml but I have no experience whether it would work.
Example:
git clone GitHub - nvidia-holoscan/holoscan-sdk: The AI sensor processing SDK for low latency streaming workflows · GitHub
du -h holoscan-sdk/
185M holoscan-sdk
truncate -s 512M mnt_a.img
ls -al mnt_a.img
-rw-rw-r-- 1 scott scott 536870912 Sep 20 18:24 mnt_a.img
sudo mkfs.ext4 -F -L mnt_a -d holoscan-sdk mnt_a.img
sudo blkid -p -s UUID -o value mnt_a.img
3ed9a42f-9428-49c6-a1b9-f131cc936414
cd Linux_for_Tegra
cp mnt_a.img bootloader/
nano tools/kernel_flash/flash_l4t_t264_nvme_rootfs_ab.xml
<partition name="mnt_a" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> `536870912` </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 8 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<align_boundary> 16384 </align_boundary>
<filename> mnt_a.img </filename>
<description> User-defined data partition containing mnt_a.img. </description>
</partition>
sudo nano rootfs/etc/fstab
UUID=3ed9a42f-9428-49c6-a1b9-f131cc936414 /mnt ext4 defaults 0 2
-
Above steps should be executed before running:
sudo EXT_NUM_SECTORS=239075328 SKIP_EEPROM_CHECK=1 UNIFIED_FLASH=1 ROOTFS_AB=1
./l4t_initrd_flash.sh --no-flash
–external-device nvme0n1
[ -c ./tools/kernel_flash/flash_l4t_t264_nvme_rootfs_ab.xml ]
3834-0008-p4071-0000-nvme external 2>&1 | tee host-log_nvme.txt -
In which XML file is
mnt_a.imgmodified? What is the specific name of the file?
tools/kernel_flash/flash_l4t_t264_nvme_rootfs_ab.xml
and
rootfs/etc/fstab
Thank you, this feature is now available



