Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Power saving measures in command line mode?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
The_Pope
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jul 2016
Posts: 111

PostPosted: Fri Dec 23, 2022 9:33 pm    Post subject: Power saving measures in command line mode? Reply with quote

Hello everyone,

I managed to start the installation on this UEFI tablet by booting from the liveDVD.
The problem is, the battery runs out while compiling :D

I boot the DVD, which defaults to GUI mode, but quickly switch to the console, pressing Ctrl+F1. Then I set the root password and start the installation normally.

What I'd like to try now is to switch off the screen before compiling. Like

"switch off screen" && emerge --oneshot whatever && "switch on screen"
Every USB device I connected to it is on a separately-powered USB hub. I also set MAKEOPTS="-j1" in the hope it will eat up less power than -j2, although I can theoretically go up to "-j4"
The tablet is connected to a 5V 3A power supply at all times, but it seems that's just not enough. That's why I'm hoping that switching off the screen will be enough to keep it going.

As a sidenote, I managed to install the resolve-march-native package, and the respective command gave me the longest -march line I've ever seen. It's some sort of low power dual-core Intel Atom with Hyperthreading, apparently.

Searching around the forum, I found this topic mentioning setterm -powersave off and setterm blank 0.

Having looked at setterm, I will try "setterm --powerdown 1" && "emerge whatever" && "setterm powerdown 0"

Any other tips to make sure I can compile at least one package at a time?
_________________
Stop the world. I want to descend.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54665
Location: 56N 3W

PostPosted: Fri Dec 23, 2022 9:45 pm    Post subject: Reply with quote

The_Pope,

"switch off screen" && emerge --oneshot whatever && "switch on screen"
is probably not quite what you want. && means if the previous command is successful ... do the following command.
That is, if emerge fails. the screen stays off. That's probably not what you want.

Write a wee ditty to do three separate commands on three lines.

Thinking about installing on something like a low power Atom.
I would build it binaries on a more capable system, poor wee thing, then install the binaries on the Atom.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
The_Pope
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jul 2016
Posts: 111

PostPosted: Fri Dec 23, 2022 10:03 pm    Post subject: Reply with quote

NeddySeagoon wrote:


Write a wee ditty to do three separate commands on three lines.



You mean one of those .sh scripts? Okay.

NeddySeagoon wrote:

Thinking about installing on something like a low power Atom.
I would build it binaries on a more capable system, poor wee thing, then install the binaries on the Atom.


Yeah, in theory I can do that. I'd only need to manage to set up distcc and configure portage with it. Haven't managed so far, because I'm not a sysadmin.
_________________
Stop the world. I want to descend.
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2191

PostPosted: Sat Dec 24, 2022 10:27 am    Post subject: Re: Power saving measures in command line mode? Reply with quote

The_Pope wrote:
Hello everyone,
...
I managed to start the installation on this UEFI tablet by booting from the liveDVD.
The problem is, the battery runs out while compiling :D
...
The tablet is connected to a 5V 3A power supply at all times, but it seems that's just not enough. That's why I'm hoping that switching off the screen will be enough to keep it going.
...

I wonder if your kernel's battery management is switching off the power supply. I'd have thought 3A would be enough for any tablet - 15W should get it glowing a nice dull red :-)
_________________
Greybeard
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54665
Location: 56N 3W

PostPosted: Sat Dec 24, 2022 10:48 am    Post subject: Reply with quote

The_Pope,

Not distcc, the configure and linking still happens on the poor wee tablet.

On your favourite desktop, make a chroot. Perform the Tablet install there.
Before you build anything ... in the chroot
1. Set CFLAGS to that mouthfut that resolve-march-native gave you.
2. Run app-portage/cpuid2cpuflags on the tablet and set CPU_FLAGS_... to whatever it tells you.
3. Add buildpkg to FEATURES

Now your big hairy desktop is going to build everything in the chroot to suit the poor wee Atom.
It will save a set of binary packages for the Atom too.

Its only that easy if the build host CPU can execute all the instruction on the Atom.
It can certainly build code that way.

