Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Tip: Fix "argument list too long" errors for good!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
My_World
Guru
Guru


Joined: 01 Sep 2003
Posts: 339
Location: Kalahari Desert

PostPosted: Mon Jan 30, 2006 3:00 am    Post subject: Tip: Fix "argument list too long" errors for good! Reply with quote

Just thought I would share a tip, use it, don't use it...
:P

As of late I have been getting these irretating errors with mv, cp, ls, etc. commands:
Code:

myworld@jj ~ $ cp -fr /usr/portage/distfiles/* ~/backup/distfiles/
-l: /usr/bin/cp: Argument list too long


So after a bit of Googling I found that the kernel is to blame for this! 8O

Here follows a fix to permanently fix this issue (hopefully it will receive attention as our systems become more powerfull and data more plentifull):
Quote:

One of the advantages of using an open-source kernel is that you are able to examine exactly what it is configured to do and modify its parameters to suit the individual needs of your system. Method #4 involves manually increasing the number of pages that are allocated within the kernel for command-line arguments. If you look at the include/linux/binfmts.h file, you will find the following near the top:

/*
* MAX_ARG_PAGES defines the number of pages allocated for arguments
* and envelope for the new program. 32 should suffice, this gives
* a maximum env+arg of 128kB w/4KB pages!
*/
#define MAX_ARG_PAGES 32

In order to increase the amount of memory dedicated to the command-line arguments, you simply need to provide the MAX_ARG_PAGES value with a higher number. Once this edit is saved, simply recompile, install and reboot into the new kernel as you would do normally.

On my own test system I managed to solve all my problems by raising this value to 64. After extensive testing, I have not experienced a single problem since the switch. This is entirely expected since even with MAX_ARG_PAGES set to 64, the longest possible command line I could produce would only occupy 256KB of system memory--not very much by today's system hardware standards.

The advantages of Method #4 are clear. You are now able to simply run the command as you would normally, and it completes successfully. The disadvantages are equally clear. If you raise the amount of memory available to the command line beyond the amount of available system memory, you can create a D.O.S. attack on your own system and cause it to crash. On multiuser systems in particular, even a small increase can have a significant impact because every user is then allocated the additional memory. Therefore always test extensively in your own environment, as this is the safest way to determine if Method #4 is a viable option for you.


Read more here for other solutions and fixes, but the abovementioned one is the best by far.
_________________
"Ubuntu" - an African word meaning "Gentoo is too hard for me".
Back to top
View user's profile Send private message
/dev/random
l33t
l33t


Joined: 26 Nov 2004
Posts: 704
Location: Austin, Texas, USA

PostPosted: Mon Jan 30, 2006 3:09 am    Post subject: Reply with quote

man xargs
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 18157

PostPosted: Wed Feb 01, 2006 5:48 am    Post subject: Reply with quote

/dev/random wrote:
man xargs
:mrgreen: xargs was the first thing I thought of, just wasn't in the mood for a demo.
_________________
Those who know what's best for us must rise and save us from ourselves.
Back to top
View user's profile Send private message
trunet
n00b
n00b


Joined: 03 Oct 2003
Posts: 11
Location: São Paulo/SP/Brazil

PostPosted: Wed Feb 01, 2006 4:17 pm    Post subject: Reply with quote

try this:

Code:

# find /usr/portage/distfiles -exec cp {} ~/backup/distfiles \;
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum