Powering jetson nano

Can i power jetson nano from barrel jack using power supply and battery pack from j40 headers?
If yes, will the batteries act as a ups when i cut off power from barrel jack?
Thank you.

It is not possible to just connect battery pack directly to GPIO, it would either kill Nano or would unable to deliver sufficient voltage, or both. When I had a need of something like this, at first I was thinking making my own device to solve the problem, but googling revealed that UPS for Jetson Nano already exists, and it does exactly that - powers Jetson Nano via GPIO, and if the barrel jack is unplugged, it will use batteries as a backup power source:

It works well for me. Its cut off voltage is 2.5V which is acceptable for modern Li-Ion batteries. Built-in LED fuel gauge is not accurate but fortunately remaining charge reported via I2C is of good accuracy. It is strange that they did not use values reported by i2c fuel gauge for built-in LED fuel gauge but other than that, everything works great. My Jetson Nano consumes at full load about 20W (instead of usual 10W) since it is overclocked (CPU 2.2GHz, GPU 1.2GHz, NVENC/NVDEC 0.8GHz), and input voltage (accorging to “sudo cat /sys/bus/i2c/drivers/ina3221x/6-0040/iio:device0/in_voltage0_input”) is within 4.79-4.81V at 20W power consumption. It would be better if they made it 5.25V instead of 5.1V so there is more voltage headroom under load (below 4.75V Jetson Nano can become unstable and some USB devices do not like USB voltage below 5.0V). But as of right now, this is the best UPS for Jetson Nano. And even when batteries about to hit 2.5V cut off threshold, input voltage is maintained at 4.8V@4A and there is no stability issues. I did not test if it can actually provide 8A while maintaining acceptable input voltage but it can provide at least 5-6A before input voltage hits 4.75V threshold which is good enough for me. It can simultaneously charge batteries and power nano. It has its own barrel jack socket, and the barrel jack socket at the Jetson Nano board is not supposed to be used, so I made a dummy plug for it to prevent its accidental usage instead of barrel jack socket of the UPS.

I dont want to buy, i have 6 lithium batteries connected to a dc-dc converted that powers jetson nano through both 5v and gnd pins, i want to power jetson nano from dc power supply and when electricity powers off jetson automatically powers from the batteries without turning off.
Is it possible without making an external circuit?
Is their pins or a mode that jetson nano have so that it can switch from barrel to batteries instantly?

Even if you do not want to buy, you may want to look at how others solved the problem you are trying to solve. If you look at my description of the UPS for Jetson Nano and its picture, it is clear that it makes no sense to use barrel jack socket of Jetson Nano if you already are using GPIO to provide power and that Jetson Nano does not have built-in UPS where you could just plug-in a battery.

I recommend you to look at https://developer.nvidia.com/jetson-nano-carrier-board-design-files - by looking at Jetson Nano carrier board schematics you can understand how it works, what components it has and how they are connected. Barrel jack socket has a protection circuit, and by providing power directly via GPIO you bypass the protection. The benefit of doing this is lesser voltage drop under load. You will also see in the schematics that there is no built-in UPS on the carrier board which can switch between a battery and DC power supply (actually, there is a tiny UPS in Jetson Nano, but only for RTC - it can charge a small battery or supercapacitor and use it when there is no external power to keep the clock running).

Before I got T208, I was using external dc-dc converter as 5.25V power supply for Jetson Nano, and I made multiple inputs for it - one for 11.1V battery, and another one for 12V DC power supply. I was using Li-ion batteries with built-in overcurrent, overvoltage, undervoltage and overtemperature protections. It may be not a good idea to charge them with constant 12V power supply and blindly discharge them. But I did not want to turn off Jetson Nano each time I switch from the battery to DC power, and I also had microcontroller which I used to monitor the battery voltage among other things. After plugging in 12V DC power, I could either leave the battery to be charged with constant 12V voltage or disconnect the battery and put it in a proper charger (this is what I usually did). Basically, all I had is a socket for 12V DC power which was directly connected to inputs of DC-DC converter and the battery. It worked fine for many months until I finally decided to buy T208 because I wanted proper fast charging, better fuel gauge meter and more compact size.

You did not mention what cells you are using. Please note that if you are using a Li-ion battery and it does not have built-in protection circuit, you should not even try what I described above. Devices such as T208 provide their own protection so it is fine to use unprotected Li-ion cells, but it is not safe to use unprotected Li-ion directly, without external circuit to protect them from overdiscarging, overvoltage and overcurrent.