The code in the chroot can be divided into two groups. The code that must run there, and everything else.
If you find that the chroot gives you illegal instruction errors, some code built for the Atom has just failed to execute on the build host.
You can build a list of packages as you discover them and set more build host friendly CFLAGS, just for them.

Its time to move your binary packages to the Atom and install them there.
There are several ways to achieve that.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
The_Pope
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jul 2016
Posts: 111

PostPosted: Sat Dec 24, 2022 11:31 am    Post subject: Re: Power saving measures in command line mode? Reply with quote

Goverp wrote:


I wonder if your kernel's battery management is switching off the power supply. I'd have thought 3A would be enough for any tablet


Yeah, I wish I knew, too. It seems a red LED, when it's permanently on, means it's charging. Blinking looks like it means battery low.
Full charge takes a lot of hours, like overnight. Then you find the LED off. I'm guessing the battery's own management doesn't suck in more than whatever amount of power, which is probably less than the 15W my power supply can provide.

I did find a way to turn off the screen, I typed setterm --powersave on, setterm --powerdown 1, setterm --powersave powerdown and setterm --blank 1. After each command I waited for a minute, but only after setterm --blank 1 did the screen actually get turned off automatically. Did the previous commands have anything to do with that, I don't know.

Making a binhost for such a Gentoo machine is stupid - it's better to just install Arch Linux.
But I would see the point in compiling the packages with distcc. I never understood how to specify which IP ranges to allow, on the distcc server side.
_________________
Stop the world. I want to descend.
Back to top
View user's profile Send private message
The_Pope
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jul 2016
Posts: 111

PostPosted: Sat Dec 24, 2022 12:00 pm    Post subject: Reply with quote

NeddySeagoon wrote:


On your favourite desktop, make a chroot. Perform the Tablet install there.
Before you build anything ... in the chroot
1. Set CFLAGS to that mouthfut that resolve-march-native gave you.
2. Run app-portage/cpuid2cpuflags on the tablet and set CPU_FLAGS_... to whatever it tells you.
3. Add buildpkg to FEATURES

Now your big hairy desktop is going to build everything in the chroot to suit the poor wee Atom.
It will save a set of binary packages for the Atom too.

Its only that easy if the build host CPU can execute all the instruction on the Atom.
It can certainly build code that way.


Nope, I have a few problems. The desktop in the house is a Core 2 Duo. A pretty kickass 3.33 GHz with 1333 MHz FSB, but still a Core 2 Duo. The tablet is way newer than that.
When I set up Gentoo, I noticed make.conf didn't have a CHOST line, so I wrote x86_64-pc-linux-gnu. Then tried to emerge cpuid2cpuflags, which failed because the compiler couldn't create executables. March-resolve-native did install successfully, but I think that's because it relies on python and not on gcc.
Then I said okay, so it's like changing the CHOST. I managed to emerge binutils, power off the system and charge the battery. Tried to emerge gcc at least twice, but it can't make it to the end, so far.
So I can't install cpuid2cpuflags yet, somewhat hilariously.

I can try the chroot thing on an i3 laptop, but that one has a different Linux distribution on it. I understand it's like trying to make a new Gentoo install somewhere in a directory of my choice, so it shouldn't matter.
_________________
Stop the world. I want to descend.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54665
Location: 56N 3W

PostPosted: Sat Dec 24, 2022 4:32 pm    Post subject: Reply with quote

The_Pope,

make.conf contions changes to your profile. CHOST is set in you profile.
There has been no need to change the CHOST since glibc dropped i386 support at glibc-2.2. At that time many users had no upgrade path as thef started with the i386 stage files.
It's OK to not set CFLAGS.

Code:
emerge --info
shows the profile ash modified by make.conf settings.

Wild guess ... compiler couldn't create executables is often due to CFLAGS=" ... -02 ..." not -O2. Its letter uppercase 'O', not numeral '0'.

Doing what you want to do is becoming more popular. Read over Build In A Chroot which has been on the wiki almost an hour now. :)

Comment welcome. Here or on the wiki Discussion page.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
The_Pope
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jul 2016
Posts: 111

PostPosted: Sun Dec 25, 2022 12:36 am    Post subject: Reply with quote

Uh, I was really early into the Gentoo install, so I just restarted it. I did it so many times that it doesn't bother me.

