WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: OK to pull out memory card once the system boots up?  (Read 8203 times)

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
OK to pull out memory card once the system boots up?
« on: July 06, 2020, 05:12:39 PM »
Hi,

As I understand the bootable media is essentially unmounted after boot up. Is it safe to pull out the sd card at this time?

I am aware that no writes are supposed to happen to the bootable media, so there is nothing in the disk cache waiting to be written at all.

Do I still risk corrupting my SD card when pulling it out after boot up? If yes, what's the recommended way to do so?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: OK to pull out memory card once the system boots up?
« Reply #1 on: July 06, 2020, 05:50:49 PM »
Hi ashfame
... As I understand the bootable media is essentially unmounted after boot up. ...
Partition #1 which contains the boot files gets unmounted. Partition #2 contains your  tce  directory which contains your extensions. It
does not get unmounted. For that, you need to:

1. You need to have a  copy2fs.flg  file in your tce directory.
2. You need to unmount it yourself.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: OK to pull out memory card once the system boots up?
« Reply #2 on: July 07, 2020, 12:54:10 AM »
Gotcha! Do you know where the command for unmounting first partition is?

And should I unmount second partition from /opt/bootlocal.sh script or somewhere else?

Also, as long as all partitions are unmounted, it's completely safe to pull out the memory card? I wonder why full-fledged linux OS always have two options - unmount & eject. I understand eject can additionally unmount other partitions as well and force the disk cache to dump its content on to the physical disk. but how does that translate into TC context?

Offline xor

  • Hero Member
  • *****
  • Posts: 1259
« Last Edit: October 27, 2022, 08:07:40 PM by Rich »

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: OK to pull out memory card once the system boots up?
« Reply #4 on: July 07, 2020, 01:16:23 AM »
http://wiki.tinycorelinux.net/doku.php?id=wiki:remastering_with_ezremaster#options_for_adding_extensions_to_your_remaster

Hi xor, I have read that section before.

Are you stating I should use "Extract TCZ to in to initrd" option in remaster so that my extensions are autoloaded? I think I will still have to unmount the second partition unless I put everything on a single partition in my remaster.

Or are you stating using the copy2fs.flg file, it will unmount the second partition as well?

Please clarify.
« Last Edit: October 27, 2022, 08:08:03 PM by Rich »

Offline xor

  • Hero Member
  • *****
  • Posts: 1259
Re: OK to pull out memory card once the system boots up?
« Reply #5 on: July 07, 2020, 01:35:40 AM »
Unless you write the script you think
I cannot fully understand you and make a correct comment

http://wiki.tinycorelinux.net/doku.php?id=wiki:remastering_with_ezremaster#options_for_adding_extensions_to_your_remaster

Hi xor, I have read that section before.

Are you stating I should use "Extract TCZ to in to initrd" option in remaster so that my extensions are autoloaded? I think I will still have to unmount the second partition unless I put everything on a single partition in my remaster.

Or are you stating using the copy2fs.flg file, it will unmount the second partition as well?

Please clarify.
« Last Edit: October 27, 2022, 08:08:39 PM by Rich »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: OK to pull out memory card once the system boots up?
« Reply #6 on: July 07, 2020, 03:45:53 AM »
Also, as long as all partitions are unmounted, it's completely safe to pull out the memory card? I wonder why full-fledged linux OS always have two options - unmount & eject. I understand eject can additionally unmount other partitions as well and force the disk cache to dump its content on to the physical disk. but how does that translate into TC context?

Yes, it would be safe to remove the sd card - do this:
Code: [Select]
$ sync
$ sudo umount /mnt/mmcblk0p2

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: OK to pull out memory card once the system boots up?
« Reply #7 on: July 07, 2020, 04:37:40 AM »
Yes, it would be safe to remove the sd card - do this:
Code: [Select]
$ sync
$ sudo umount /mnt/mmcblk0p2

Makes sense, but I thought TinyCore will only read from both the partitions and never write unless we explicitly tell it to save the state persistently. So, we won't have any remaining writes in the disk cache ever as its only being read from. Correct? That would mean, we don't need sync, just unmount it.

