Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: boudinec on February 28, 2017, 09:52:21 AM

Title: Raspberry unplug without poweroff
Post by: boudinec 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
Title: Re: Raspberry unplug without poweroff
Post by: polikuo 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.
Title: Re: Raspberry unplug without poweroff
Post by: boudinec 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).
Title: Re: Raspberry unplug without poweroff
Post by: curaga on February 28, 2017, 02:07:44 PM
The card should be unmounted, load the extensions to RAM.
Title: Re: Raspberry unplug without poweroff
Post by: boudinec 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?
Title: Re: Raspberry unplug without poweroff
Post by: bmarkus 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.
Title: Re: Raspberry unplug without poweroff
Post by: curaga on March 01, 2017, 03:46:29 AM
Mounting read-only can still corrupt some SD cards.
Title: Re: Raspberry unplug without poweroff
Post by: boudinec 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
Title: Re: Raspberry unplug without poweroff
Post by: Juanito 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.
Title: Re: Raspberry unplug without poweroff
Post by: Rich 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.
Title: Re: Raspberry unplug without poweroff
Post by: boudinec 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?
Title: Re: Raspberry unplug without poweroff
Post by: boudinec 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.
Title: Re: Raspberry unplug without poweroff
Post by: curaga on March 01, 2017, 02:11:57 PM
No conflict unless you have scripts that expect it to be mounted.
Title: Re: Raspberry unplug without poweroff
Post by: boudinec on March 01, 2017, 04:06:50 PM
Great
Thanks a lot for the help
Title: Re: Raspberry unplug without poweroff
Post by: Greg Erskine 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
Title: Re: Raspberry unplug without poweroff
Post by: boudinec on March 02, 2017, 03:41:20 AM
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

Hi Greg.

Thanks for the info, this is a good thing to know.

My concern is not about the time it takes to create a new sd card but more about the reliability and the physical access : one of my RPi is used for local control of some equipment and is bundled inside of it. So its access is a bit annoying.

Regards
Title: Re: Raspberry unplug without poweroff
Post by: mocore on March 02, 2017, 06:37:56 AM
access is a bit annoying.

Perhaps an 'SD card Extension Cable' could `fix` that ?