Two ways to construct a partition full under Linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.