jceajcea
Posts: 10
Joined: Sat Sep 16, 2017 9:35 pm

Is hot plugging a microSD electrically safe?

Tue Jul 28, 2020 2:40 am

Hi there. Sorry if this is not the right forum area for this question. Please, move the thread where appropriate.

I am thinking about a PXE microSD card flasher. The idea is to boot a Raspberry PI from PXE, with no microSD card. That initial network OS would wait until the user inserts a microSD WHILE THE RASPBERRY IS ALIVE AND WAITING, then the OS connects to a image repository and starts flashing the microSD card, rebooting the RPI to the microSD card when done.

I need the microSD to be initially unplugged because I need the Raspberry PI to do a PXE boot (I am talking about RPI 3B+ here) and I can not count on what could be in the microSD. After booting, I need to be able to plug the microSD with out damaging the RPI or the microSD card, in order to overwrite it.

So my question is simple: Would be electrically safe to insert a microSD card in a running (PXE booted) Raspberry PI? I would like to know about Raspberry PI 3B, 3B+ and 4B.

I am interested in the electrical aspect, not the filesystem corruption aspect.

Also, can I know that a microSD is present beside trying to read a particular sector until success?

In the same line, just out of curiosity, would it be electrically safe to unplug a microSD from a powered on RPI?. Lets suppose the that filesystem was flushed & unmounted to avoid logical corruption.

If you have a better approach or cool suggestion, let me know.

Thanks a lot.

PS: If somebody else already did something similar, please, let me know.

ejolson
Posts: 5795
Joined: Tue Mar 18, 2014 11:47 am

Re: Is hot plugging a microSD electrically safe?

Tue Jul 28, 2020 2:46 am

jceajcea wrote:
Tue Jul 28, 2020 2:40 am
Hi there. Sorry if this is not the right forum area for this question. Please, move the thread where appropriate.

I am thinking about a PXE microSD card flasher. The idea is to boot a Raspberry PI from PXE, with no microSD card. That initial network OS would wait until the user inserts a microSD WHILE THE RASPBERRY IS ALIVE AND WAITING, then the OS connects to a image repository and starts flashing the microSD card, rebooting the RPI to the microSD card when done.

I need the microSD to be initially unplugged because I need the Raspberry PI to do a PXE boot (I am talking about RPI 3B+ here) and I can not count on what could be in the microSD. After booting, I need to be able to plug the microSD with out damaging the RPI or the microSD card, in order to overwrite it.

So my question is simple: Would be electrically safe to insert a microSD card in a running (PXE booted) Raspberry PI? I would like to know about Raspberry PI 3B, 3B+ and 4B.

I am interested in the electrical aspect, not the filesystem corruption aspect.

Also, can I know that a microSD is present beside trying to read a particular sector until success?

In the same line, just out of curiosity, would it be electrically safe to unplug a microSD from a powered on RPI?. Lets suppose the tha filesystem was flushed & unmounted to avoid logical corruption.

If you have a better approach of cool suggestion, let me know.

Thanks a lot.

PS: If somebody else already did something similar, please, let me know.
The kernel drivers definitely have code that polls an empty SD card slot to determine when a card is inserted, so I expect hot-plug is an expected mode of operation. How well it actually works is a different question, as I spent about an hour yesterday looking for one of those tiny cards I had accidentally misplaced.

I imagine the setup you describe would be useful at code clubs and in student labs where people bring their own SD cards and need to format them without access to a USB card reader or other equipment before getting started.

jceajcea
Posts: 10
Joined: Sat Sep 16, 2017 9:35 pm

Re: Is hot plugging a microSD electrically safe?

Tue Jul 28, 2020 3:06 am

ejolson wrote:
Tue Jul 28, 2020 2:46 am
The kernel drivers definitely have code that polls an empty SD card slot to determine when a card is inserted, so I expect hot-plug is an expected mode of operation. How well it actually works is a different question, as I spent about an hour yesterday looking for one of those tiny cards I had accidentally misplaced.
That is useful, but I would like a more... authoritative answer :-).
ejolson wrote:
Tue Jul 28, 2020 2:46 am
I imagine the setup you describe would be useful at code clubs and in student labs where people bring their own SD cards and need to format them without access to a USB card reader or other equipment before getting started.
Indeed. Many users haven't an easy way to plug a microSD card to a regular computer and trying to explain how to use "win32imager" to a random Windows user is... challenging. My idea is that you download a PXE flasher for your OS (Windows/Linux/Mac) that will launch a local PXE boot server (Python code) and then you switch on the raspberry pi to flash. The program in the main computer would allow you to choose what image to use: OSMC, weather station, NAS, a variety of choices and configurations...

For instance, I have a backup of my parents RPI I update on home holidays. The survival time of that particular RPI is not very high, they don't pay attention, so I need to instruct them a couple of time a year about how to reflash the microSD from Windows. A pain.

In a makerspace, you could use a local PXE server and you would choose what image to flash.

In a workshop, you can tell people just to switch on their raspberries and all of them receive a PXE that runs the workshop from RAM or just overwrite the microSD with the course material.

