Accessing pfSense CF card
I have just removed a 4GB Compact Flash card from one of ALIX.2 devices running pfSense.
I've connected it via USB card reader to a server running Debian 8 but struggle to examine any data on it.
GNU Parted 3.2
Welcome to GNU Parted! Type 'help' to view a list of commands.
Model: Multi-Reader -0 (scsi)
Disk /dev/sdb: 3997MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 1968MB 1968MB primary boot
2 1968MB 3937MB 1968MB primary
3 3937MB 3989MB 52.6MB primary sun-ufs
/dev/sdb1: PTUUID="90909090" PTTYPE="dos" PARTUUID="90909090-01"
/dev/sdb2: PTUUID="90909090" PTTYPE="dos" PARTUUID="90909090-02"
/dev/sdb3: UUID="567870dc15ada898" TYPE="ufs" PARTUUID="90909090-03"
When trying to mount sdb1 I get:
[259868.588702] FAT-fs (sdb1): utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!
[259868.593612] FAT-fs (sdb1): bogus number of reserved sectors
[259868.593791] FAT-fs (sdb1): Can't find a valid FAT filesystem
When trying to mount sdb3 as ufs I get:
mount: /dev/sdb3 is write-protected, mounting read-only
ls: reading directory /mnt/tmp1: Input/output error
[259227.248028] UFS-fs error (device sdb3): ufs_check_page: bad entry in directory #2: rec_len is too small for name_len - offset=0, rec_len=12, name_len=260
[259227.248493] UFS-fs error (device sdb3): ufs_readdir: bad page in #2
How to read it under Linux?
Is it likely that the card or the image are faulty?
All three slices should be UFS, so the fact that it says DOS is troubling.
I have never been able to read UFS volumes on Linux, but there may be some trick I don't know. Your best bet is to boot a BSD system (FreeBSD, PC BSD, etc) and try to mount the card there
It might say dos but that's for sure a misidenfication, most likely parted not being even aware of the BSD partition type for a primary partition because that's what pfSense uses when you do a standard MBR install. The actual partitions are then inside the BSD type container partition, in FreeBSD terminology if the disk is da0 then the first slice "primary partition" is da0s1 and the first real partition inside the first slice is da0s1a. Linux tools tend to be totally ignorant of this partitioning scheme.
I have now booted into FreeBSD 10.3 live DVD and connected the same USB CF card reader with pfSense card.
"sade" provides me with the following:
da4 3.7GB MBR
da4s1 1.8GB BSD
da4s1a 1.8GB !0
da4s2 1.8GB BSD
da4s2a 1.8GB !0
da4s3 50MB freebsd
Does this output makes perfect sense to you and looks healthy?
Even though the partitioning looks weird (to me) pfSense boots up fine of it!
That's the NanoBSD partitioning scheme. There are two main slices, da4s1 and da4s2 and they are duplicate copies of each other to ease the update process. The UFS formatted partitions on those are da4s1a and da4s2a. You should be able to mount them from the live CD/DVD with these commands (using /tmp/* as mount directories because /mnt is read-only on the live CD/DVD environment):
mkdir /tmp/mnt1 mkdir /tmp/mnt2 mount /dev/da4s1a /tmp/mnt1 mount /dev/da4s2a /tmp/mnt2
The third slice da4s3 is the configuration slice that holds the configuration files. I don't quite know if it's supposed to be just a slice da4s3 or is there supposed to be partitioning behind it. Try this to mount it directly:
mkdir /tmp/mnt3 mount /dev/da4s3 /tmp/mnt3
If that doesn't work you probably have to use /dev/da4s3a.
Btw, there is a much better tool for showing partitions on disks:
[2.4.1-RELEASE][firstname.lastname@example.org]/root: gpart show => 40 62533216 ada0 GPT (30G) 40 409600 1 efi (200M) 409640 1024 2 freebsd-boot (512K) 410664 984 - free - (492K) 411648 4194304 3 freebsd-swap (2.0G) 4605952 57925632 4 freebsd-zfs (28G) 62531584 1672 - free - (836K)
What I'm actually trying to achieve is to:
1. Save an image / data of this (4G) card in case I need it back on it in the future (I'm suspecting the image is a 2G one).
Can I easily create a single .img file to be re-imported?
What other methods would you suggest?
2. Put a fresh image on it (I already have pfSense-CE-2.3.4-RELEASE-4g-i386-nanobsd.img downloaded).
Most likely I will use Rufus or Win32 Disk Imager as suggested here:
3. Import pfSense config from another ALIX2 device running an ancient 2.0.1 release.
4. Make a trip to the Data Centre and quickly swap the devices.
This is another related thread of mine:
Do I need a bigger CF card, say 8GB to store 2 copies of 4G image plus configuration?
Or is the image already appropriately sliced?
I'm not too familiar with NanoBSD but I just happened to be aware of how the partitioning works there. You'll have to hope that someone who knows more shares their knowledge here.