sudo mkfs.ext4 -m 0 -T small -i 8192 /dev/sdb
sudo fsck -f /dev/sdb
fsck from util-linux 2.36.1
e2fsck 1.46.2 (28-Feb-2021)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdb: 11/65536000 files (0.0% non-contiguous), 8680071/524288000 blocks
sudo mount /dev/sdb /mnt/disk
tar -xvf archive.tar -C /mnt/disk
train_m/233557/10.jpg
tar: train_m/233557: Cannot mkdir: No space left on device
tar: train_m/233557/10.jpg: Cannot open: No such file or directory
train_m/233557/5.jpg
tar: train_m/233557: Cannot mkdir: No space left on device
tar: train_m/233557/5.jpg: Cannot open: No such file or directory
train_m/233557/0.jpg
tar: train_m/233557: Cannot mkdir: No space left on device
tar: train_m/233557/0.jpg: Cannot open: No such file or directory
train_m/492576/
train_m/492576/1.jpg
train_m/492576/2.jpg
train_m/492576/3.jpg
train_m/492576/0.jpg
As I understand it, this means that some directories couldn't be extracted while others could.
tar: Exiting with failure status due to previous errors
Apparently, a few thousand directories (out of ~600k directories) weren't extracted. How could this have happened?
After extraction, I checked the space:
df -i
Filesystem Inodes IUsed IFree IUse%
/dev/sdb 65536000 8276432 57259568 13%
df -h
Filesystem Size Used Avail Use%
/dev/sdb 492G 97G 396G 20%
P.S. If I format the disk with the default parameters, the archive extracts successfully, but due to the large number of files, I reach the inode limit and cannot add any more data to the disk.
The problem was solved by adding the large_dir option during formatting:
mkfs.ext4 -O large_dir -m 0 -T small -i 8192 /dev/sdb