Format USB storage with ext4

USB storages are just one of plain block devices, so they can be formatted with ext4, major filesystem for Linux.

Ext4 USB devices are mostly for Linux specific usage, excluding casual read by Windows, MacOS and so on.

But ext4 can be read by any hosts with compatible ext4 drivers.
You need to introduce some encrypting solution for your strict security purposes.

Identify device

At first, you need to confirm device file path like /dev/sdx.
If your USB is detected automatically, mount command will show one.

$ mount | grep media

In other cases, you may consult recent dmesg log.

Setup partition

Following operations destroy existing data on devices. You need to confirm the exact device path.

Almost all USB storage is formatted with filesystems for Windows.
You need to change filesystem type to Linux one.

$ sudo cfdisk <Device path for USB storage>

cfdisk provides its own terminal user interface, you can select Linux from Type, then Write and Quit.

If you want to have multiple partitions, you can also configure on cfdisk.

Format

mke2fs formats storages with options as follows:

sudo mke2fs [-c] -t ext4 <Device path for the partition>

Device path should be for the partition suffixed with number like /dev/sdx1.
-c is optional for checking bad blocks before format.

⁋ Jul 26, 2023↻ Nov 7, 2024
中馬崇尋
Chuma Takahiro