cleverca22
Posts: 1379
Joined: Sat Aug 18, 2012 2:33 pm

Re: Is hot plugging a microSD electrically safe?

Tue Jul 28, 2020 3:36 am

for the pi4, you will likely be able to flash it over the usb-c port, using drivers for the CM4 (which arent released yet)

but that may depend on what the default eeprom image sets the boot order to, and require a more recent image, or pre-booting a recovery.bin first.....

i do like the idea of a netboot setup, where you just boot the pi with a blank card in it, then pick a distro from a UI right on the pi, and it will flash itself

User avatar
Imperf3kt
Posts: 3855
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Is hot plugging a microSD electrically safe?

Tue Jul 28, 2020 3:40 am

jceajcea wrote:
Tue Jul 28, 2020 3:06 am
Indeed. Many users haven't an easy way to plug a microSD card to a regular computer
This is very true... I'm one of them.
In order to flash a MicroSD card (which I've just had to do twice) I have to download the files to my desktop PC, put the downloaded files onto a flash drive, eject the flash drive, put the flash drive into my laptop, copy the files over, insert a SD card to MicroSD card adaptor (why does a MODERN mid range laptop have an SD card adatpor?!) and then run balena etcher.

I really should just buy a card reader, as I seem to have misplaced the two I already owned, as should anybody else. Then there is no problem, and you have an "easy way" to plug a microSD card into a "regular" computer.
55:55:44:44:4C
52:4C:52:42:41

cleverca22
Posts: 1379
Joined: Sat Aug 18, 2012 2:33 pm

Re: Is hot plugging a microSD electrically safe?

Tue Jul 28, 2020 3:44 am

Imperf3kt wrote:
Tue Jul 28, 2020 3:40 am
insert a SD card to MicroSD card adaptor (why does a MODERN mid range laptop have an SD card adatpor?!)
id prefer the laptop to have full sd, rather then microsd
you can always use an adapter to make your card bigger, but never the other way around

having uSD in the laptop, would prevent you from ever using full size SD, which i still need for the pi1's

and its not like its making the laptop bigger

ejolson
Posts: 5795
Joined: Tue Mar 18, 2014 11:47 am

Re: Is hot plugging a microSD electrically safe?

Tue Jul 28, 2020 3:59 am

Imperf3kt wrote:
Tue Jul 28, 2020 3:40 am
jceajcea wrote:
Tue Jul 28, 2020 3:06 am
Indeed. Many users haven't an easy way to plug a microSD card to a regular computer
why does a MODERN mid range laptop have an SD card adatpor?!.
I think the SD card slot on the laptop is primarily for use by people with digital cameras and camcorders. I used the slot on my laptop for additional storage until someone two-years old knocked it off the table and broke the SD card neatly into two pieces.

What I imagine is a computing lab where the network boot server is already configured and the students bring in their own SD cards, boot the Pi, insert the card and format the SD card with a new version of Raspberry Pi OS. After that, they can boot the Pi directly from their own card or place the card in a nearby robot and boot that.

Note that this isn't a full network boot configuration but just enough network boot to format the SD card. Thus, a powerful server is not needed. Another advantage is that the card can be taken home for use on the Pi at home. The disadvantage is that the card will get lost. The advantage is that if it does get lost, the student can easily bring another card and again format it without any additional equipment or help.

fruitoftheloom
Posts: 24062
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Is hot plugging a microSD electrically safe?

Tue Jul 28, 2020 7:11 am

jceajcea wrote:
Tue Jul 28, 2020 2:40 am
Hi there. Sorry if this is not the right forum area for this question. Please, move the thread where appropriate.

I am thinking about a PXE microSD card flasher. The idea is to boot a Raspberry PI from PXE, with no microSD card. That initial network OS would wait until the user inserts a microSD WHILE THE RASPBERRY IS ALIVE AND WAITING, then the OS connects to a image repository and starts flashing the microSD card, rebooting the RPI to the microSD card when done.

I need the microSD to be initially unplugged because I need the Raspberry PI to do a PXE boot (I am talking about RPI 3B+ here) and I can not count on what could be in the microSD. After booting, I need to be able to plug the microSD with out damaging the RPI or the microSD card, in order to overwrite it.

So my question is simple: Would be electrically safe to insert a microSD card in a running (PXE booted) Raspberry PI? I would like to know about Raspberry PI 3B, 3B+ and 4B.

I am interested in the electrical aspect, not the filesystem corruption aspect.

Also, can I know that a microSD is present beside trying to read a particular sector until success?

In the same line, just out of curiosity, would it be electrically safe to unplug a microSD from a powered on RPI?. Lets suppose the that filesystem was flushed & unmounted to avoid logical corruption.

If you have a better approach or cool suggestion, let me know.

Thanks a lot.

PS: If somebody else already did something similar, please, let me know.

Yes Network Booting Raspberry Pi Operating System Lite version is definitely feasible and documented:

https://www.raspberrypi.org/documentati ... des/net.md


Booting from USB MSD when inserting a SD Card it is automatically mounted, and in fact have been able to use Pi-Imager to create a bootable SD Card, so the functionality is there in the Desktop Version.


So I would presume you would need to create a GUI which has all the functionality of being able to create a bootable SD Card when a Icon is clicked on by the end user.


Nice project, and would be like a "Live Terminal" for just one purpose, though an USB SD Card Reader would be easier for inserting / removing an SD Card......
Thinking outside the box is better than burying your head in the sand...

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2437
Joined: Thu Jul 11, 2013 2:37 pm

Re: Is hot plugging a microSD electrically safe?

Tue Jul 28, 2020 7:55 am

jceajcea wrote:
Tue Jul 28, 2020 3:06 am
ejolson wrote:
Tue Jul 28, 2020 2:46 am
The kernel drivers definitely have code that polls an empty SD card slot to determine when a card is inserted, so I expect hot-plug is an expected mode of operation. How well it actually works is a different question, as I spent about an hour yesterday looking for one of those tiny cards I had accidentally misplaced.
That is useful, but I would like a more... authoritative answer :-).
MicroSD cards (and the slot on the board) are hot-pluggable.
Rockets are loud.
https://astro-pi.org

