We all know that Linux provides special device/dev/full to test disk full, however it is only valid for files. For programs that use fixed file names or predictable filenames, the general/dev/full can be met. For programs that have a file name generated in an unpredictable way, you also need to construct a fully-written partition. One obvious way to do this is to create a real partition and then fill it up, but it's a bit cumbersome to operate. This article provides two other relatively simple ways.
Using Memory disks
The rationale is to mount the memory as a disk and then use DD to write full. Linux supports two types of memory disks, Ramfs and TMPFS. Ramfs must use physical memory, cannot take advantage of swap partitions, and will gradually grow on writing until all memory is exhausted, that is, the partition size cannot be set, so it is not suitable for scenarios where the partition is full. TMPFS can use physical memory and swap partitions, and it supports setting the partition size. Therefore, we use TMPFS to construct a partition full.
mkdir -p /mnt/ramdiskmount -t tmpfs -o size=1m tmpfs /mnt/ramdiskdd if=/dev/zero of=/mnt/ramdisk/test size=1m count=1
Using the Loop device
The basic principle is to create a 1M size file, create a EXT2 partition on it, mount it as a partition in loop, and then write full with DD.
dd if=/dev/zero of=a.img bs=1M count=1mkdir -p /mnt/loopmkfs.ext2 a.imgmount -t ext2 -o loop a.img /mnt/loopdd if=/dev/zero of=/mnt/loop/file bs=1M count=1
Two ways to construct a partition full under Linux