andrum99
Posts: 1520
Joined: Fri Jul 20, 2012 2:41 pm

Remove SD card once booted, root on hard disk

Sun Jun 30, 2013 7:55 pm

Recently I have been experimenting with putting my root filesystem on a USB attached hard disk. My system seems to run fine if I unmount the /boot partition on the SD card. In order to be sure of preventing corruption to the SD card once the Pi is booted I tried removing the SD card but apparently Raspbian doesn't like this: I get messages like this in dmesg:

Code: Select all

[  274.453957] mmc0: Timeout waiting for hardware interrupt - cmd13.
[  284.474248] mmc0: Timeout waiting for hardware interrupt - cmd13.
[  294.494551] mmc0: Timeout waiting for hardware interrupt - cmd13.
[  304.514830] mmc0: Timeout waiting for hardware interrupt - cmd13.
[  304.516014] mmc0: card 0001 removed
[  314.575143] mmc0: Timeout waiting for hardware interrupt - cmd52.
[  324.595416] mmc0: Timeout waiting for hardware interrupt - cmd52.
[  334.615705] mmc0: Timeout waiting for hardware interrupt - cmd8.
[  344.635998] mmc0: Timeout waiting for hardware interrupt - cmd5.
[  354.656339] mmc0: Timeout waiting for hardware interrupt - cmd5.
[  364.676585] mmc0: Timeout waiting for hardware interrupt - cmd5.
Is there a way I can tell Linux to disconnect or shutdown the SD card interface before I remove the card? And similarly switch it back on when I put the card back in?

Thanks

Andrew.

jawbonegroove
Posts: 37
Joined: Sun Jun 23, 2013 8:17 am
Location: pdx/usa
Contact: Website

Re: Remove SD card once booted, root on hard disk

Sun Jun 30, 2013 8:44 pm

you might do better to leave it in but just for the /boot partition, with / on your usb or hdd

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: Remove SD card once booted, root on hard disk

Mon Jul 01, 2013 6:12 am

My guess is that virtual memory is enabled and that the virtual memory manager is trying to read/write from/to a non-existent path to the swap file on the SD card after it's been removed. You may need to redirect the virtual memory manager to the path for the swap file on the hard disk drive, or you could disable virtual memory altogether if you're not using more memory than is available in physical RAM.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

andrum99
Posts: 1520
Joined: Fri Jul 20, 2012 2:41 pm

Re: Remove SD card once booted, root on hard disk

Mon Jul 01, 2013 2:27 pm

Jim Manley wrote:My guess is that virtual memory is enabled and that the virtual memory manager is trying to read/write from/to a non-existent path to the swap file on the SD card after it's been removed. You may need to redirect the virtual memory manager to the path for the swap file on the hard disk drive, or you could disable virtual memory altogether if you're not using more memory than is available in physical RAM.
When the root filesystem is moved, swap moves along with it, since it is set to use the file /var/swap. So I've done that already. Just to be 100% sure it wasn't swap I disabled swap altogether and I still get these error messages. It seems Raspbian is set up so it assumes the SD card will always be there. It would be nice if this wasn't the case.

Cheers

Andrew.

gkreidl
Posts: 6345
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Remove SD card once booted, root on hard disk

Mon Jul 01, 2013 3:13 pm

There is no reason to remove the sd card to prevent corruption, as the system does not write to the boot partition at all, except when you update the system files.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: Remove SD card once booted, root on hard disk

Tue Jul 02, 2013 6:45 pm

Sounds like the SD card is probably still mounted and there's still references to it. You need to unmount it before removing it in order to prevent any references to it remaining:

umount -l /dev/mmcblk0p1
umount -l /dev/mmcblk0p2

This can only be done after you've shifted the path to the root filesystem over to the USB hard disk via config.txt and rebooted.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

andrum99
Posts: 1520
Joined: Fri Jul 20, 2012 2:41 pm

Re: Remove SD card once booted, root on hard disk

Tue Jul 02, 2013 6:50 pm

gkreidl wrote:There is no reason to remove the sd card to prevent corruption, as the system does not write to the boot partition at all, except when you update the system files.
I'm trying to be doubly sure. Keeping the SD card powered up and active makes me nervous.

I've already unmounted all filesystems on the SD card - those messages in the kernel log are caused by something else. I guess I could just ignore them. The problem is when I plug the card back in it is not recognised, so I need to reboot the Pi to get it working. I suppose for now I will just have to leave the card in.

Thanks

Andrew.

rln
Posts: 176
Joined: Wed Apr 09, 2014 1:43 pm
Location: Sweden
Contact: Website

Re: Remove SD card once booted, root on hard disk

Thu Jun 26, 2014 11:48 am

andrum99 wrote: I've already unmounted all filesystems on the SD card - those messages in the kernel log are caused by something else. The problem is when I plug the card back in it is not recognised, so I need to reboot the Pi to get it working.
Andrew.
Hi
This issue has been fixed in the Nard SDK:
http://www.arbetsmyra.dyndns.org/nard/

If you exchange Raspbian for Nard you can remove the SD card whenever you like. Later plugging it back in works too.

/Ronny
Author of the robust Nard distro http://www.nard.se

User avatar
r3d4
Posts: 993
Joined: Sat Jul 30, 2011 8:21 am
Location: ./

Re: Remove SD card once booted, root on hard disk

Thu Jun 26, 2014 2:33 pm

rln wrote: Hi
This issue has been fixed in the Nard SDK:
http://www.arbetsmyra.dyndns.org/nard/

If you exchange Raspbian for Nard you can remove the SD card whenever you like. Later plugging it back in works too.

/Ronny
Do you happen no know HOW it was fixed ? in this alt distro ?? then perhaps the sloution could be applyed to other setups !!!!
Real life is, to most, a long second-best, a perpetual compromise between the ideal and the possible.
-
Meanwhile, the sysadmin who accidentally nuked the data reckons "its best not run anything more with sudo today"
-
what about spike milligan?

kscho8064
Posts: 1
Joined: Wed Apr 04, 2018 1:28 am

Re: Remove SD card once booted, root on hard disk

Wed Apr 04, 2018 1:31 am

On the kernel 4.14.31 could auto detecting card remove and insert !

User avatar
HawaiianPi
Posts: 6523
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Remove SD card once booted, root on hard disk

Wed Apr 04, 2018 9:49 am

And yet another obsolete thread is resurrected from the dead.
Necro.jpg
Necro.jpg (35.04 KiB) Viewed 6303 times
On current versions of Raspbian you can USB boot non-Pi3 models using a FAT32 SD card with only bootcode.bin on it. The SD card will not be subject to wear because it is not written to by the OS (the OS doesn't use the card after the USB drive boots, and only reads from it prior to that).
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups, and where is that annoying music coming from?

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: Remove SD card once booted, root on hard disk

Wed Apr 04, 2018 10:22 am

And, just for the sake of completeness, if you boot from a USB device you can "hot plug" SD cards just like you can on PC hardware. The green LED flashes once a second when the SD card slot is polled for an inserted card.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Heater
Posts: 18622
Joined: Tue Jul 17, 2012 3:02 pm

Re: Remove SD card once booted, root on hard disk

Wed Apr 04, 2018 11:04 am

I see no problem with an old thread being resurrected.

The question is still valid. The answer needed updating in light of recent developments.
Memory in C++ is a leaky abstraction .

Return to “General discussion”