Paul Hutch
Posts: 556
Joined: Fri Aug 25, 2017 2:58 pm
Location: Blackstone River Valley, MA, USA
Contact: Website

Re: Is hot plugging a microSD electrically safe?

Tue Jul 28, 2020 1:13 pm

The power connections on a microSD card are longer to guarantee power is applied first so that there are no electrical problems when hot swapping.

rochrist
Posts: 2
Joined: Sat Aug 01, 2020 8:30 pm

Re: Is hot plugging a microSD electrically safe?

Sat Aug 01, 2020 8:36 pm

Imperf3kt wrote:
Tue Jul 28, 2020 3:40 am
jceajcea wrote:
Tue Jul 28, 2020 3:06 am
Indeed. Many users haven't an easy way to plug a microSD card to a regular computer
This is very true... I'm one of them.
In order to flash a MicroSD card (which I've just had to do twice) I have to download the files to my desktop PC, put the downloaded files onto a flash drive, eject the flash drive, put the flash drive into my laptop, copy the files over, insert a SD card to MicroSD card adaptor (why does a MODERN mid range laptop have an SD card adatpor?!) and then run balena etcher.

I really should just buy a card reader, as I seem to have misplaced the two I already owned, as should anybody else. Then there is no problem, and you have an "easy way" to plug a microSD card into a "regular" computer.
USB card readers are available that will read/write any type of card including micro cards, are reliable and cost about $10. I've got 3 of them.

NimbUx
Posts: 251
Joined: Fri Jan 03, 2020 10:33 am

Re: Is hot plugging a microSD electrically safe?

Sun Aug 02, 2020 12:45 pm

Electrically safe... which in turn begs the question : does Raspi-OS, once brought up, need access
the /boot partition in any way while running normally (except explicitly asked by a user) ?
Same question during normal shutdown.
IOW, assuming my RasPI booted using /boot from the SD card, but the rest of the system's directory tree
is hosted on a USB disc, would it be safe to remove the SD card from the USB-C slot during normal OS operation ? Would the same SD-card (with /boot) need to be re-inserted in place before shutting down ?

User avatar
rpdom
Posts: 17563
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Is hot plugging a microSD electrically safe?

Sun Aug 02, 2020 12:54 pm

NimbUx wrote:
Sun Aug 02, 2020 12:45 pm
does Raspi-OS, once brought up, need access
the /boot partition in any way while running normally
Only during apt upgrades when a new kernel or associated firmware files might need to be installed. AFAIK, other than while booting (and user editing of cmdline.txt/config.txt), that is the only time the files in /boot are accessed. You can test that by unmounting /boot after you start up your Pi and see what, if anything, fails.
Unreadable squiggle

ejolson
Posts: 5795
Joined: Tue Mar 18, 2014 11:47 am

Re: Is hot plugging a microSD electrically safe?

Sun Aug 02, 2020 2:47 pm

rochrist wrote:
Sat Aug 01, 2020 8:36 pm
Imperf3kt wrote:
Tue Jul 28, 2020 3:40 am
jceajcea wrote:
Tue Jul 28, 2020 3:06 am
Indeed. Many users haven't an easy way to plug a microSD card to a regular computer
This is very true... I'm one of them.
In order to flash a MicroSD card (which I've just had to do twice) I have to download the files to my desktop PC, put the downloaded files onto a flash drive, eject the flash drive, put the flash drive into my laptop, copy the files over, insert a SD card to MicroSD card adaptor (why does a MODERN mid range laptop have an SD card adatpor?!) and then run balena etcher.

I really should just buy a card reader, as I seem to have misplaced the two I already owned, as should anybody else. Then there is no problem, and you have an "easy way" to plug a microSD card into a "regular" computer.
USB card readers are available that will read/write any type of card including micro cards, are reliable and cost about $10. I've got 3 of them.
Right. That is almost one third the $35 cost of the Pi itself and you'd also need a extra SD card that was already bootable to get started. The original post is about formatting an SD card without additional hardware, including no additional SD card.

Using network boot at a Raspberry Jam or school computer lab to format new cards is, in my opinion, a very nice idea.

Return to “Advanced users”