bharadwajtk
Posts: 65
Joined: Sun May 26, 2013 10:22 am

IP from cmdline.txt is not taking sometimes

Fri Jan 30, 2015 10:40 am

Hi, I am setting static IP to Pi by editing the cmdline.txt file in my Laptop. The issue Pi is not picking this IP after boot. I have another SD card which is exactly similar to this one and there I am able to set static IP by changing cmdline.txt file from Laptop. Both my SD cards have some script added to it which runs at boot time (to get inputs from a button).

1. Is this boot time script interfering and not allowing the IP value to be read from cmdline.txt file?
2. If yes, how it's working in the other SD card, which has the same settings? or Is it meant to behave randomly ??

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: IP from cmdline.txt is not taking sometimes

Fri Jan 30, 2015 12:39 pm

This isn't ant rpi-update thing is it ? A lot of stuff has been broken/changed since kernel version 3.18 came out on rpi-update. Unless you've got a very good reason, never, ever, run rpi-update.

The IP from cmdline.txt is an unholy botch at the best of times, I'd learn how to do it properly, lots of info on google.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: IP from cmdline.txt is not taking sometimes

Fri Jan 30, 2015 1:12 pm

pluggy wrote:This isn't ant rpi-update thing is it ? A lot of stuff has been broken/changed since kernel version 3.18 came out on rpi-update. Unless you've got a very good reason, never, ever, run dpi-update.
Agreed.

The IP from cmdline.txt is an unholy botch at the best of times, I'd learn how to do it properly, lots of info on google.
Agreed.

But the supposed "sell" of this method is that you can do it quickly and easily from a non-Linux machine (I.e., Windows). Of course, this is lost nowadays for "most" users, since they will (presumably) be using NOOBS (and that breaks the "Can do it from Windows" thing).

It'd be nice if someone could come up with a "tool" that would "just do it" - some tool that could be run from Windows and would do this change (and do it for either Ethernet or Wireless). There was a lot of discussion of this way back when, and it seemed like we were frequently "almost there", but no one was ever able to quite seal the deal.

Note: Yes, I am aware that this task is (on paper) "impossible", because the files we need to change are in the ext4 partition on the SD card and Windows can't (on paper) access those file. Still, there are workarounds - ways to get these things done. As I've said, quite a while ago, we were "almost there". It still seems to me that it ought to be possible to do this. I may work on it at some point…
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: IP from cmdline.txt is not taking sometimes

Fri Jan 30, 2015 1:26 pm

Regarding your signature Joe, I've never come across any forum where updating your signature doesn't affect every post you ever made. Its not broken, its just very difficult to make it behave otherwise, so nobody does it. Even the expensive and very highly regarded vBulletin forum software behaves this way. Its certainly standard issue with good ol' phpbb.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: IP from cmdline.txt is not taking sometimes

Fri Jan 30, 2015 1:33 pm

pluggy wrote:Regarding your signature Joe, I've never come across any forum where updating your signature doesn't affect every post you ever made. Its not broken, its just very difficult to make it behave otherwise, so nobody does it. Even the expensive and very highly regarded vBulletin forum software behaves this way. Its certainly standard issue with good ol' phpbb.
It seems odd to me, coming from Usenet. Also email.

I agree that it is "standard" in web based forums.

One of the many reasons why web based forums are a bad idea.

(And get off my lawn!!!)
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
procount
Posts: 1834
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: IP from cmdline.txt is not taking sometimes

Fri Jan 30, 2015 2:02 pm

@bharadwajtk - I didn't have a problem using this method with Raspbian, although it was a while ago on a model B. But I did find it a bit flakey when adding it to the NOOBS recovery program in recovery.cmdline when I was trying to overcome my DHCP not working properly from a directly connected laptop connection (timing issues).
Completing more parameters to the ip= parameter often helped. I did wonder if that was a timing issue too.

Do you need to change this static IP address often, or is it just the case that you need to be able to set it once after installation, but you want to set it from a Windows PC?
Are you running headless?
Did you install from NOOBS, or a direct image write?
I'm just trying to identify your use cases, as this is a common problem with various solutions.

