You are not logged in.

#1 2024-12-30 21:36:41

JustSomeGeek
Member
From: Scotland
Registered: 2018-08-13
Posts: 68

Wiki - KVM - Hugepages [SOLVED]

https://wiki.archlinux.org/title/KVM

4.2 Enabling huge pages

# echo 550 > /proc/sys/vm/nr_hugepages

Produces the error: "warning: An error occurred while redirecting file '/proc/sys/vm/nr_hugepages'
open: Permission denied"

# sysctl -w vm.nr_hugepages=512

from: 14.7. Configuring Huge Pages in Red Hat Enterprise Linux 4 or 5

Appears to work fine for me.

Last edited by JustSomeGeek (2024-12-31 15:05:08)

Offline

#2 2024-12-31 09:19:48

seth
Member
Registered: 2012-09-03
Posts: 60,764

Re: Wiki - KVM - Hugepages [SOLVED]

This would belong into the wiki discussion page, but "#" indicates a root shell and in case you "sudo echo 550 > …" you're sudo'ing the wrong thing.
Try

echo 550 | sudo tee /proc/sys/vm/nr_hugepages

Offline

#3 2024-12-31 14:04:20

lahwaacz
Wiki Admin
From: Czech Republic
Registered: 2012-05-29
Posts: 764

Re: Wiki - KVM - Hugepages [SOLVED]

Offline

#4 2024-12-31 14:33:24

JustSomeGeek
Member
From: Scotland
Registered: 2018-08-13
Posts: 68

Re: Wiki - KVM - Hugepages [SOLVED]

seth wrote:

This would belong into the wiki discussion page, but "#" indicates a root shell and in case you "sudo echo 550 > …" you're sudo'ing the wrong thing.
Try

echo 550 | sudo tee /proc/sys/vm/nr_hugepages

That works. But I was just pointing out that the quoted command on the Wiki page did not give the expected result, so I am attempting to point out an inaccuracy, or ambiguity in the article. (Or my own competence in understanding it.) Also, I thought this was the Wiki discussion sub-forum.

Offline

#5 2024-12-31 14:36:02

JustSomeGeek
Member
From: Scotland
Registered: 2018-08-13
Posts: 68

Re: Wiki - KVM - Hugepages [SOLVED]

Yes, which is why I attempted to sudo the command, as indicated in the article. But thank you.

Offline

#6 2024-12-31 14:51:31

seth
Member
Registered: 2012-09-03
Posts: 60,764

Re: Wiki - KVM - Hugepages [SOLVED]

This has nothing to do w/ the wiki and there's absolutely nothing inaccurate in it.

The problem is down to

which is why I attempted to sudo the command

Attempting

sudo echo foo > /root/owned/bar

is a classical beginner mistake and reflects unawareness of the shell.
You're elevating "echo" but echo writes to *your* stdout. It is then the redirection (">") which tries to write into the protected path, but the redirection isn't elevated.
You could also use a subshell (I remember a semi-heated debate about which one was more efficient) but piping into the elevated "sudo tee" is probably the most common approach.

In this specific case you can just as much use sysctl which will write into that path and is directly elevatable w/ sudo, but that's a special case and you're better off having understood the problems and some shell basics wink

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

#7 2024-12-31 15:04:20

JustSomeGeek
Member
From: Scotland
Registered: 2018-08-13
Posts: 68

Re: Wiki - KVM - Hugepages [SOLVED]

seth wrote:

This has nothing to do w/ the wiki and there's absolutely nothing inaccurate in it.

The problem is down to

which is why I attempted to sudo the command

Attempting

sudo echo foo > /root/owned/bar

is a classical beginner mistake and reflects unawareness of the shell.
You're elevating "echo" but echo writes to *your* stdout. It is then the redirection (">") which tries to write into the protected path, but the redirection isn't elevated.
You could also use a subshell (I remember a semi-heated debate about which one was more efficient) but piping into the elevated "sudo tee" is probably the most common approach.

In this specific case you can just as much use sysctl which will write into that path and is directly elevatable w/ sudo, but that's a special case and you're better off having understood the problems and some shell basics wink

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Ah! Then, my apologies, and thanks, to the Wiki team. The trouble with learning, is not realising you don't know something, until someone else points it out. I'll scuttle away and attempt to educate myself better. Thanks! :-)

Offline

Board footer

Powered by FluxBB