Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Using an advanced filesystem (Linux ext4) for both Teslacam and music files: The Definitive Guide

This site may earn commission on affiliate links.
There are several potential advantages to using ext4, a Linux filesystem, on an SSD connected to your Tesla in the glove box. The Linux-specific filesystem is journaled, which means it has some protection against data corruption from disconnects. I switched to ext4 as my filesystem for the Tesla USB drive more than a year ago and from that point I no longer had data corruption problems. There are currently few resources for using the Linux filesystem ext4 for both TeslaCam and media files on the same drive. Consequently, I’ve created a step-by-step set of instructions to rectify this Internet knowledge gap. Please feel free to offer comments on how this could be improved.

Here are the steps I took to do this with a 500GB Samsung T7 SSD. It works perfectly with dashcam/Sentry clips as well as FLAC music files.


Commands to enter are highlighted in bold.


Connect your SSD to a Linux machine via the USB port. Now find which device this has been assigned to by looking at the recent log entries pertaining to the new USB drive:


[michael@ares ~]$ sudo dmesg -T

[…]

[Sun Jul 23 15:15:28 2023] usb 2-1.2: new high-speed USB device number 5 using ehci-pci
[Sun Jul 23 15:15:28 2023] usb 2-1.2: New USB device found, idVendor=04e8, idProduct=4001, bcdDevice= 1.00
[Sun Jul 23 15:15:28 2023] usb 2-1.2: New USB device strings: Mfr=2, Product=3, SerialNumber=1
[Sun Jul 23 15:15:28 2023] usb 2-1.2: Product: PSSD T7
[Sun Jul 23 15:15:28 2023] usb 2-1.2: Manufacturer: Samsung
[Sun Jul 23 15:15:28 2023] usb 2-1.2: SerialNumber: S5TMNS0T112060J
[Sun Jul 23 15:15:29 2023] scsi host7: uas
[Sun Jul 23 15:15:29 2023] scsi 7:0:0:0: Direct-Access Samsung PSSD T7 0 PQ: 0 ANSI: 6
[Sun Jul 23 15:15:29 2023] sd 7:0:0:0: Attached scsi generic sg10 type 0
[Sun Jul 23 15:15:29 2023] sd 7:0:0:0: [sdj] 976773168 512-byte logical blocks: (500 GB/466 GiB)
[Sun Jul 23 15:15:29 2023] sd 7:0:0:0: [sdj] Write Protect is off
[Sun Jul 23 15:15:29 2023] sd 7:0:0:0: [sdj] Mode Sense: 43 00 00 00
[Sun Jul 23 15:15:29 2023] sd 7:0:0:0: [sdj] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[Sun Jul 23 15:15:29 2023] sd 7:0:0:0: [sdj] Optimal transfer size 33553920 bytes
[Sun Jul 23 15:15:29 2023] sdj: sdj1
[Sun Jul 23 15:15:29 2023] sd 7:0:0:0: [sdj] Attached SCSI disk

[michael@ares ~]$



In this example, the SSD has been assigned /dev/sdj. It is vitally important that you use the correct device for the upcoming commands, as they are destructive to the data on the drive. Don’t just copy the following commands that deal with partitioning and filesystem creation; make sure you appropriate alter the “/dev/sdXX” part to fit your particular situations.

Remove the current partition(s), make a gpt label, and add two new partitions. If there are more than one pre-existing partitions then you will need to execute subsequent commands “rm 2”, “rm 3”, and so forth until all existing partitions are removed.


[michael@ares ~]$ sudo parted /dev/sdj

GNU Parted 3.2
Using /dev/sdj
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Samsung PSSD T7 (scsi)
Disk /dev/sdj: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 1049kB 500GB 500GB primary

(parted) rm 1
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdj will be destroyed and all data on this disk will be
lost. Do you want to continue?
Yes/No? Yes
(parted) mkpart primary 0GB 200GB
(parted) mkpart primary 200GB 100%
(parted) print
Model: Samsung PSSD T7 (scsi)
Disk /dev/sdj: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 33.6MB 200GB 200GB primary
2 200GB 500GB 300GB primary

(parted) quit
Information: You may need to update /etc/fstab.

[michael@ares ~]$


There should now be two new partitions. The first, 200GB, we will use for saving TeslaCam clips. The second (rest of the drive) we will use for media files. Now we need to create filesystems on both of these partitions. Again, replace “sdj” with the appropriate device.

[michael@ares ~]$ sudo mkfs.ext4 /dev/sdj1
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 48823575 4k blocks and 12206080 inodes
Filesystem UUID: 3c4b7ab0-25b1-4d41-bc6e-af1edb8c29ab
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

[michael@ares ~]$ sudo mkfs.ext4 /dev/sdj2
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 73259938 4k blocks and 18317312 inodes
Filesystem UUID: 8e21991f-1e93-478f-905b-01597408046f
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done



OPTIONAL, BUT SOMETIMES HELPFUL: We can create filesystem labels for our partitions:

[michael@ares ~]$ sudo e2label /dev/sdj1 "TESLACAM"
[michael@ares ~]$ sudo e2label /dev/sdj2 "MEDIA"
[michael@ares ~]$

Now create a mount point for both of these partitions:

[michael@ares mnt]$ sudo mkdir /mnt/tesla_SSD
[michael@ares mnt]$ sudo mkdir /mnt/tesla_SSD/teslacam
[michael@ares mnt]$ sudo mkdir /mnt/tesla_SSD/media
[michael@ares mnt]$


Next, mount both partitions:

