WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Raspberry unplug without poweroff  (Read 6051 times)

Offline boudinec

  • Newbie
  • *
  • Posts: 15
Raspberry unplug without poweroff
« on: February 28, 2017, 09:52:21 AM »
Hello

I am using some Rasperry Pi running piCore in such conditions that the power supply can be turned-off without being able to call poweroff or shutdown before.
I know this is a bad idea with raspbian, but is it dangerous to do this with piCore? Is there any risk to damage the SD card?

Regards

Cedric

Online polikuo

  • Hero Member
  • *****
  • Posts: 717
Re: Raspberry unplug without poweroff
« Reply #1 on: February 28, 2017, 10:23:49 AM »
If you do not need to backup anything, then yes, it is safe to unplug the power cable.
If you have a persistent directory  (/home, /opt) on the USB or SD card, then no, it might damage your card.

Offline boudinec

  • Newbie
  • *
  • Posts: 15
Re: Raspberry unplug without poweroff
« Reply #2 on: February 28, 2017, 12:25:01 PM »
Thanks for the answer.
I have some scripts running that are packaged in tcz files thus I never mount /home or /opt.
Mount gives me the following :
Code: (bash) [Select]
tmpfs on / type tmpfs (rw,relatime,size=400520k)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000)
tmpfs on /dev/shm type tmpfs (rw,relatime)
/dev/mmcblk0p2 on /mnt/mmcblk0p2 type ext4 (rw,relatime,data=ordered)
/mnt/mmcblk0p2/tce/optional/mc.tcz on /tmp/tcloop/mc type squashfs (ro,relatime)
...
/mnt/mmcblk0p2/tce/optional/libgpg-error.tcz on /tmp/tcloop/libgpg-error type squashfs (ro,relatime)

Is it safe even if some partitions are mounted in rw mode (/mnt/mmcblk0p2 for instance).

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Raspberry unplug without poweroff
« Reply #3 on: February 28, 2017, 02:07:44 PM »
The card should be unmounted, load the extensions to RAM.
The only barriers that can stop you are the ones you create yourself.

Offline boudinec

  • Newbie
  • *
  • Posts: 15
Re: Raspberry unplug without poweroff
« Reply #4 on: February 28, 2017, 03:06:33 PM »
The card should be unmounted, load the extensions to RAM.

Is there any way to configure piCore to do this automatically ?
As long as there are no write access to /mnt/mmcblk0p2, could it be mounted in ro mode at starup? And then pass from rw to ro (and vice-versa) when needed?

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Raspberry unplug without poweroff
« Reply #5 on: February 28, 2017, 10:18:18 PM »
Is there any way to configure piCore to do this automatically ?
As long as there are no write access to /mnt/mmcblk0p2, could it be mounted in ro mode at starup? And then pass from rw to ro (and vice-versa) when needed?

Create a file copy2fs.flg in /mnt/mmcblk0p2/tce If it exists extensions will be copied to RAM and mmcblk0p2 unmounted. Content of file is not important, it can be zero length.

If you are not using the partition, better to unmount.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Raspberry unplug without poweroff
« Reply #6 on: March 01, 2017, 03:46:29 AM »
Mounting read-only can still corrupt some SD cards.
The only barriers that can stop you are the ones you create yourself.

Offline boudinec

  • Newbie
  • *
  • Posts: 15
Re: Raspberry unplug without poweroff
« Reply #7 on: March 01, 2017, 04:59:20 AM »

Create a file copy2fs.flg in /mnt/mmcblk0p2/tce If it exists extensions will be copied to RAM and mmcblk0p2 unmounted. Content of file is not important, it can be zero length.

If you are not using the partition, better to unmount.

Thanks. I'll try this.
If in any case I want install some packages with tce: sould I just manually mount and unmount mmcblk0p2 or will it be automatic ?

Mounting read-only can still corrupt some SD cards.
I done a couple of internet searches on a subject and my idea is not very about this subject. Do you have some interesting links to about this?

Thanks again for the help

Cedric

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14798
Re: Raspberry unplug without poweroff
« Reply #8 on: March 01, 2017, 06:07:06 AM »
If in any case I want install some packages with tce: sould I just manually mount and unmount mmcblk0p2 or will it be automatic ?

It will not be automatic, you will need to mount the partition with your tce folder on, load the required extensions (with the copy2fs flag set) and then umount the partition.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11590
Re: Raspberry unplug without poweroff
« Reply #9 on: March 01, 2017, 10:09:49 AM »
Hi boudinec
Quote
If in any case I want install some packages with tce: sould I just manually mount and unmount mmcblk0p2 or will it be automatic ?
If those packages are the packaged scripts you referred to above you can add the package names to  tce/onboot,lst. Then
they will load automatically when you boot.

Offline boudinec

  • Newbie
  • *
  • Posts: 15
Re: Raspberry unplug without poweroff
« Reply #10 on: March 01, 2017, 11:38:41 AM »
Create a file copy2fs.flg in /mnt/mmcblk0p2/tce If it exists extensions will be copied to RAM and mmcblk0p2 unmounted. Content of file is not important, it can be zero length.

I created /mnt/mmcblk0p2/tce/copy2fs.flg.
When I boot, mount gives me:
Code: (bash) [Select]
tmpfs on / type tmpfs (rw,relatime,size=400516k)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000)
tmpfs on /dev/shm type tmpfs (rw,relatime)
/dev/mmcblk0p2 on /mnt/mmcblk0p2 type ext4 (rw,relatime,data=ordered)

So /mnt/mmcblk0p2 is still mounted, so I added at the end of /opt/bootlocal.sh:
Code: (bash) [Select]
umount /mnt/mmcblk0p2Is there any risk of conflct with something else?

Offline boudinec

  • Newbie
  • *
  • Posts: 15
Re: Raspberry unplug without poweroff
« Reply #11 on: March 01, 2017, 11:43:02 AM »
Hi boudinec
Quote
If in any case I want install some packages with tce: sould I just manually mount and unmount mmcblk0p2 or will it be automatic ?
If those packages are the packaged scripts you referred to above you can add the package names to  tce/onboot,lst. Then
they will load automatically when you boot.

This is what I actually do, my scripts are in a tcz referenced in onboot.lst as well as its dependencies.
Theoretically, I do not need to install more packages. But, this is theory, I can need to install some package for maintenance purpose: so I will manually handle the mmc mounting.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Raspberry unplug without poweroff
« Reply #12 on: March 01, 2017, 02:11:57 PM »
No conflict unless you have scripts that expect it to be mounted.
The only barriers that can stop you are the ones you create yourself.

Offline boudinec

  • Newbie
  • *
  • Posts: 15
Re: Raspberry unplug without poweroff
« Reply #13 on: March 01, 2017, 04:06:50 PM »
Great
Thanks a lot for the help

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: Raspberry unplug without poweroff
« Reply #14 on: March 01, 2017, 04:31:51 PM »
hi boudinec,

We are using piCore for piCorePlayer with hundreds of users, many just pull the power to turn the player off. They have been doing this for 3 or 4 years and to-date we haven't had complaints about corrupted SD cards. I haven't seen one personally. After the initial setup we don't write to the SD card.

We use the standard setup with /opt and /home in RAM and haven't found it necessary to copy to RAM or unmount mmcblk0p2, though technically is the right thing to do.

So the standard setup has proven extremely reliable.

The other thing, if you somehow manage to corrupt the SD card, the image is so small it takes very little time to burn a new one, in our case less than 10 seconds. This is a feature that should be shouted from the roof tops.

regards
Greg