how can i limit system resources for a particular process?

Jordi Moles Blanco
2009-07-02T14:29:17+00:00

hi everyone,

let's say i want to create an .img file of 50GB with "dd" command. After 
that, i will give it a format with mkfs.ext3.

The problem is that while "dd" is running I'm not able to do anything 
else on the machine, not even ssh in, it just consumes all the available 
resources, and as I'm creating a 50GB image, i can't access the machine 
for several minutes.

I've tried to use "nice" command, giving the "dd" process the lowest 
possible priority, 19. The thing is that the whole thing performs 
better, i can establish ssh connection. However, i can't do much when 
I'm in it, everything is so slow.

I've also read some documentation about "limit/ulimit" command, but i 
fail to see how i can use it successfully for this matter.

I would like to run dd and let it use, for example, only 10% of the CPU 
time or 30% of the total amount of memory. Is that possible?  I'm not 
looking for a "general" process limit for the whole system, only for a 
particular process.

Thanks in advance for your help.


Re: how can i limit system resources for a particular process? by Nils Kassube on 2009-07-02T15:33:35+00:00
Jordi Moles Blanco wrote:
> let's say i want to create an .img file of 50GB with "dd" command.
> After that, i will give it a format with mkfs.ext3.
>
> The problem is that while "dd" is running I'm not able to do anything
> else on the machine, not even ssh in, it just consumes all the
> available resources, and as I'm creating a 50GB image, i can't access
> the machine for several minutes.
>
> I've tried to use "nice" command, giving the "dd" process the lowest
> possible priority, 19. The thing is that the whole thing performs
> better, i can establish ssh connection. However, i can't do much when
> I'm in it, everything is so slow.

Try the ionice command. In your case the problem is the constant write 
access to the disk. If you want to limit disk access to times where no 
other process wants to use the disk, it would be a command like this:

ionice -c3 dd if=/dev/zero of=filename.img bs=10M count=5000

You can even combine it with nice like

nice -19 ionice -c3 dd if=/dev/zero of=filename.img bs=10M count=5000

but I don't think that is necessary.


Nils



Re: how can i limit system resources for a particular process? by Donn on 2009-07-02T15:40:38+00:00
On Thursday, 02 July 2009 17:31:41 Nils Kassube wrote:
> Try the ionice command
Awesome post Nils, thanks. I made a gnote of it ;)

d


Re: how can i limit system resources for a particular process? by Willy K. Hamra on 2009-07-02T15:47:29+00:00
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
> Awesome post Nils, thanks. I made a gnote of it ;)
>=20
> d
>=20
yeah, nice one. in kysyguard, it automatically redjusts the IO niceness
as i move the CPU niceness slider. but for a non-gui way, ionice is
excellent. thanks!

Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

---

Re: how can i limit system resources for a particular process? by Alvin on 2009-07-02T16:59:08+00:00
On Thursday 02 July 2009 17:38:40 Donn wrote:
> On Thursday, 02 July 2009 17:31:41 Nils Kassube wrote:
> > Try the ionice command
>
> Awesome post Nils, thanks. I made a gnote of it ;)

I agree, but I used kjots ;-)


Re: how can i limit system resources for a particular process? solved - by Jordi Moles Blanco on 2009-07-03T07:22:05+00:00
hi,

thanks for the advice, that worked great, it's what i was looking for.

Jordi.

En/na Nils Kassube ha escrit:
> Jordi Moles Blanco wrote:
>   
>> let's say i want to create an .img file of 50GB with "dd" command.
>> After that, i will give it a format with mkfs.ext3.
>>
>> The problem is that while "dd" is running I'm not able to do anything
>> else on the machine, not even ssh in, it just consumes all the
>> available resources, and as I'm creating a 50GB image, i can't access
>> the machine for several minutes.
>>
>> I've tried to use "nice" command, giving the "dd" process the lowest
>> possible priority, 19. The thing is that the whole thing performs
>> better, i can establish ssh connection. However, i can't do much when
>> I'm in it, everything is so slow.
>>     
>
> Try the ionice command. In your case the problem is the constant write 
> access to the disk. If you want to limit disk access to times where no 
> other process wants to use the disk, it would be a command like this:
>
> ionice -c3 dd if=/dev/zero of=filename.img bs=10M count=5000
>
> You can even combine it with nice like
>
> nice -19 ionice -c3 dd if=/dev/zero of=filename.img bs=10M count=5000
>
> but I don't think that is necessary.
>
>
> Nils
>
>
>   


Loading


$ This page is proudly powered by www.pubbs.net, you can see more at ubuntu archive | Partners: Global Manufacturers