Way to instantly fill up/use up lots of disk space?
Clash Royale CLAN TAG#URR8PPP
up vote
38
down vote
favorite
On a Linux VM I would like to TEST the NAGIOS monitoring more deeply than just switching off the VM or disconnecting the virtual NIC; I would like to test or "enforce a disk space alarm" through occupying several % of free space for a short period of time.
I know that I could just use a
dd if=/dev/zero of=/tmp/hd-fillup.zeros bs=1G count=50
or something like that... but this takes time and loads the system and requires again time when removing the test files with rm.
Is there a quick (almost instant) way to fill up a partition that does not load down the system and takes a lot of time ? im thinking about something that allocates space, but does not "fill" it.
linux filesystems hard-disk disk-usage
 |Â
show 2 more comments
up vote
38
down vote
favorite
On a Linux VM I would like to TEST the NAGIOS monitoring more deeply than just switching off the VM or disconnecting the virtual NIC; I would like to test or "enforce a disk space alarm" through occupying several % of free space for a short period of time.
I know that I could just use a
dd if=/dev/zero of=/tmp/hd-fillup.zeros bs=1G count=50
or something like that... but this takes time and loads the system and requires again time when removing the test files with rm.
Is there a quick (almost instant) way to fill up a partition that does not load down the system and takes a lot of time ? im thinking about something that allocates space, but does not "fill" it.
linux filesystems hard-disk disk-usage
sorry, forgot to mention that its a >> ext3 filesystem.
â Axel Werner
Jun 29 '16 at 12:17
You need to upgrade it to ext4 to support fallocate.
â Rui F Ribeiro
Jun 29 '16 at 12:22
1
Zip bomb always works
â galois
Jun 29 '16 at 18:53
1
@jaska Make it an answer. It was the very first idea I got when reading the title...
â Crowley
Jun 30 '16 at 9:35
Why don't you use/dev/full
? (Assuming it exists). Tryecho 'test' > /dev/full
on Debian.
â Ismael Miguel
Jun 30 '16 at 15:53
 |Â
show 2 more comments
up vote
38
down vote
favorite
up vote
38
down vote
favorite
On a Linux VM I would like to TEST the NAGIOS monitoring more deeply than just switching off the VM or disconnecting the virtual NIC; I would like to test or "enforce a disk space alarm" through occupying several % of free space for a short period of time.
I know that I could just use a
dd if=/dev/zero of=/tmp/hd-fillup.zeros bs=1G count=50
or something like that... but this takes time and loads the system and requires again time when removing the test files with rm.
Is there a quick (almost instant) way to fill up a partition that does not load down the system and takes a lot of time ? im thinking about something that allocates space, but does not "fill" it.
linux filesystems hard-disk disk-usage
On a Linux VM I would like to TEST the NAGIOS monitoring more deeply than just switching off the VM or disconnecting the virtual NIC; I would like to test or "enforce a disk space alarm" through occupying several % of free space for a short period of time.
I know that I could just use a
dd if=/dev/zero of=/tmp/hd-fillup.zeros bs=1G count=50
or something like that... but this takes time and loads the system and requires again time when removing the test files with rm.
Is there a quick (almost instant) way to fill up a partition that does not load down the system and takes a lot of time ? im thinking about something that allocates space, but does not "fill" it.
linux filesystems hard-disk disk-usage
linux filesystems hard-disk disk-usage
edited Feb 11 at 21:42
Rui F Ribeiro
37.9k1475122
37.9k1475122
asked Jun 29 '16 at 12:04
Axel Werner
3631314
3631314
sorry, forgot to mention that its a >> ext3 filesystem.
â Axel Werner
Jun 29 '16 at 12:17
You need to upgrade it to ext4 to support fallocate.
â Rui F Ribeiro
Jun 29 '16 at 12:22
1
Zip bomb always works
â galois
Jun 29 '16 at 18:53
1
@jaska Make it an answer. It was the very first idea I got when reading the title...
â Crowley
Jun 30 '16 at 9:35
Why don't you use/dev/full
? (Assuming it exists). Tryecho 'test' > /dev/full
on Debian.
â Ismael Miguel
Jun 30 '16 at 15:53
 |Â
