i have installed ubuntu-21.10-preinstalled-desktop-arm64+raspi.img.xz. is it possible to edit /boot/config.txt from the file itself so that we need not boot into the pi and then edit the config.txt and reboot? why not just directly edit the config.txt from the file and boot into the pi with that custom image? note so far i have opened the .img file from the downloaded .img.xz file without extracting and have got 2 mounted volumes "system-boot" and "writable".

  • AFAIK Ubuntu doesn't have /boot/config.txt. The boot files can be edited by any computer after writing a SD. But if you REALLY want to edit the image just loop mount on a Linux machine.
    – Milliways
    Jan 5 at 6:39
  • @Milliways , just now i tried but linux says it is mounted as a read-only filesystem.
    – user135142
    Jan 5 at 6:50
  • firstly should i add a file "/boot/config.txt" in "writable" or a file "config.txt" in "system-boot"?
    – user135142
    Jan 5 at 6:51
  • Last time I used Ubuntu on a Pi (before it became bloatware and refused to run on a 2GiB system) it had a different file system structure to Raspberry Pi OS. /boot is just where it is mounted on a booted Raspberry Pi OS system. Regardless the boot partition should be FAT32 - which can be read on any OS. If you really want to use Ubuntu you need to do it their way.
    – Milliways
    Jan 5 at 7:34
  • @Milliways , so system-boot is simply mounted on /boot?
    – user135142
    Jan 5 at 8:39

1 Answer 1


You can loop mount the image on a Linux machine then edit using normal tools.

The following is a script I use, but frankly is more work than just editing files.

# 2020-01-19
# Mount partitions on an OS Image
# Assumes only 2 partitions boot & root exist in Image

# IMG='/mnt/Image/BusterBackup.img'
# echo $IMG

  echo ""
  echo "$1"
  echo ""
  exit 1

if [[ "${IMG}" = "" ]]; then
    errexit "Usage: $0 imagefile"
if [ $(id -u) -ne 0 ]; then
    errexit "$0 must be run as root user"

# Check/create Mount Points
if [ ! -e $BOOT_MOUNT ]; then
    mkdir $BOOT_MOUNT
if [ ! -e $ROOT_MOUNT ]; then
    mkdir $ROOT_MOUNT

# Check Mount Points
if $(mountpoint -q $BOOT_MOUNT); then
    errexit "Mountpoint $BOOT_MOUNT already in use"
if $(mountpoint -q $ROOT_MOUNT); then
    errexit "Mountpoint $ROOT_MOUNT already in use"

# Loop mount all partitions on Image
LOOP="$(losetup --find --partscan --show ${IMG})"
if [ $? -ne 0 ]; then
    errexit "Unable to create loop device"

# echo $LOOP
SD1+="p1"   # partition containing boot files
SD2+="p2"   # partition containing OS files

# exit
# Mount Partitions 1 & 2
if ! $(mountpoint -q $BOOT_MOUNT); then
    mount $SD1 $BOOT_MOUNT  # mount partition containing boot files
if ! $(mountpoint -q $ROOT_MOUNT); then
    mount $SD2 $ROOT_MOUNT  # mount root partition containing OS files

echo "When finished, run:"
echo "sudo umount ${BOOT_MOUNT} ${ROOT_MOUNT}"
echo "sudo losetup -d ${LOOP}"
echo ""
  • didn't really work, it mounted everything as read only. had to edit the file as it was using everything except the actual /dev/loop* being used.
    – user135142
    Jan 5 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.