How to consume all available space on partition?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to consume all available space on partition?
# 1  
Old 04-15-2014
How to consume all available space on partition?

Hi

I'm doing some resilience testing and need to write a script to consume all of the available disk space on a partition and then to free it up again.

This would need to be -

Safe
Dynamic, in that it calculates the free space prior to consuming it.
I might want to go on to consume a configurable percentage of it instead...

This would be on a Centos Linux box

Anyone have any experience in this area?

Brad
# 2  
Old 04-15-2014
Can be quite dangerous

Unless the disk is not actively used, the results of maximizing (completely filling) the drive can be very unpredictable. Since this is a production environment, I will assume that others read/write to the drive, and what any program may do when confronted with an inability to get space is simply unknown.

That said, there are some simple processes to fill a disk. However, I would like to know more about why first.
# 3  
Old 04-15-2014
Smilie

Nothing sinister... Like I said, this is for some automated resilience testing. I need to prove that a service can cope when it has insufficient disk space available.

The service is supposed to load data files into a data store and should cope by telling the source server to add the files to the retry queue because it doesn't have the space to accept the copy of the file.
# 4  
Old 04-15-2014
Quote:
telling the source server to add the files to the retry queue because it doesn't have the space to accept the copy of the file.
For how long? And so it will retry again and again? dont you think the system will complain also and start generating loads of line in system log?
# 5  
Old 04-15-2014
Well that is exactly what I am trying to achieve. Stress the system and look for problems.

But to your specific question, no the logging should not get out of hand. It should just log that it has added it to the retry queue.
# 6  
Old 04-15-2014
Perhaps something in a simple loop will do the job:-
Code:
#!/bin/ksh

RC=0
typeset -Z20 counter=0

if [ ! -d hog ]
then
   mkdir hog
fi

until [ $RC -ne 0 ]
do
   ((counter=$counter+1))
   echo "Hello" > hog/hogfile_counter
   RC=$?
done

This will write vast numbers of files until either the space of the i-nodes are exhausted and no new files can be created. You can simply delete the entire hog directory to clean up.

If you want to ensure that you fill space, you could:-
Code:
#!/bin/ksh

RC=0
typeset -Z20 counter=0

until [ $RC -ne 0 ]
do
   ((counter=$counter+1))
   echo "$counter" >> hogfile
   cp hogfile hogtempA
   cp hogfile hogtempB
   cp hogfile hogtempC
   cp hogfile hogtempD
   cp hogfile hogtempE
   cat hogtemp? > hogfile   
   RC=$?
done

You can then delete hogfile and hogtemp? to free the space.

Both will take quite a while as the IO is probably expensive.

To set a limit, perhaps you could change the loop not to check the return code, but to do a df and get the current value. You can then test if it is over a predetermined limit.



I hope that this helps,
Robin
# 7  
Old 04-15-2014
Hi Robin

Thanks but I am hoping to perhaps calculate the size in bytes and then create a file in a directory about that size... Perhaps using something like dd?

I wouldn't want the automation suite hanging up for a long time while it generated the files.

This might work though if I create a file that is MB's in size and then copy it until I run out of space.

The idea though, is to leave so little space that the files being loaded would fail to copy across from the source server. So some sort of calculation of size will be required.

Calculating it in K might be accurate enough though. If I just leave a couple of K free then the files will certainly be too large.

Cheers

Brad
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Allot free space from one partition to other

I have a RHEL 5.3 machine with the following partitions and free space: Free space on the partitions / : 74GB /boot : 81MB /var : 73GB /home : 37GB /icat : 758MB /opt : 1.5GB Now is it possible to allot a free space of some other partitions to /opt? I want around 100 GB more space... (4 Replies)
Discussion started by: omniok
4 Replies

2. UNIX for Dummies Questions & Answers

How Much Space Before 1st Partition?

Hello All, I'm having trouble finding info on how to convert sector size (*if that's really what i want to do?) to something easier to understand. I'm trying to copy the MBR from a bootable SD Card to another SD Card or image file, but I'm not sure what I should use in my dd command since I'm... (17 Replies)
Discussion started by: mrm5102
17 Replies

3. Linux

How to increase root space from another partition?

Hi OS Experts I would like to increase root partition from another partition so that I can save more documents in Home and Desktop. whether it is possible without formating root partition if so please explain here is o/p of df -h Filesystem Size Used Avail Use% Mounted on /dev/sda9... (8 Replies)
Discussion started by: Akshay Hegde
8 Replies

4. Slackware

Ideal partition sizes of 17 gb space.

I am planning to install slack 13.37 on an old stand-alone PIII (512 mb ram) with 17 gb disk space. I need to keep lotsa pdf, chm type e-books for programming with few other misc. documents. I'm going to use this system for my personal use. It has no network but I browse internet with cable... (0 Replies)
Discussion started by: vectrum
0 Replies

5. UNIX for Dummies Questions & Answers

shifting space from one partition to other

hi My System is Sun Microsystems Inc. SunOS 5.10 Solaris Partition Info is /dev/vx/dsk/bootdg/var 27G 25G 1.2G 96% /var /dev/vx/dsk/bootdg/oravol 110G 54G 56G 49% /export/home I want to shift space 20G from /export/home to /var What should be the command ?? (2 Replies)
Discussion started by: kaushik02018
2 Replies

6. Red Hat

RHEL 5 supports only 2 TB space for a partition !

Dear Friends , I am using Redhat Ent Linux 5.0 with a EMC storage which HDD space is 4 TB. After Installing RHEL 5 , I get 4 TB space available but when I am going to create a partition then the OS show 2TB available space . I cannot create a partition above 2TB space . Is there any limitation... (3 Replies)
Discussion started by: shipon_97
3 Replies

7. AIX

How to find the top 6 users (which consume most space)?

Hi everybody, I want to know if there is any posibility to find out - on an AIX system - which are the the users who consume most space or at least a posibility to obtain a list with all the users and how much space are they consuming ? Trying to use du command was useless. Any idea?... (5 Replies)
Discussion started by: RebelDac
5 Replies

8. Shell Programming and Scripting

Disk space for root partition

Hello, I am trying to monitor disk space for each node on the machine. I am able to get all individual nodes but for the '/' node. For example: df -k: bash-2.05b# df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/xxx 4127108 2415340 1502120 62% / /dev/yyy ... (3 Replies)
Discussion started by: chiru_h
3 Replies

9. UNIX for Advanced & Expert Users

moving space from one partition to another

How can I move some space allocated to one partition to another, i.e. from "/var" to "/" . Thanks! (4 Replies)
Discussion started by: jason6792
4 Replies

10. UNIX for Dummies Questions & Answers

Swap Partition Space

first of all, sorry about my english...I´m a spanish newbie to this marvelous OS and i have just a couple of doubts...u know? :-) 1) how big should my swap partition be if i installed debian 2.2r3 or FreeBSD 4.x on a AMD k7 1400Mhz with 512Mb of Random Access Memory? i heard that those OS... (1 Reply)
Discussion started by: I[X]ION
1 Replies
Login or Register to Ask a Question