show 2 more comments
sorry, forgot to mention that its a >> ext3 filesystem.
â Axel Werner
Jun 29 '16 at 12:17
You need to upgrade it to ext4 to support fallocate.
â Rui F Ribeiro
Jun 29 '16 at 12:22
1
Zip bomb always works
â galois
Jun 29 '16 at 18:53
1
@jaska Make it an answer. It was the very first idea I got when reading the title...
â Crowley
Jun 30 '16 at 9:35
Why don't you use/dev/full
? (Assuming it exists). Tryecho 'test' > /dev/full
on Debian.
â Ismael Miguel
Jun 30 '16 at 15:53
sorry, forgot to mention that its a >> ext3 filesystem.
â Axel Werner
Jun 29 '16 at 12:17
sorry, forgot to mention that its a >> ext3 filesystem.
â Axel Werner
Jun 29 '16 at 12:17
You need to upgrade it to ext4 to support fallocate.
â Rui F Ribeiro
Jun 29 '16 at 12:22
You need to upgrade it to ext4 to support fallocate.
â Rui F Ribeiro
Jun 29 '16 at 12:22
1
1
Zip bomb always works
â galois
Jun 29 '16 at 18:53
Zip bomb always works
â galois
Jun 29 '16 at 18:53
1
1
@jaska Make it an answer. It was the very first idea I got when reading the title...
â Crowley
Jun 30 '16 at 9:35
@jaska Make it an answer. It was the very first idea I got when reading the title...
â Crowley
Jun 30 '16 at 9:35
Why don't you use
/dev/full
? (Assuming it exists). Try echo 'test' > /dev/full
on Debian.â Ismael Miguel
Jun 30 '16 at 15:53
Why don't you use
/dev/full
? (Assuming it exists). Try echo 'test' > /dev/full
on Debian.â Ismael Miguel
Jun 30 '16 at 15:53
 |Â
show 2 more comments
4 Answers
4
active
oldest
votes
up vote
54
down vote
accepted
The fastest way to create a file in a Linux system is using fallocate
:
fallocate -l 50G file
From man:
fallocate is used to manipulate the allocated disk space for a
file,
either to deallocate or preallocate it.
For filesystems which support
the fallocate system call, preallocation is done quickly by allocating
blocks and marking them as uninitialized, requiring no IO to the data
blocks. This is much faster than creating a file by filling it with
zeros.
Supported for XFS (since Linux 2.6.38), ext4 (since Linux 3.0),
Btrfs (since Linux 3.7) and tmpfs (since Linux 3.5).
1
Why are you running it throughsudo
?
â gerrit
Jun 29 '16 at 23:31
1
@gerrit Added that point to the answer.
â Rui F Ribeiro
Jun 30 '16 at 6:53
3
"fallocate
needs root privileges" Not on my system (Linux Mint 17.3, downstream of Ubuntu, thus Debian). (ext4 file system)
â T.J. Crowder
Jun 30 '16 at 7:48
1
+1 although the OP explicitly mentioned that his filesystem is ext3.
â syneticon-dj
Jun 30 '16 at 7:59
1
@RuiFRibeiro, thanks! for sles11sp4 ive been able to create a file, format it with ext4, but where unable to mount it in RW mode. later i found a kernel message in /var/log/messages that said, ext4 is supported only as read-only. :/
â Axel Werner
Jul 1 '16 at 11:40
 |Â
show 8 more comments
up vote
13
down vote
Other alternatives include:
- to change the alarm thresholds to something near or below the current usage, or
- to create a very small test partition with limited inodes, size, or other attributes.
Being able to test things such as running into the root reserved percentage, if any, may also be handy.
root reserved percentage normally is 10% unless you tweak it - it ends up a too big waste of system in big partitions/modern disks. When defining alarms, you´d better already take it in account.
â Rui F Ribeiro
Jun 29 '16 at 16:59
+1 for the first thing. a hundred times true. why the hell should I actually create something on a machine disk? what if something (like coredump, batch job generating big temporary files, ...) happens at the time of my testing and whole disk gets accidentally eaten up?
â Fiisch
Jun 29 '16 at 18:30
1
@Fisch - Why? To make sure your alerting threshold is correct and that you're not doing something like accidentally setting the inode free percentage instead of the disk space free percentage (which I've seen done before). If something fails because you filled up a disk to the alerting threshold, then your alerting threshold is too low - the whole point of alerting is that it's supposed to alert you before things start to break.
â Johnny
Jun 29 '16 at 20:06
Cat, good point. But no solution for me. I dont have controll over the VM configuration (cant alter partitions or virtual disks), nor have controll over the NAGIOS Server.
â Axel Werner
Jun 30 '16 at 6:37
2
@AxelWerner Can you loopback-mount a file as "fake" partitiion? That still would allow you to test without seriously affecting anything. Format it with one of the supported filesystems and and you can play around with fallocate too.
â Tonny
Jun 30 '16 at 14:09
 |Â