Just trying to understand the internals clearly :)


Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: OK to pull out memory card once the system boots up?
« Reply #8 on: July 07, 2020, 04:49:23 AM »
You could almost certainly do without sync.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: OK to pull out memory card once the system boots up?
« Reply #9 on: July 07, 2020, 05:15:36 AM »
You could almost certainly do without sync.
ok great, thank you!

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: OK to pull out memory card once the system boots up?
« Reply #10 on: July 07, 2020, 05:16:23 AM »
Unless you write the script you think
I cannot fully understand you and make a correct comment

http://wiki.tinycorelinux.net/doku.php?id=wiki:remastering_with_ezremaster#options_for_adding_extensions_to_your_remaster

Hi xor, I have read that section before.

Are you stating I should use "Extract TCZ to in to initrd" option in remaster so that my extensions are autoloaded? I think I will still have to unmount the second partition unless I put everything on a single partition in my remaster.

Or are you stating using the copy2fs.flg file, it will unmount the second partition as well?

Please clarify.

Sorry, I was just trying to understand why you pointed me towards that link in the context of the question asked.
« Last Edit: October 27, 2022, 08:07:03 PM by Rich »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: OK to pull out memory card once the system boots up?
« Reply #11 on: July 07, 2020, 09:39:47 AM »
Hi ashfame
The  umount  command will refuse to unmount a "device" if its filesystem is in use:

1. If you open a file with an editor or the  less  command, that filesystem is in use.
2. If you execute  cd /mnt/mmcblk0p2  in a terminal, that filesystem is in use.
3. If you are using a file manager to look at a directory, that filesystem is in use.

If you try to unmount a filesystem that is in use, you will receive a  target is busy  error message.

That brings us to  umount  and  sync. You don't need sync. The umount command waits for writes to complete. I put together a little
slideshow to demonstrate. Each image contains 2 terminals. The top terminal monitors whether the device is busy (1) or not (0).
The bottom terminal shows the commands as I executed them.

Start: The device is not busy (0). No commands have been given yet.


Copy: We copy a large file (~100 Mbytes) to a USB thumb drive. The device is busy (1). Notice the command prompt has returned
          even though the copy command has not completed.


Unmount: We issue a  umount  command. The device is still busy (1) because it is still being written to. Notice the command prompt
               has NOT returned because the  umount  command has not completed. It will be blocked until all pending writes are
               completed.


Done: The device is no longer busy (0) and the  umount  command completes.

« Last Edit: July 07, 2020, 09:41:31 AM by Rich »

Offline xor

  • Hero Member
  • *****
  • Posts: 1259
Re: OK to pull out memory card once the system boots up?
« Reply #12 on: July 07, 2020, 10:03:23 AM »
I am writing on google translate,

Unless you write the script you think
I cannot fully understand you and make a correct comment

http://wiki.tinycorelinux.net/doku.php?id=wiki:remastering_with_ezremaster#options_for_adding_extensions_to_your_remaster

Hi xor, I have read that section before.

Are you stating I should use "Extract TCZ to in to initrd" option in remaster so that my extensions are autoloaded? I think I will still have to unmount the second partition unless I put everything on a single partition in my remaster.

Or are you stating using the copy2fs.flg file, it will unmount the second partition as well?

Please clarify.

Sorry, I was just trying to understand why you pointed me towards that link in the context of the question asked.
« Last Edit: October 27, 2022, 08:06:17 PM by Rich »

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: OK to pull out memory card once the system boots up?
« Reply #13 on: July 07, 2020, 10:31:55 AM »
I put together a little slideshow to demonstrate. Each image contains 2 terminals. The top terminal monitors whether the device is busy (1) or not (0). The bottom terminal shows the commands as I executed them.

Thanks a lot for going to that length of explaining it. This really explains it :)

Unmount all partitions and they will finish the writes to physical disk and only then return. Brilliant! So one only needs to care about all partitions being unmounted & it can be ejected. Thanks again!

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: OK to pull out memory card once the system boots up?
« Reply #14 on: July 07, 2020, 10:32:50 AM »
I am writing on google translate

Thanks anyway! :)