I have a solution for a NOOBS installation called noobsconfig - https://github.com/procount/noobsconfig. That allows you to set up Ethernet or Wifi network connection parameters on the SD card from Windows before you install Raspbian from Noobs and it patches the parameters during installation. It also includes a retro.sh script that allows you to do it retrospectively, i.e. after you have installed the OS. You could adapt that for your needs if you are not using NOOBS. Meltwater has adopted noobsconfig for his PiKitchen recipes https://pihw.wordpress.com/guides/pi-kitchen/ which provide many documented examples.

There is also a solution called rpi_conf from Abishur that does a similar thing, allowing configuration from Windows and copying configurations to the ext4 partition on boot, which doesn't assume noobs. I'm sure there are others as well.

@Joe Schmoe - noobsconfig enables me to set my network connection out of the box from Windows, but it only works with NOOBS because that allows me to hook into the installation process. That is not the case with a standard Raspbian image (say) that is downloaded from the RPF. Maybe what is required is a run-once boot script to be added to the standard distribution (like raspi-config) that can pick up a script or parameters from the boot partition (like Abishur's rpi_conf). Are there other use cases you have in mind that would not be covered by the above? I suppose the main issue is to create a user friendly OS independent tool that can set it up, too.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

bharadwajtk
Posts: 65
Joined: Sun May 26, 2013 10:22 am

Re: IP from cmdline.txt is not taking sometimes

Wed Feb 04, 2015 4:10 pm

procount wrote:@bharadwajtk - I didn't have a problem using this method with Raspbian, although it was a while ago on a model B. But I did find it a bit flakey when adding it to the NOOBS recovery program in recovery.cmdline when I was trying to overcome my DHCP not working properly from a directly connected laptop connection (timing issues).
Completing more parameters to the ip= parameter often helped. I did wonder if that was a timing issue too.

Do you need to change this static IP address often, or is it just the case that you need to be able to set it once after installation, but you want to set it from a Windows PC?
Are you running headless?
Did you install from NOOBS, or a direct image write?
I'm just trying to identify your use cases, as this is a common problem with various solutions.

I have a solution for a NOOBS installation called noobsconfig - https://github.com/procount/noobsconfig. That allows you to set up Ethernet or Wifi network connection parameters on the SD card from Windows before you install Raspbian from Noobs and it patches the parameters during installation. It also includes a retro.sh script that allows you to do it retrospectively, i.e. after you have installed the OS. You could adapt that for your needs if you are not using NOOBS. Meltwater has adopted noobsconfig for his PiKitchen recipes https://pihw.wordpress.com/guides/pi-kitchen/ which provide many documented examples.

There is also a solution called rpi_conf from Abishur that does a similar thing, allowing configuration from Windows and copying configurations to the ext4 partition on boot, which doesn't assume noobs. I'm sure there are others as well.

@Joe Schmoe - noobsconfig enables me to set my network connection out of the box from Windows, but it only works with NOOBS because that allows me to hook into the installation process. That is not the case with a standard Raspbian image (say) that is downloaded from the RPF. Maybe what is required is a run-once boot script to be added to the standard distribution (like raspi-config) that can pick up a script or parameters from the boot partition (like Abishur's rpi_conf). Are there other use cases you have in mind that would not be covered by the above? I suppose the main issue is to create a user friendly OS independent tool that can set it up, too.

Hi, Thanks for the detailed reply. I need to change the IPs often. I am using Raspbian image written directly on SD card. and I am trying to set it from windows machine. The issue is some times it works but other times it doesn't. As I mentioned I have a script to get input from a switch, which runs at boot time. Is this script which is interfering with the cmdline.txt input and not letting the ip set to the desired value ????

User avatar
procount
Posts: 1834
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: IP from cmdline.txt is not taking sometimes

Wed Feb 04, 2015 4:25 pm

Well, if you temporarily remove your script, does it then work?

Another solution I saw somewhere (although NOT SECURE) is to copy your /etc/network/interfaces and /etc/wpa_supplicant/wpa_supplicant.conf (if you are using wifi) files to /boot. Then replace the originals with symlinks to the copies on /boot.
That allows you to easily edit those files using Windows, but the downside is it also allows everyone to see your network configuration (possibly including wifi passwords).
But if you are changing your static IP regularly, it might be a convenient solution for you.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

Return to “Troubleshooting”