show 5 more comments
up vote
9
down vote
fallocate -l 50G big_file
truncate -s 50G big_file
dd of=bigfile bs=1 seek=50G count=0
As those three ways can all fill up a partition quickly.
If you like use dd, usually you can try it with seek. Just set seek=file_size_what_you_need
and set count=0
. That will tell the system there is a file, and its size is what you set, but the system will not create it actually. And used this way, you can create a file which is bigger than the partition size.
Example, on an ext4 partition with less than 3G available. Use dd to create a 5T file which exists as metadata -- requiring virtually no block space.
df -h . ; dd of=biggerfile bs=1 seek=5000G count=0 ; ls -log biggerfile ; df -h .
Output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 42G 37G 2.8G 94% /home
0+0 records in
0+0 records out
0 bytes copied, 4.9296e-05 s, 0.0 kB/s
-rw-rw-r-- 1 5368709120000 Jun 29 13:13 biggerfile
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 42G 37G 2.8G 94% /home
1
can you add some more information to your answer?
â cat
Jun 29 '16 at 15:18
I just add more thinking in a finished question for people which search the same question other way. ignore it what if you are not.
â Se ven
Jun 29 '16 at 15:50
Thiscount=0
method is quite interesting, I've added an example.
â agc
Jun 29 '16 at 16:47
6
Note that thedd
example above may well allocate a sparse file. In that case the file size is 50G, it's actually only using a block (or not even) and so the disk is not getting full. YMMV.
â MAP
Jun 29 '16 at 19:49
2
I tested your suggestion on my ext3 filesystem. it did not work as expected. truncate and dd did create a file with a large file size, but "df -h" did not recognize it. still shows the same free hd space.
â Axel Werner
Jun 30 '16 at 6:53
 |Â
show 2 more comments
up vote
0
down vote
You could also take advantage of the stress-ng tool that is supported on a wide number of Linux-based systems:
stress-ng --fallocate 4 --fallocate-bytes 70% --timeout 1m --metrics --verify --times
New contributor
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
54
down vote
accepted
The fastest way to create a file in a Linux system is using fallocate
:
fallocate -l 50G file
From man:
fallocate is used to manipulate the allocated disk space for a
file,
either to deallocate or preallocate it.
For filesystems which support
the fallocate system call, preallocation is done quickly by allocating
blocks and marking them as uninitialized, requiring no IO to the data
blocks. This is much faster than creating a file by filling it with
zeros.
Supported for XFS (since Linux 2.6.38), ext4 (since Linux 3.0),
Btrfs (since Linux 3.7) and tmpfs (since Linux 3.5).
1
Why are you running it throughsudo
?
â gerrit
Jun 29 '16 at 23:31
1
@gerrit Added that point to the answer.
â Rui F Ribeiro
Jun 30 '16 at 6:53
3
"fallocate
needs root privileges" Not on my system (Linux Mint 17.3, downstream of Ubuntu, thus Debian). (ext4 file system)
â T.J. Crowder
Jun 30 '16 at 7:48
1
+1 although the OP explicitly mentioned that his filesystem is ext3.
â syneticon-dj
Jun 30 '16 at 7:59
1
@RuiFRibeiro, thanks! for sles11sp4 ive been able to create a file, format it with ext4, but where unable to mount it in RW mode. later i found a kernel message in /var/log/messages that said, ext4 is supported only as read-only. :/
â Axel Werner
Jul 1 '16 at 11:40
 |Â
show 8 more comments
up vote
54
down vote
accepted
The fastest way to create a file in a Linux system is using fallocate
:
fallocate -l 50G file
From man:
fallocate is used to manipulate the allocated disk space for a
file,
either to deallocate or preallocate it.
For filesystems which support
the fallocate system call, preallocation is done quickly by allocating
blocks and marking them as uninitialized, requiring no IO to the data
blocks. This is much faster than creating a file by filling it with
zeros.
Supported for XFS (since Linux 2.6.38), ext4 (since Linux 3.0),
Btrfs (since Linux 3.7) and tmpfs (since Linux 3.5).
1
Why are you running it throughsudo
?
â gerrit
Jun 29 '16 at 23:31
1
@gerrit Added that point to the answer.
â Rui F Ribeiro
Jun 30 '16 at 6:53
3
"fallocate
needs root privileges" Not on my system (Linux Mint 17.3, downstream of Ubuntu, thus Debian). (ext4 file system)
â T.J. Crowder
Jun 30 '16 at 7:48
1
+1 although the OP explicitly mentioned that his filesystem is ext3.
â syneticon-dj
Jun 30 '16 at 7:59
1
@RuiFRibeiro, thanks! for sles11sp4 ive been able to create a file, format it with ext4, but where unable to mount it in RW mode. later i found a kernel message in /var/log/messages that said, ext4 is supported only as read-only. :/
â Axel Werner
Jul 1 '16 at 11:40
 |Â
