I tried to mount sd card image created by OpenWrt Firmware selector and i get this error
: Warning: file does not end on a 512-byte sector boundary; the remaining end of the file will be ignored.
Failed to determine file system type for partition /dev/loop0p1. Skipping.
Failed to determine file system type for partition /dev/loop0p2. Skipping.
Failed to mount any partition as boot.
how can i mount images created by firmware selector on linux machine?
#!/bin/sh
Check if the image file is provided
if [ -z "$1" ]; thenecho "Usage: $0 <sdcard.img>"exit 1fi
IMAGE_FILE=$1
Check if the image file exists
if [ ! -f "$IMAGE_FILE" ]; thenecho "Image file $IMAGE_FILE does not exist."exit 1fi
Create mount points if they don't exist
mkdir -p mnt/bootmkdir -p mnt/rootfs
Use losetup to set up the loop device
LOOP_DEVICE=$(sudo losetup -f --show "$IMAGE_FILE")if [ -z "$LOOP_DEVICE" ]; thenecho "Failed to set up loop device."exit 1fi
Use fdisk to list partitions
PARTITIONS=$(sudo fdisk -l "$LOOP_DEVICE" | grep "^${LOOP_DEVICE}p" | awk '{print $1}')if [ -z "$PARTITIONS" ]; thenecho "No partitions found."sudo losetup -d "$LOOP_DEVICE"exit 1fi
Function to determine file system type and mount partition
mount_partition() {local partition=$1local mount_point=$2
Determine the file system type
fs_type=$(sudo blkid -o value -s TYPE "$partition")if [ -z "$fs_type" ]; thenecho "Failed to determine file system type for partition ${partition}. Skipping."return 1fi
Check if the mount point is already mounted
if mountpoint -q "$mount_point"; thenecho "Mount point ${mount_point} is already mounted. Unmounting..."sudo umount "$mount_point"if [ $? -ne 0 ]; thenecho "Failed to unmount ${mount_point}."return 1fifi
Mount the partition
sudo mount -t $fs_type "$partition" "$mount_point"if [ $? -ne 0 ]; thenecho "Failed to mount partition ${partition}."return 1fi
echo "Partition ${partition} mounted successfully on ${mount_point}."return 0}
Mount boot partition
boot_mounted=falsefor partition in $PARTITIONS; doif mount_partition "$partition" mnt/boot; thenboot_mounted=truebreakfidone
if [ "$boot_mounted" = false ]; thenecho "Failed to mount any partition as boot."sudo losetup -d "$LOOP_DEVICE"exit 1fi
Mount rootfs partition
rootfs_mounted=falsefor partition in $PARTITIONS; doif mount_partition "$partition" mnt/rootfs; thenrootfs_mounted=truebreakfidone
if [ "$rootfs_mounted" = false ]; thenecho "Failed to mount any partition as rootfs."sudo umount mnt/boot/sudo losetup -d "$LOOP_DEVICE"exit 1fi
echo "Partitions mounted successfully."
Cleanup function
cleanup() {sudo umount mnt/boot/sudo umount mnt/rootfs/sudo losetup -d "$LOOP_DEVICE"echo "Cleanup completed."}
Trap to call cleanup on script exit
trap cleanup EXIT
I'm using a Banana Pi R3, and i haven't found a way to mount the card on my linux pc.
I can see the partitions on the sd card with fdisk and blkid, but it seems its filesystems are not compatible with x86.
yes my manual attempts did not work i tried mounting it like a hdd image
i tried different filesystems but i still get the error
/ # fdisk -lu /router.img
Disk /router.img: 238 MiB, 249561088 bytes, 487424 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f
Device Boot Start End Sectors Size Id Type
/router.img1 1 1048607 1048607 512M ee GPT
/router.img2 * 34 8191 8158 4M 83 Linux
mount -t xxx -o loop,offset=1 /router.img /mnt/part1
mount: /mnt/part1: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
dmesg(1) may have more information after failed mount system call.
# -t xxx i tried different filesystems
mount -o loop,offset=1 /router.img /mnt/part1
mount: /mnt/part1: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
dmesg(1) may have more information after failed mount system call.
mount -a -o loop,offset=1 /router.img /mnt/part1
# i get no errors but nothing is mounted
Which OS and distribution are you trying to mount the image on?
This script has many syntax mistakes, including comments not starting with # and missing newlines (copy-paste from Windows, with Windows-style newlines?)
the script is generated by ai i tried manually without scripts nothing worked then i tried the ai script multiple variants none of them worked i did not look carefully at the ai script i have been trying this for some time without scripts and i had enough of it. i was able to mount other images hdd, iso, floppy images all worked .
You realize that embedded devices are picky and hard to recover?
If you want to make changes, you work on the source - what you're trying is not sensible (at least for a supported device), high risk, needs real experience and safety guards and far exceeds the abilities of an ai, by far - especially the particular specimen of an ai you picked. A kindergarten child mud wrestling with a dog would get better results by pure chance than this thing.
Since this script just uses mainly blkid, you won't get any better information than blkid can deliver.
Because (in my case the R3 sd-card) doesn't give any information about the file system.
I guess, they're all x86-pc images.
Or have you tried any image from an Atari ST e.g., or an Amiga or PC-88 system? I assume, all these won't work either.
Essentially you are demanding us to write a script from nothing. Does not work like that. Try to figure out how to use losetup to get /dev/loop0pX partitions out of raw image file. Then blkid and mount those to your liking. then unmount and un-losetup when done.
this error keeps appearing file does not end on a 512-byte sector boundary
losetup --partscan -f router.img
losetup: router.img: Warning: file does not end on a 512-byte sector boundary; the remaining end of the file will be ignored.