How do you increase MAXSYMLINKS

In a python script, I am creating a bunch of symbolic links chained together.

example: link1->link2->link3->…….->somefile.txt

I was wondering how you can change the max number of symlinks to be greater than 20?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

On Linux (3.5 at least), it’s hardcoded to 40 (see follow_link() in fs/namei.c), and note that it’s the number of links followed when resolving all the components of a path, you can only change it by recompiling the kernel.

$ ln -s . 0
$ n=0; repeat 50 ln -s $((n++)) $n
$ ls -LdF 39
39/
$ ls -LdF 40
ls: cannot access 40: Too many levels of symbolic links
$ ls -LdF 20/18 10/10/10/6
10/10/10/6/  20/18/
$ ls -LdF 20/19 10/10/10/7
ls: cannot access 20/19: Too many levels of symbolic links
ls: cannot access 10/10/10/7: Too many levels of symbolic links


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x