show 8 more comments
up vote
54
down vote
accepted
up vote
54
down vote
accepted
The fastest way to create a file in a Linux system is using fallocate
:
fallocate -l 50G file
From man:
fallocate is used to manipulate the allocated disk space for a
file,
either to deallocate or preallocate it.
For filesystems which support
the fallocate system call, preallocation is done quickly by allocating
blocks and marking them as uninitialized, requiring no IO to the data
blocks. This is much faster than creating a file by filling it with
zeros.
Supported for XFS (since Linux 2.6.38), ext4 (since Linux 3.0),
Btrfs (since Linux 3.7) and tmpfs (since Linux 3.5).
The fastest way to create a file in a Linux system is using fallocate
:
fallocate -l 50G file
From man:
fallocate is used to manipulate the allocated disk space for a
file,
either to deallocate or preallocate it.
For filesystems which support
the fallocate system call, preallocation is done quickly by allocating
blocks and marking them as uninitialized, requiring no IO to the data
blocks. This is much faster than creating a file by filling it with
zeros.
Supported for XFS (since Linux 2.6.38), ext4 (since Linux 3.0),
Btrfs (since Linux 3.7) and tmpfs (since Linux 3.5).
edited Feb 3 at 1:15
answered Jun 29 '16 at 12:17
Rui F Ribeiro
37.9k1475122
37.9k1475122
1
Why are you running it throughsudo
?
â gerrit
Jun 29 '16 at 23:31
1
@gerrit Added that point to the answer.
â Rui F Ribeiro
Jun 30 '16 at 6:53
3
"fallocate
needs root privileges" Not on my system (Linux Mint 17.3, downstream of Ubuntu, thus Debian). (ext4 file system)
â T.J. Crowder
Jun 30 '16 at 7:48
1
+1 although the OP explicitly mentioned that his filesystem is ext3.
â syneticon-dj
Jun 30 '16 at 7:59
1
@RuiFRibeiro, thanks! for sles11sp4 ive been able to create a file, format it with ext4, but where unable to mount it in RW mode. later i found a kernel message in /var/log/messages that said, ext4 is supported only as read-only. :/
â Axel Werner
Jul 1 '16 at 11:40
 |Â
show 8 more comments
1
Why are you running it throughsudo
?
â gerrit
Jun 29 '16 at 23:31
1
@gerrit Added that point to the answer.
â Rui F Ribeiro
Jun 30 '16 at 6:53
3
"fallocate
needs root privileges" Not on my system (Linux Mint 17.3, downstream of Ubuntu, thus Debian). (ext4 file system)
â T.J. Crowder
Jun 30 '16 at 7:48
1
+1 although the OP explicitly mentioned that his filesystem is ext3.
â syneticon-dj
Jun 30 '16 at 7:59
1
@RuiFRibeiro, thanks! for sles11sp4 ive been able to create a file, format it with ext4, but where unable to mount it in RW mode. later i found a kernel message in /var/log/messages that said, ext4 is supported only as read-only. :/
â Axel Werner
Jul 1 '16 at 11:40
1
1
Why are you running it through
sudo
?â gerrit
Jun 29 '16 at 23:31
Why are you running it through
sudo
?â gerrit
Jun 29 '16 at 23:31
1
1
@gerrit Added that point to the answer.
â Rui F Ribeiro
Jun 30 '16 at 6:53
@gerrit Added that point to the answer.
â Rui F Ribeiro
Jun 30 '16 at 6:53
3
3
"
fallocate
needs root privileges" Not on my system (Linux Mint 17.3, downstream of Ubuntu, thus Debian). (ext4 file system)â T.J. Crowder
Jun 30 '16 at 7:48
"
fallocate
needs root privileges" Not on my system (Linux Mint 17.3, downstream of Ubuntu, thus Debian). (ext4 file system)â T.J. Crowder
Jun 30 '16 at 7:48
1
1
+1 although the OP explicitly mentioned that his filesystem is ext3.
â syneticon-dj
Jun 30 '16 at 7:59
+1 although the OP explicitly mentioned that his filesystem is ext3.
â syneticon-dj
Jun 30 '16 at 7:59
1
1
@RuiFRibeiro, thanks! for sles11sp4 ive been able to create a file, format it with ext4, but where unable to mount it in RW mode. later i found a kernel message in /var/log/messages that said, ext4 is supported only as read-only. :/
â Axel Werner
Jul 1 '16 at 11:40
@RuiFRibeiro, thanks! for sles11sp4 ive been able to create a file, format it with ext4, but where unable to mount it in RW mode. later i found a kernel message in /var/log/messages that said, ext4 is supported only as read-only. :/
â Axel Werner
Jul 1 '16 at 11:40
 |Â
