In this entry I’m going to explain how I could recover information from my router (APU1D4) when router doesn’t boot. Since a couple of days I get this error message booting device:
elf64_loadimage: failed to read section headers
I have to say that I had installed pfSense 2.4.2-RELEASE on my router, this distribution is based on FreeBSD, and after some time investigating I couldn’t find the problem so I decided to get all useful data from my router (I had an internal Git repo running there) and reinstall it.
To access to router internal drive I installed a new pfSense version to write in a memory stick:
$ gunzip -c pfSense-CE-memstick-serial-2.4.4-RELEASE-p3-amd64.img.gz | sudo dd of=/dev/sdc bs=1M
Check USB stick:
$ fdisk -l /dev/sdc Disk /dev/sdc: 15 GiB, 16122904576 bytes, 31490048 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: 0x90909090 Device Boot Start End Sectors Size Id Type /dev/sdc1 1 1600 1600 800K ef EFI (FAT-12/16/32) /dev/sdc2 * 1601 1477200 1475600 720.5M a5 FreeBSD /dev/sdc3 1477201 1550928 73728 36M b W95 FAT32
Plug USB memstick in my router and press F10 while is booting to select boot device:
Press F10 key now for boot menu: Select boot device: 1. USB MSC Drive UFD 3.0 Silicon-Power16G 1100 2. AHCI/0: TS32GMSA370 ATA-9 Hard-Disk (30533 MiBytes) 3. Payload [setup] 4. Payload [memtest] Select boot device: 1
Then follow all steps needed I can select the following option:
Rescue Shell > Launch a shell for rescue operations
Once I’m in rescue shell I need to mount my internal drive to copy my internal repository to an external computer in my LAN, but I need to find which the device name and partition is used by my old pfsense installation using these commands:
# geom disk list Geom name: ada0 Providers: 1. Name: ada0 Mediasize: 32017047552 (30G) Sectorsize: 512 Mode: r0w0e0 descr: TS32GMSA370 ident: D007501916 rotationrate: 0 fwsectors: 63 fwheads: 16 ...
Device name found and now:
# gpart show -p => 63 62533233 ada0 MBR (30G) 63 62533233 ada0s1 freebsd [active] (30G) => 0 62533233 ada0s1 BSD (30G) 0 16 - free - (8.0K) 16 45756001 ada0s1a freebsd-ufs (22G) 45756017 16777216 ada0s1b freebsd-swap (8.0G)
With partition name I can mount what I need:
# mount /dev/ada0s1a /mnt
At this point is needed to setup network interface to communicate with LAN using ifconfig command:
# ifconfig re0 192.168.1.XXX netmask 255.255.255.0 broadcast 192.168.1.255 up
And then we can copy all information that I need so I’m able to reinstall my router safetely.
It would be great to discover the root cause because FreeBSD kernel couldn’t read section headers but at least I didn’t loose any information.
Quite simple procedure but it was the first time I had to use a rescue shell in pfsense.
That’s all folks!!
—
“Well done is better than well said.”
— Benjamin Franklin
One thought on “Recover information when pfsense router doesn’t boot”