Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I think what you're asking is how you can change boot parameters when Linux is up and running already.
You have to edit your boot environment. Typically the boot environment is on flash in protected sectors. Therefore you'd have to make a routine to un-protect the flash, read it, do the modifications you require, then save back to flash and re-protect the sectors. Some stuff may already exist. We had to do this long ago when using this bootloader because we needed to option it for booting between different images which were at different disk locations. What we chose to do actually was to have the bootloader load a fixed environment which depended on variables, we established those variables first by reading a totally separate sector in flash. This way our active Linux (upgrade process) would edit solely the "content" of the boot variables, but not the integrity of the bootloader environment. For instance, we'd establish a variable; such as BOOT_DELAY, and the bootloader environment used
Code:
bootdelay=$BOOT_DELAY
Our setup prior to reading the boot environment would establish either these variables as read from our "settings" flash location, or use defaults. I.e. we'd establish defaults; read the "settings" location and if the checksum was OK, we'd modify any variables which were included in the "settings" location. Then read the boot environment; which was always consistent in using the variables. This way we ran less of a chance of corrupting our boot environment; we could corrupt the "settings" location, but we had a checksum of it and started with defaults. In fact, part of certain upgrades where we wanted to force defaulting of the box, we'd force that checksum to be an impossible value and thus cause a rewrite of the settings sector to be a default.
Sorry, I'm half-recalling more and more as I've written here. The main points were that we were concerned that even though we could edit the boot environment from our operational image, we felt it was risky, so we figured a way to do this where we could encounter one or more of the potential problems we foresaw and still work.
I think what you're asking is how you can change boot parameters when Linux is up and running already.
You have to edit your boot environment. Typically the boot environment is on flash in protected sectors. Therefore you'd have to make a routine to un-protect the flash, read it, do the modifications you require, then save back to flash and re-protect the sectors. Some stuff may already exist. We had to do this long ago when using this bootloader because we needed to option it for booting between different images which were at different disk locations. What we chose to do actually was to have the bootloader load a fixed environment which depended on variables, we established those variables first by reading a totally separate sector in flash. This way our active Linux (upgrade process) would edit solely the "content" of the boot variables, but not the integrity of the bootloader environment. For instance, we'd establish a variable; such as BOOT_DELAY, and the bootloader environment used
Code:
bootdelay=$BOOT_DELAY
Our setup prior to reading the boot environment would establish either these variables as read from our "settings" flash location, or use defaults. I.e. we'd establish defaults; read the "settings" location and if the checksum was OK, we'd modify any variables which were included in the "settings" location. Then read the boot environment; which was always consistent in using the variables. This way we ran less of a chance of corrupting our boot environment; we could corrupt the "settings" location, but we had a checksum of it and started with defaults. In fact, part of certain upgrades where we wanted to force defaulting of the box, we'd force that checksum to be an impossible value and thus cause a rewrite of the settings sector to be a default.
Sorry, I'm half-recalling more and more as I've written here. The main points were that we were concerned that even though we could edit the boot environment from our operational image, we felt it was risky, so we figured a way to do this where we could encounter one or more of the potential problems we foresaw and still work.
It's a very good idea. Thanks. But for me(newbie) its too complicated. Thanks a lot anyway.
I realize that, but given that you're using u-boot you're likely on an embedded platform. I'd consider it if you're creating a product. But do agree that if this is merely experimentation or a personal project, then you're just better off editing it once, saving the environment and leaving it at that.
When you break into u-boot, you can print the environment, via printenv, and you can change the boot delay setting there, then you can save the environment, via saveenv and it should stay that way for each recurring boot.
I realize that, but given that you're using u-boot you're likely on an embedded platform. I'd consider it if you're creating a product. But do agree that if this is merely experimentation or a personal project, then you're just better off editing it once, saving the environment and leaving it at that.
When you break into u-boot, you can print the environment, via printenv, and you can change the boot delay setting there, then you can save the environment, via saveenv and it should stay that way for each recurring boot.
Ye. Setting in the u-boot would be easier.. I will take a good look at your method when I have enough time, its defninitly a very good idea to solve this kind of problems.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.