show 8 more comments
up vote
13
down vote
Other alternatives include:
- to change the alarm thresholds to something near or below the current usage, or
- to create a very small test partition with limited inodes, size, or other attributes.
Being able to test things such as running into the root reserved percentage, if any, may also be handy.
root reserved percentage normally is 10% unless you tweak it - it ends up a too big waste of system in big partitions/modern disks. When defining alarms, you´d better already take it in account.
â Rui F Ribeiro
Jun 29 '16 at 16:59
+1 for the first thing. a hundred times true. why the hell should I actually create something on a machine disk? what if something (like coredump, batch job generating big temporary files, ...) happens at the time of my testing and whole disk gets accidentally eaten up?
â Fiisch
Jun 29 '16 at 18:30
1
@Fisch - Why? To make sure your alerting threshold is correct and that you're not doing something like accidentally setting the inode free percentage instead of the disk space free percentage (which I've seen done before). If something fails because you filled up a disk to the alerting threshold, then your alerting threshold is too low - the whole point of alerting is that it's supposed to alert you before things start to break.
â Johnny
Jun 29 '16 at 20:06
Cat, good point. But no solution for me. I dont have controll over the VM configuration (cant alter partitions or virtual disks), nor have controll over the NAGIOS Server.
â Axel Werner
Jun 30 '16 at 6:37
2
@AxelWerner Can you loopback-mount a file as "fake" partitiion? That still would allow you to test without seriously affecting anything. Format it with one of the supported filesystems and and you can play around with fallocate too.
â Tonny
Jun 30 '16 at 14:09
 |Â
show 5 more comments
up vote
13
down vote
Other alternatives include:
- to change the alarm thresholds to something near or below the current usage, or
- to create a very small test partition with limited inodes, size, or other attributes.
Being able to test things such as running into the root reserved percentage, if any, may also be handy.
root reserved percentage normally is 10% unless you tweak it - it ends up a too big waste of system in big partitions/modern disks. When defining alarms, you´d better already take it in account.
â Rui F Ribeiro
Jun 29 '16 at 16:59
+1 for the first thing. a hundred times true. why the hell should I actually create something on a machine disk? what if something (like coredump, batch job generating big temporary files, ...) happens at the time of my testing and whole disk gets accidentally eaten up?
â Fiisch
Jun 29 '16 at 18:30
1
@Fisch - Why? To make sure your alerting threshold is correct and that you're not doing something like accidentally setting the inode free percentage instead of the disk space free percentage (which I've seen done before). If something fails because you filled up a disk to the alerting threshold, then your alerting threshold is too low - the whole point of alerting is that it's supposed to alert you before things start to break.
â Johnny
Jun 29 '16 at 20:06
Cat, good point. But no solution for me. I dont have controll over the VM configuration (cant alter partitions or virtual disks), nor have controll over the NAGIOS Server.
â Axel Werner
Jun 30 '16 at 6:37
2
@AxelWerner Can you loopback-mount a file as "fake" partitiion? That still would allow you to test without seriously affecting anything. Format it with one of the supported filesystems and and you can play around with fallocate too.
â Tonny
Jun 30 '16 at 14:09
 |Â
show 5 more comments
up vote
13
down vote
up vote
13
down vote
Other alternatives include:
- to change the alarm thresholds to something near or below the current usage, or
- to create a very small test partition with limited inodes, size, or other attributes.
Being able to test things such as running into the root reserved percentage, if any, may also be handy.
Other alternatives include:
- to change the alarm thresholds to something near or below the current usage, or
- to create a very small test partition with limited inodes, size, or other attributes.
Being able to test things such as running into the root reserved percentage, if any, may also be handy.
edited Jun 29 '16 at 15:46
cat
1,67621135
1,67621135
answered Jun 29 '16 at 14:05
thrig
23.2k12854
23.2k12854
root reserved percentage normally is 10% unless you tweak it - it ends up a too big waste of system in big partitions/modern disks. When defining alarms, you´d better already take it in account.
â Rui F Ribeiro
Jun 29 '16 at 16:59
+1 for the first thing. a hundred times true. why the hell should I actually create something on a machine disk? what if something (like coredump, batch job generating big temporary files, ...) happens at the time of my testing and whole disk gets accidentally eaten up?
â Fiisch
Jun 29 '16 at 18:30
1
@Fisch - Why? To make sure your alerting threshold is correct and that you're not doing something like accidentally setting the inode free percentage instead of the disk space free percentage (which I've seen done before). If something fails because you filled up a disk to the alerting threshold, then your alerting threshold is too low - the whole point of alerting is that it's supposed to alert you before things start to break.
â Johnny
Jun 29 '16 at 20:06
Cat, good point. But no solution for me. I dont have controll over the VM configuration (cant alter partitions or virtual disks), nor have controll over the NAGIOS Server.
â Axel Werner
Jun 30 '16 at 6:37
2
@AxelWerner Can you loopback-mount a file as "fake" partitiion? That still would allow you to test without seriously affecting anything. Format it with one of the supported filesystems and and you can play around with fallocate too.
â Tonny
Jun 30 '16 at 14:09
 |Â
