F3
F3 - Fight Flash Fraud
Install / Use
/learn @AltraMayor/F3README
f3 - Fight Flash Fraud
f3 is a simple tool that tests flash cards capacity and performance to see if they live up to claimed specifications. It fills the device with pseudorandom data and then checks if it returns the same on reading.
F3 stands for Fight Flash Fraud, or Fight Fake Flash.
Table of Contents
Examples <#examples>__Installation <#installation>__Other resources <#other-resources>__
.. _examples: .. highlight:: console
Examples
We'll use :code:/dev/sdX as a placeholder here, you need to replace
:code:X with a lowercase letter so that it matches the device you
want to use.
:code:lsblk will show you an overview of your current devices.
Testing performance with f3read/f3write
Use these two programs in this order. f3write will write large files to your mounted disk and f3read will check if the flash disk contains exactly the written files::
$ ./f3write /media/michel/5EBD-5C80/
$ ./f3read /media/michel/5EBD-5C80/
Please replace "/media/michel/5EBD-5C80/" with the appropriate path. USB devices are mounted in "/Volumes" on Macs.
If you have installed f3read and f3write, you can remove the "./" that is shown before their names.
Quick capacity tests with f3probe
f3probe is the fastest drive test and suitable for large disks because it only writes what's necessary to test the drive. It operates directly on the (unmounted) block device and needs to be run as a privileged user::
# ./f3probe --destructive --time-ops /dev/sdX
.. warning:: This will destroy any previously stored data on your disk!
Correcting capacity to actual size with f3fix
f3fix creates a partition that fits the actual size of the fake drive. Use f3probe's output to determine the parameters for f3fix::
# ./f3fix --last-sec=16477878 /dev/sdX
Installation
Download and Compile
The files of the stable version of F3 are
here <https://github.com/AltraMayor/f3/tags>__. The
following command uncompresses the files::
$ unzip f3-9.0.zip
.. highlight:: bash
Compile stable software on Linux or FreeBSD
To build::
make
If you want to install f3write and f3read, run the following command::
make install
Compile stable software on Windows/Cygwin
f3write and f3read can be installed on Windows, but currently f3probe, f3fix,
and f3brew require Linux <#the-extra-applications-for-linux>. To use them
on a Windows machine, use the Docker Installation <#docker>. For f3write
and f3read, read on.
If you haven't already, install the following Cygwin packages and their dependencies:
gcc-coremakelibargp-devel
To build, you need special flags::
export LDFLAGS="$LDFLAGS -Wl,--stack,4000000 -largp"
make
If you want to install f3write and f3read, run the following command::
make install
Compile stable software on Apple Mac
f3write and f3read can be installed on Mac, but currently f3probe, f3fix, and
f3brew require Linux <#the-extra-applications-for-linux>. To use them on
Mac, use the Docker Installation <#docker>. For f3write and f3read, read
on.
Using HomeBrew
If you have Homebrew already installed in your computer, the command
below will install F3::
brew install f3
Using MacPorts
If you use MacPorts instead, use the following command::
port install f3
Compiling the latest development version from the source code
Most of the f3 source code builds fine using Xcode, the only dependency
missing is the GNU C library "argp". You can build argp from scratch, or
use the version provided by HomeBrew and MacPorts as "argp-standalone"
The following steps have been tested on OS X El Capitan 10.11.
1) Install Apple command line tools::
xcode-select --install
See http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/
for details.
2) Install Homebrew or MacPorts
HomeBrew::
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
See https://brew.sh/ for details.
MacPorts: https://www.macports.org/install.php
3) Install argp library::
brew install argp-standalone
See https://formulae.brew.sh/formula/argp-standalone and
https://www.freshports.org/devel/argp-standalone/ for more
information.
Or, for MacPorts::
port install argp-standalone
See https://trac.macports.org/browser/trunk/dports/sysutils/f3/Portfile
for more information.
4) Build F3::
When using Homebrew, you can just run::
make
When using MacPorts, you will need to pass the location where MacPorts
installed argp-standalone::
make ARGP=/opt/local
Docker
------
Quick Start
~~~~~~~~~~~
A pre-built `image <https://cloud.docker.com/repository/docker/peron/f3>`__
is available over at Docker Hub, ready to be used. With docker started, just
run::
docker run -it --rm --device <device> peron/f3 <f3-command> [<f3-options>] <device>
For example, to probe a drive mounted at /dev/sdX::
docker run -it --rm --device /dev/sdX peron/f3 f3probe --destructive --time-ops /dev/sdX
Optionally, you can also build your own container *if* you don't want to use the
pre-built image. From this directory, run::
make docker
or::
docker build -t f3:latest .
To run f3 commands using your newly built Docker image::
docker run -it --rm --device <device> f3:latest <f3-command> [<f3-options>] <device>
docker run -it --rm --device /dev/sdX f3:latest f3probe --destructive --time-ops /dev/sdX
docker run -it --rm -v /path/to/mounted/device:/mnt/ f3:latest f3write /mnt/
docker run -it --rm -v /path/to/mounted/device:/mnt/ f3:latest f3read /mnt/
Drive Permissions / Passthrough
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Getting the drive device to map into the Docker container is tricky for Mac and
Windows. Passing through devices on Mac and Windows is a well-documented issue
(`[github]
<https://github.com/docker/for-mac/issues/3110#issuecomment-456853036>`__
`[stackexchange]
<https://devops.stackexchange.com/questions/4572/how-to-pass-a-dev-disk-device-on-macos-into-linux-docker/6076#6076>`__
`[tty]
<https://christopherjmcclellan.wordpress.com/2019/04/21/using-usb-with-docker-for-mac/#tldr>`__)
On Linux it should just work, but on Mac or Windows, Docker tends to map the
drive as a normal directory rather than a mounted drive and you will get an
error like :code:`f3probe: Can't open device '/opt/usb': Is a directory`, that
is if you can map it at all.
To solve this, we can use docker-machine to create a VirtualBox VM
(boot2docker), in which to run the Docker container. Since VirtualBox *can*
handle device pass-through, we can pass the device through to the VirtualBox VM
which can then pass the device through to the Docker container. Milad Alizadeh
wrote up some good instructions `here
<https://mil.ad/blog/2018/access-usb-devices-in-container-in-mac.html>`__
which are geared towards USB devices, but it shouldn't be too hard to adapt to
other drive types. Here's what I typed into my Mac terminal (probably
similar for Windows, but untested)::
docker-machine create -d virtualbox default
docker-machine stop
vboxmanage modifyvm default --usb on
docker-machine start
vboxmanage usbfilter add 0 --target default --name flashdrive --vendorid 0x0123 --productid 0x4567
eval $(docker-machine env default)
For the usbfilter add command, note that the "name" argument is the new name
you're giving the filter so you can name it whatever you want.
:code:`--vendorid` and :code:`--productid` can be found on Mac in "System
Information" under "USB". You can also try searching for the right device in
:code:`vboxmanage list usbhost`.
Alternatively, you may opt to add the device through the VirtualBox GUI
application instead::
docker-machine create -d virtualbox default
docker-machine stop
# open VirtualBox and manually add the drive device before proceeding to the next command
docker-machine start
eval $(docker-machine env default)
Once you've run the above commands, unplug and replug the flash drive and run::
docker-machine ssh default "lsblk"
to list the devices. Search for the correct drive - the "SIZE" column may be
helpful in locating the device of interest. For example, :code:`sdb` is a common
mount point for a USB drive. Now you should be able to run the command from
Quick Start::
docker run --rm -it --device /dev/sdX peron/f3 f3probe --destructive --time-ops /dev/sdX
You may find it useful to enter a bash prompt in the Docker container to poke
around the filesystem::
docker run --rm -it --device /dev/sdX peron/f3 bash
so that you can run commands like :code:`ls /dev/*`.
The extra applications for Linux
--------------------------------
Install dependencies
~~~~~~~~~~~~~~~~~~~~
f3probe and f3brew require version 1 of the library libudev, and f3fix
requires version 0 of the library libparted to compile. On Ubuntu, you
can install these libraries with the following command::
sudo apt-get install libudev1 libudev-dev libparted-dev
If you are running a version of Ubuntu before 20.04.1, replace the package `libparted-dev`
on the command line above with `libparted0-dev`.
On Fedora, you can install these libraries with the following command::
sudo dnf install systemd-devel parted-devel
Compile the extra applications
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
make extra
.. note::
- The extra applications are only compiled and tested on Linux
platform.
- Please do not e-mail me saying that you want the extra
applications to run on your platform; I already know that.
Related Skills
node-connect
342.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
85.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
342.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
342.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