It couldn't have been the -O2 setting. The default make.conf comes with "-O2 -pipe" to which I add whatever resolve-march-native tells me, in front of -O2, and -fomit-frame-pointer after -pipe.
It definitely was due to me adding a CHOST value to make.conf - I didn't do it the second time and it just worked. I now have CPU_FLAGS_X86 defined, thanks to cpuid2cpuflags.

Your tutorial on compiling in a chroot:

Code:
mount -o bind /dev /usr/tortoise/dev


The handbook says something like:

Code:
mount --rbind /dev /usr/tortoise/dev


Do both do the same thing? There are more discrepancies like this, although they all look similar to the handbook.

Also:

Code:
mount -t ext4 /dev/mapper/nvmestatic-portage /usr/tortoise/var/db/repos/gentoo


What if I don't use a nvme drive? The locations are probably different.

Quote:
If tortoise is already installed, copy over its /etc/portage/*. If not, set the chroot /etc/portage/* to suit the target tortoise, then copy it to tortoise before the install.


You mean use make.conf and friends from the slow machine, into the chroot? Right, well, I wouldn't start this process without having at least set up the root Gentoo partition on the slow machine first, which would mean having stage3 already unpacked and maybe even cpuid2cpuflags and resolve-march-native already installed and reflected in make.conf...just a thought?

I think I can tell which lines to leave out when I want to avoid using tmpfs entirely, because the "hare" has just 4 GB of RAM in my case.

Otherwise... can this be done on a different Linux desktop distribution? I'm guessing at least gcc needs to be as exactly the same version as possible.
_________________
Stop the world. I want to descend.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54665
Location: 56N 3W

PostPosted: Sun Dec 25, 2022 11:57 am    Post subject: Reply with quote

The_Pope,

The guide assumes that the host install is Gentoo. If its not, you can't share its bits.
Then you need a whole Gentoo install in the chroot.

I think the handbook covers the eventuality that the host install is systemd, which I have no experience of.
The handbook mount steps are therefore preferred as they work with either openrc or systemd.

The
Code:
mount -t ext4 /dev/mapper/nvmestatic-portage /usr/tortoise/var/db/repos/gentoo
should be changed to be generic.
I'll do that but not today. The location of the host repo is user configurable.

Yes, you need at least a stage3 in a chroot on tortoise, as you need to run portage to install binaries.
I should add that too.

Thank you for the feedback.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
The_Pope
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jul 2016
Posts: 111

PostPosted: Sun Dec 25, 2022 2:31 pm    Post subject: Reply with quote

NeddySeagoon wrote:


I think the handbook covers the eventuality that the host install is systemd, which I have no experience of.
The handbook mount steps are therefore preferred as they work with either openrc or systemd.


I'm... far from being an expert, but as far as I know, the lines that do "mount --rbind" in the Gentoo Handbook are for openrc exclusively.
The ones for systemd are the ones that do "mount --make-rslave"

I'm pretty sure of this, because I have done a lot of installs just skipping the --make-rslave lines, as I had no intention of using systemd.

When mounting, I usually remember this by heart: mount root partition, mount --types proc /proc /mnt/gentoo/proc, then mount --rbind /dev and /sys.
Fairly recently, a new thing has been added: "mount --bind /run /mnt/gentoo/run"

Reading mount --help, it looks like your "mount -o bind" commands are equivalent and that there is only a little difference between --bind and --rbind.
_________________
Stop the world. I want to descend.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22918

PostPosted: Sun Dec 25, 2022 4:56 pm    Post subject: Reply with quote

--bind binds exactly the specified location. --rbind will do --bind as specified, then also find any mounts under the source and bind them to the corresponding locations under the destination. If the source has no mounts under it, then --rbind will have the same effect as --bind.

--make-rslave is to --make-slave as --rbind is to --bind. --make-slave marks the target as a "slave mount". Per man mount, a slave mount replicates mounts received from its master. When Linux boots, all mounts are private, so there is no need to use --make-slave. systemd has a (mis)feature that it likes to turn many mounts from private to shared. If running on a system where this was done, you may need --make-slave to prevent changes made inside the chroot from propagating back out of the chroot.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo 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