show 5 more comments
root reserved percentage normally is 10% unless you tweak it - it ends up a too big waste of system in big partitions/modern disks. When defining alarms, you´d better already take it in account.
â Rui F Ribeiro
Jun 29 '16 at 16:59
+1 for the first thing. a hundred times true. why the hell should I actually create something on a machine disk? what if something (like coredump, batch job generating big temporary files, ...) happens at the time of my testing and whole disk gets accidentally eaten up?
â Fiisch
Jun 29 '16 at 18:30
1
@Fisch - Why? To make sure your alerting threshold is correct and that you're not doing something like accidentally setting the inode free percentage instead of the disk space free percentage (which I've seen done before). If something fails because you filled up a disk to the alerting threshold, then your alerting threshold is too low - the whole point of alerting is that it's supposed to alert you before things start to break.
â Johnny
Jun 29 '16 at 20:06
Cat, good point. But no solution for me. I dont have controll over the VM configuration (cant alter partitions or virtual disks), nor have controll over the NAGIOS Server.
â Axel Werner
Jun 30 '16 at 6:37
2
@AxelWerner Can you loopback-mount a file as "fake" partitiion? That still would allow you to test without seriously affecting anything. Format it with one of the supported filesystems and and you can play around with fallocate too.
â Tonny
Jun 30 '16 at 14:09
root reserved percentage normally is 10% unless you tweak it - it ends up a too big waste of system in big partitions/modern disks. When defining alarms, you´d better already take it in account.
â Rui F Ribeiro
Jun 29 '16 at 16:59
root reserved percentage normally is 10% unless you tweak it - it ends up a too big waste of system in big partitions/modern disks. When defining alarms, you´d better already take it in account.
â Rui F Ribeiro
Jun 29 '16 at 16:59
+1 for the first thing. a hundred times true. why the hell should I actually create something on a machine disk? what if something (like coredump, batch job generating big temporary files, ...) happens at the time of my testing and whole disk gets accidentally eaten up?
â Fiisch
Jun 29 '16 at 18:30
+1 for the first thing. a hundred times true. why the hell should I actually create something on a machine disk? what if something (like coredump, batch job generating big temporary files, ...) happens at the time of my testing and whole disk gets accidentally eaten up?
â Fiisch
Jun 29 '16 at 18:30
1
1
@Fisch - Why? To make sure your alerting threshold is correct and that you're not doing something like accidentally setting the inode free percentage instead of the disk space free percentage (which I've seen done before). If something fails because you filled up a disk to the alerting threshold, then your alerting threshold is too low - the whole point of alerting is that it's supposed to alert you before things start to break.
â Johnny
Jun 29 '16 at 20:06
@Fisch - Why? To make sure your alerting threshold is correct and that you're not doing something like accidentally setting the inode free percentage instead of the disk space free percentage (which I've seen done before). If something fails because you filled up a disk to the alerting threshold, then your alerting threshold is too low - the whole point of alerting is that it's supposed to alert you before things start to break.
â Johnny
Jun 29 '16 at 20:06
Cat, good point. But no solution for me. I dont have controll over the VM configuration (cant alter partitions or virtual disks), nor have controll over the NAGIOS Server.
â Axel Werner
Jun 30 '16 at 6:37
Cat, good point. But no solution for me. I dont have controll over the VM configuration (cant alter partitions or virtual disks), nor have controll over the NAGIOS Server.
â Axel Werner
Jun 30 '16 at 6:37
2
2
@AxelWerner Can you loopback-mount a file as "fake" partitiion? That still would allow you to test without seriously affecting anything. Format it with one of the supported filesystems and and you can play around with fallocate too.
â Tonny
Jun 30 '16 at 14:09
@AxelWerner Can you loopback-mount a file as "fake" partitiion? That still would allow you to test without seriously affecting anything. Format it with one of the supported filesystems and and you can play around with fallocate too.
â Tonny
Jun 30 '16 at 14:09
 |Â