[michael@ares mnt]$ sudo mount /dev/sdj1 /mnt/tesla_SSD/teslacam
[michael@ares mnt]$ sudo mount /dev/sdj2 /mnt/tesla_SSD/media
[michael@ares mnt]$



You can confirm that both mounted properly:

[michael@ares mnt]$ sudo mount | grep tesla
/dev/sdj1 on /mnt/tesla_SSD/teslacam type ext4 (rw,relatime,stripe=8191)
/dev/sdj2 on /mnt/tesla_SSD/media type ext4 (rw,relatime,stripe=8191)


Now create a directory called “TeslaCam” on the first partition, and assign the proper permissions to allow reading and writing. The user and group ID’s (1984 and 1999, respectively) were ones that I determined empirically by reading the SSD after the car had written to the TeslaCam directory.

[michael@ares mnt]$ sudo mkdir /mnt/tesla_SSD/teslacam/TeslaCam
[michael@ares mnt]$ sudo chmod -R a+rwx /mnt/tesla_SSD/teslacam
[michael@ares mnt]$ sudo chown -R 1984:1999 /mnt/tesla_SSD/teslacam
[michael@ares mnt]$


Next, create a directory on the second partition called “Music” or something to that effect:

[michael@ares mnt]$ sudo mkdir /mnt/tesla_SSD/media/Music
[michael@ares mnt]$


We’ll now copy your media files over to the new Music directory. Replace the source directory with the one appropriate for your situation. (NOTE: Trailing slashes, or lack thereof, are significant with rysnc.)


[michael@ares mnt]$ sudo rsync -avzh /path/to/source/media/top/directory /mnt/tesla_SSD/media/Music/

Now set permissions on the media partition. (I suspect the media partition is only used for reading, so the user and group ID’s might be less important for media, as long as there are universal read privileges.)

[michael@ares mnt]$ sudo chmod -R a+rwx /mnt/tesla_SSD/media
[michael@ares mnt]$ sudo chown -R 1984:1999 /mnt/tesla_SSD/media
[michael@ares mnt]$


Unmount the SSD so you can subsequently disconnect it from your Linux computer:

[michael@ares mnt]$ sudo umount /mnt/tesla_SSD/teslacam
[michael@ares mnt]$ sudo umount /mnt/tesla_SSD/media
[michael@ares mnt]$


Remove the external SSD and connect it to the USB port in the glove box. Touch the Media icon on the car's touchscreen, then at the top left (might be marked as Streaming or something like that) choose USB. You will be able to see the progress for scanning media files on the external drive.

tesla_USB_media_scanning_smaller.png


Your drive should now function as both a dashcam storage and source for media!
 
Thanks for this - I may give it a try. I had nothing but problems trying to get my T7 1TB drive to even work in my Model 3. The interface refuses to format it, just says error occurred. But if I format it manually in Windows it seems to be okay..
 
Thanks for documenting this. I may try this by connecting the drive to my Raspberry Pi, as it run a Linux OS.

Is data corruption from disconnects a problem? Right now my drive is formatted in Windows and I haven't experienced a problem.
When I first got my Model 3, I formatted the drive from the car's menus. (I think exFAT is its default formatting filesystem.) Within a few months I had a couple issues writing to the drive and had to reformat it.

Then I switched to ext4 when I learned I could use that and for well over a year I've never had a single issue.

So at the very least it doesn't hurt anything, and I strongly suspect using ext4 has been the reason for the change in reliability.
 
Does these instructions apply to someone running mac? Don’t have Linux machine handy???
These are Linux-specific instructions, and the ext4 filesystem is a Linux filesystem.

I don't think that a MacOS system can create and write to ext4 filesystems. You can, however, install a Linux system inside a virtual machine.

I use Parallels Desktop on my M1-based Macbook Pro to run a Fedora Linux distribution within the MacOS, and I've managed to configure the Tesla SSD with this method. Just be sure to go to Parallels Desktop --> Preferences --> Devices and configure "when a new external device is detected" to either attach it to the Linux VM or ask what to do. This will give the Linux VM access to the drive when you plug it in.

Alternatively, there are a couple third-party software options for the Mac, like MacFUSE and extFS that might allow you to do this, but I haven't tested any of these options.
 
I've flipflopped around between filesystems over the years trying to figure out the cause of my problems with music playback and occasional glitching with my teslacam recordings. I started having issues sometime in the summer of '21 when my USB music would no longer resume playing where it left off when I got back in the vehicle. It was also at the same time that I started having a errors popping up every time I got in the vehicle saying that there was a problem with the USB drive (these eventually disappeared with a Tesla software update). I figured maybe it was having issues cleanly unmounting the partitions, but never landed on a solution that solved all the issues. I currently have a similar setup but with MBR and exFAT for my music. All this to ask: does music resume properly with the filesystem setup as outlined above?
 
I've flipflopped around between filesystems over the years trying to figure out the cause of my problems with music playback and occasional glitching with my teslacam recordings. I started having issues sometime in the summer of '21 when my USB music would no longer resume playing where it left off when I got back in the vehicle. It was also at the same time that I started having a errors popping up every time I got in the vehicle saying that there was a problem with the USB drive (these eventually disappeared with a Tesla software update). I figured maybe it was having issues cleanly unmounting the partitions, but never landed on a solution that solved all the issues. I currently have a similar setup but with MBR and exFAT for my music. All this to ask: does music resume properly with the filesystem setup as outlined above?
Yes, it does resume playing when you park the car and come back to it after a while.
 
There is a much simple way to get Ext4 by using MiniTool Partition Wizard or something similar (for windows 10 or 11). The caveat is that you will not be able to access the USB (or SSD) via windows unless you install special driver.