I use TeslaUSB (via a Raspberry Pi Zero W) to record my Tesla Dashcam footage, and automatically upload it to my NAS when I return home. Recently, however, my pi failed to boot up properly, and my dashcam was unable to record footage.
When I plugged it directly into a monitor at home (it wouldn’t even start enough to SSH into the pi), I was able to see an error on the startup logs complaining about corruption when mounting /backingfiles.
The below is a how-to, for anyone else encountering this issue, to repair the device without resorting to a full reinstall. Please note that whilst this worked for me, I make no guarantees that it will for you. You may need to resort to a full reinstall if it all goes pear shaped.
Sorry, I was exploring and attempting to fix the issue, so no screenshots/photos.
What You’ll Need
- A monitor, and a micro-HDMI cable to connect to your pi
- A Keyboard you can plug in
- An SD Card reader
- A computer
NB: This guide assumes you are using Windows on your computer. Additional steps/different locations may be required if you are using Mac/Linux
Verify the issue
First, plug your pi into your monitor, and power it up. You’ll see a bunch of log entries. If you’re encountering the same issue as I did, you’ll see an error log indicating that there was an error mounting /backingfiles – In my example the error said something about corruption on the mount.
You will also likely see an error at the bottom stating Can Not Open Access to Console the Root Account is Locked. This is because we do not set a password on the root user in linux by default (instead we use the sudo command to elevate permissions).
If you do not see the account locked error, you may be able to bypass the first few steps of the fix.
Initial Setup
The below steps indicate what I did to fix the issue.
- Plug your SD card into your computer
- You should see the drive displayed in File Explorer
- Open the drive, and edit
cmdline.txt - At the very end of the line, add
init=/usr/bin/bash(leaving a space after the existing text, and save the file- Ensure that the full content of the file is on a single line
- Reinsert the SD card into the pi and boot it back up
At this point, you won’t see the error, but the pi will load into a default bash session. Here, we need to set the root password using pwd. It will ask you to set and confirm a password.
Don’t worry about the password being too secure, we’ll remove it as part of our cleanup at the end.
- Plug your SD card back into your computer
- Navigate back to
cmdline.txt - Remove the
init=/usr/bin/bashand save the file - Reinsert back into the pi and boot it again
At this point, you’ll encounter the error again, but now you’ll have a working root session.
Fixing the Issue
From here, we can actually investigate the issue, and make attempts to resolve it.
Start by entering systemctl status backingfiles.mount – You should see an error in here relating to the issue we saw in the startup logs. Make a note of the What section of the output.
Back at the command prompt, type in xfs_repair -v -L [path] – substituting [path] with the path specified in the What section beforehand.
This will take a few minutes to complete, just let it do its thing.
Once it is complete, you can restart the pi (I had to pull the plug, as the regular shutdown command didn’t seem to work). You should now see the TeslaUSB load properly, and drop you into a login prompt. If you do, the issue should be fixed!
Cleanup
Now we have it working, we need to clean up that root password. Log into the pi using your teslausb login credentials.
- Type in
sudo -iand press enter - Type in
bin/remountfs_rwand press enter – this allows us to make changes as necessary - Type in
passwd -dl rootand press enter
This will remove the root password we added earlier, and return it back to the intended state.
Conclusion
And that’s it! We now have a working TeslaUSB drive again, and can plug it back into the car.