show 5 more comments
up vote
9
down vote
fallocate -l 50G big_file
truncate -s 50G big_file
dd of=bigfile bs=1 seek=50G count=0
As those three ways can all fill up a partition quickly.
If you like use dd, usually you can try it with seek. Just set seek=file_size_what_you_need
and set count=0
. That will tell the system there is a file, and its size is what you set, but the system will not create it actually. And used this way, you can create a file which is bigger than the partition size.
Example, on an ext4 partition with less than 3G available. Use dd to create a 5T file which exists as metadata -- requiring virtually no block space.
df -h . ; dd of=biggerfile bs=1 seek=5000G count=0 ; ls -log biggerfile ; df -h .
Output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 42G 37G 2.8G 94% /home
0+0 records in
0+0 records out
0 bytes copied, 4.9296e-05 s, 0.0 kB/s
-rw-rw-r-- 1 5368709120000 Jun 29 13:13 biggerfile
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 42G 37G 2.8G 94% /home
1
can you add some more information to your answer?
â cat
Jun 29 '16 at 15:18
I just add more thinking in a finished question for people which search the same question other way. ignore it what if you are not.
â Se ven
Jun 29 '16 at 15:50
Thiscount=0
method is quite interesting, I've added an example.
â agc
Jun 29 '16 at 16:47
6
Note that thedd
example above may well allocate a sparse file. In that case the file size is 50G, it's actually only using a block (or not even) and so the disk is not getting full. YMMV.
â MAP
Jun 29 '16 at 19:49
2
I tested your suggestion on my ext3 filesystem. it did not work as expected. truncate and dd did create a file with a large file size, but "df -h" did not recognize it. still shows the same free hd space.
â Axel Werner
Jun 30 '16 at 6:53
 |Â
show 2 more comments
up vote
9
down vote
fallocate -l 50G big_file
truncate -s 50G big_file
dd of=bigfile bs=1 seek=50G count=0
As those three ways can all fill up a partition quickly.
If you like use dd, usually you can try it with seek. Just set seek=file_size_what_you_need
and set count=0
. That will tell the system there is a file, and its size is what you set, but the system will not create it actually. And used this way, you can create a file which is bigger than the partition size.
Example, on an ext4 partition with less than 3G available. Use dd to create a 5T file which exists as metadata -- requiring virtually no block space.
df -h . ; dd of=biggerfile bs=1 seek=5000G count=0 ; ls -log biggerfile ; df -h .
Output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 42G 37G 2.8G 94% /home
0+0 records in
0+0 records out
0 bytes copied, 4.9296e-05 s, 0.0 kB/s
-rw-rw-r-- 1 5368709120000 Jun 29 13:13 biggerfile
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 42G 37G 2.8G 94% /home
1
can you add some more information to your answer?
â cat
Jun 29 '16 at 15:18
I just add more thinking in a finished question for people which search the same question other way. ignore it what if you are not.
â Se ven
Jun 29 '16 at 15:50
Thiscount=0
method is quite interesting, I've added an example.
â agc
Jun 29 '16 at 16:47
6
Note that thedd
example above may well allocate a sparse file. In that case the file size is 50G, it's actually only using a block (or not even) and so the disk is not getting full. YMMV.
â MAP
Jun 29 '16 at 19:49
2
I tested your suggestion on my ext3 filesystem. it did not work as expected. truncate and dd did create a file with a large file size, but "df -h" did not recognize it. still shows the same free hd space.
â Axel Werner
Jun 30 '16 at 6:53
 |Â
show 2 more comments
up vote
9
down vote
up vote
9
down vote
fallocate -l 50G big_file
truncate -s 50G big_file
dd of=bigfile bs=1 seek=50G count=0
As those three ways can all fill up a partition quickly.
If you like use dd, usually you can try it with seek. Just set seek=file_size_what_you_need
and set count=0
. That will tell the system there is a file, and its size is what you set, but the system will not create it actually. And used this way, you can create a file which is bigger than the partition size.
Example, on an ext4 partition with less than 3G available. Use dd to create a 5T file which exists as metadata -- requiring virtually no block space.
df -h . ; dd of=biggerfile bs=1 seek=5000G count=0 ; ls -log biggerfile ; df -h .
Output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 42G 37G 2.8G 94% /home
0+0 records in
0+0 records out
0 bytes copied, 4.9296e-05 s, 0.0 kB/s
-rw-rw-r-- 1 5368709120000 Jun 29 13:13 biggerfile
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 42G 37G 2.8G 94% /home
fallocate -l 50G big_file
truncate -s 50G big_file
dd of=bigfile bs=1 seek=50G count=0
As those three ways can all fill up a partition quickly.
If you like use dd, usually you can try it with seek. Just set seek=file_size_what_you_need
and set count=0
. That will tell the system there is a file, and its size is what you set, but the system will not create it actually. And used this way, you can create a file which is bigger than the partition size.
Example, on an ext4 partition with less than 3G available. Use dd to create a 5T file which exists as metadata -- requiring virtually no block space.
df -h . ; dd of=biggerfile bs=1 seek=5000G count=0 ; ls -log biggerfile ; df -h .
Output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 42G 37G 2.8G 94% /home
0+0 records in
0+0 records out
0 bytes copied, 4.9296e-05 s, 0.0 kB/s
-rw-rw-r-- 1 5368709120000 Jun 29 13:13 biggerfile
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 42G 37G 2.8G 94% /home
edited Jun 29 '16 at 21:36
agc
4,3631935
4,3631935
answered Jun 29 '16 at 14:33
Se ven
1349
1349
1
can you add some more information to your answer?
â cat
Jun 29 '16 at 15:18
I just add more thinking in a finished question for people which search the same question other way. ignore it what if you are not.
â Se ven
Jun 29 '16 at 15:50
Thiscount=0
method is quite interesting, I've added an example.
â agc
Jun 29 '16 at 16:47
6
Note that thedd
example above may well allocate a sparse file. In that case the file size is 50G, it's actually only using a block (or not even) and so the disk is not getting full. YMMV.
â MAP
Jun 29 '16 at 19:49
2
I tested your suggestion on my ext3 filesystem. it did not work as expected. truncate and dd did create a file with a large file size, but "df -h" did not recognize it. still shows the same free hd space.
â Axel Werner
Jun 30 '16 at 6:53
 |Â
show 2 more comments
1
can you add some more information to your answer?
â cat
Jun 29 '16 at 15:18
I just add more thinking in a finished question for people which search the same question other way. ignore it what if you are not.
â Se ven
Jun 29 '16 at 15:50
Thiscount=0
method is quite interesting, I've added an example.
â agc
Jun 29 '16 at 16:47
6
Note that thedd
example above may well allocate a sparse file. In that case the file size is 50G, it's actually only using a block (or not even) and so the disk is not getting full. YMMV.
â MAP
Jun 29 '16 at 19:49
2
I tested your suggestion on my ext3 filesystem. it did not work as expected. truncate and dd did create a file with a large file size, but "df -h" did not recognize it. still shows the same free hd space.
â Axel Werner
Jun 30 '16 at 6:53
1
1
can you add some more information to your answer?
â cat
Jun 29 '16 at 15:18
can you add some more information to your answer?
â cat
Jun 29 '16 at 15:18
I just add more thinking in a finished question for people which search the same question other way. ignore it what if you are not.
â Se ven
Jun 29 '16 at 15:50
I just add more thinking in a finished question for people which search the same question other way. ignore it what if you are not.
â Se ven
Jun 29 '16 at 15:50
This
count=0
method is quite interesting, I've added an example.â agc
Jun 29 '16 at 16:47
This
count=0
method is quite interesting, I've added an example.â agc
Jun 29 '16 at 16:47
6
6
Note that the
dd
example above may well allocate a sparse file. In that case the file size is 50G, it's actually only using a block (or not even) and so the disk is not getting full. YMMV.â MAP
Jun 29 '16 at 19:49
Note that the
dd
example above may well allocate a sparse file. In that case the file size is 50G, it's actually only using a block (or not even) and so the disk is not getting full. YMMV.â MAP
Jun 29 '16 at 19:49
2
2
I tested your suggestion on my ext3 filesystem. it did not work as expected. truncate and dd did create a file with a large file size, but "df -h" did not recognize it. still shows the same free hd space.
â Axel Werner
Jun 30 '16 at 6:53
I tested your suggestion on my ext3 filesystem. it did not work as expected. truncate and dd did create a file with a large file size, but "df -h" did not recognize it. still shows the same free hd space.
â Axel Werner
Jun 30 '16 at 6:53
 |Â
show 2 more comments
up vote
0
down vote
You could also take advantage of the stress-ng tool that is supported on a wide number of Linux-based systems:
stress-ng --fallocate 4 --fallocate-bytes 70% --timeout 1m --metrics --verify --times
New contributor
add a comment |Â
up vote
0
down vote
You could also take advantage of the stress-ng tool that is supported on a wide number of Linux-based systems:
stress-ng --fallocate 4 --fallocate-bytes 70% --timeout 1m --metrics --verify --times
New contributor
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You could also take advantage of the stress-ng tool that is supported on a wide number of Linux-based systems:
stress-ng --fallocate 4 --fallocate-bytes 70% --timeout 1m --metrics --verify --times
New contributor
You could also take advantage of the stress-ng tool that is supported on a wide number of Linux-based systems:
stress-ng --fallocate 4 --fallocate-bytes 70% --timeout 1m --metrics --verify --times
New contributor
New contributor
answered 8 mins ago
theosophe74
11
11
New contributor
New contributor
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f292843%2fway-to-instantly-fill-up-use-up-lots-of-disk-space%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
sorry, forgot to mention that its a >> ext3 filesystem.
â Axel Werner
Jun 29 '16 at 12:17
You need to upgrade it to ext4 to support fallocate.
â Rui F Ribeiro
Jun 29 '16 at 12:22
1
Zip bomb always works
â galois
Jun 29 '16 at 18:53
1
@jaska Make it an answer. It was the very first idea I got when reading the title...
â Crowley
Jun 30 '16 at 9:35
Why don't you use
/dev/full
? (Assuming it exists). Tryecho 'test' > /dev/full
on Debian.â Ismael Miguel
Jun 30 '16 at 15:53