we shouldn't shut down by unplugging, but what about live sessions?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
we shouldn't shut down by unplugging, but what about live sessions?
I learned as a child that it's not a good idea to shut down by just unplugging. But I think when I learned that, the sources suggested it could harm files. I don't remember whether anyone said it could harm hardware as well.
I am considering this specific situation: I was doing something quick on my laptop that my desktop wasn't set up for, using a live session. Loaded into the RAM from a flash drive. I made some files in the session and moved them onto another stick that was plugged in. Once finished, I was ready to shut it down. After hesitating a second, I just shrugged and pulled the plug--it was a bit quicker than waiting for the shutdown routine. Should I not have done that, even considering that it was just a live session about to vanish forever, and I had saved the files on a flash drive?
I learned as a child that it's not a good idea to shut down by just unplugging. But I think when I learned that, the sources suggested it could harm files. I don't remember whether anyone said it could harm hardware as well.
I am considering this specific situation: I was doing something quick on my laptop that my desktop wasn't set up for, using a live session. Loaded into the RAM from a flash drive. I made some files in the session and moved them onto another stick that was plugged in. Once finished, I was ready to shut it down. After hesitating a second, I just shrugged and pulled the plug--it was a bit quicker than waiting for the shutdown routine. Should I not have done that, even considering that it was just a live session about to vanish forever, and I had saved the files on a flash drive?
As long as you eject the stick you store the files on first you are ok. Without ejecting you take the chance the files have not been fully written to the stick before the power to it goes away.
The live operating system on a flash drive is basically the same as a CD/DVD i.e. ISO9600 read only so it should be fine with unplugging.
However, the data drive is another matter. As posted since both read/write operations are cached there could be but probably unlikely in your case on the assumption the files were not large still some writing done in the background.
I learned as a child that it's not a good idea to shut down by just unplugging.
Children today, yikes. I was a kid in the DOS days (when no such thing existed). One of the most annoying things when win95 came around was "shutting down", like wtf is that all about, why can't I just turn it off! They even managed to hijack the power-off button on many computers that made it shutdown instead of just power off.
Yes, live system you can just power off, if yer talking about the live environment on most distros install iso.
I remember having to park the hard disk drive heads before powering off in DOS... but yes the concept of "shutting down" was unknown in MS OS before Windows 95 as far as I can recall...
The computer buffers data in memory in a strategy known as "lazy writing." If you're busy writing or updating a file, the computer knows that it is very likely that you will make another change at or near the same area. So, it makes those changes in the buffer before "lazily" writing it to disc in the background.
In Unix/Linux, the sync command forces all of those lazy writes to occur before the command completes. I think that it's a good idea to end scripts which do a lot of file updates or copying with a call to that command. Upon return, there is no un-written data in any disk I/O buffer. Sometimes this command will take a human-noticeable amount of time to complete, especially in the case of USB-connected storage devices which are usually "capacious, but slow."
It is therefore very important that you "eject" an external storage device before removing it, and to make sure that any lights have stopped blinking for several seconds. Other people here have very recently reported that they did this, then "quickly" removed the device, only to discover the hard way that I/O write activity was still in progress. (And the data was lost or corrupted.) Obviously it should not be that way – but it might be. Therefore, explicitly eject or dismount the drive, then wait several seconds more after the lights stop blinking.
"Shutting down" first gives all active processes a signal that the system is about to shut down. They should respond to that signal by closing all of their files and otherwise putting their earthly affairs in order, then terminate themselves. The OS will wait a little while to give all of them the opportunity to do that before finally signaling the motherboard to turn off the power. If you simply "yank the plug," the state of the system at the next power-on is unpredictable, and any final disk-writes didn't happen. It's especially problematic if a disk write was happening at that instant, because this can leave a "magnetic smear" on a spinning disk.
Last edited by sundialsvcs; 10-19-2021 at 08:28 AM.
I don't remember whether anyone said it could harm hardware as well.
Back in the early days of the home PC ... if you had a hard drive, you'd have to issue a command to "park" the hard drive. Doubly true if you had to move the computer. If you powered off the PC without parking, the head could scrape and damage the platters. Power outages were a scary thing back then.
It is therefore very important that you "eject" an external storage device before removing it, and to make sure that any lights have stopped blinking for several seconds. Other people here have very recently reported that they did this, then "quickly" removed the device, only to discover the hard way that I/O write activity was still in progress. (And the data was lost or corrupted.) Obviously it should not be that way – but it might be. Therefore, explicitly eject or dismount the drive, then wait several seconds more after the lights stop blinking.
As an addendum, you can issue the 'sync' command to force the OS to write everything. Once it returns, you can be sure your data is written. Great for personal systems, but I understand you don't want to make this habit on a busy server, as it may cause I/O delays as the server continues to process other commands.
I use a laptop with a replacement ac cord that isn't the exact spec of the original. It works but only at a very specific level of insertion and wiggle.
For this the power fails all the time.
In LIVE mode the biggest problem is losing my place. What exactly was I doing again? What files did I have open? I wouldn't want a read-write in process on a mounted partition.
There is trouble with save/persistent files in use, but in a good os even they are recoverable.
High-capacity servers routinely use a variety of I/O technologies such as "NAS = Network-Attached Storage," and of course always have highly reliable power supplies.
I use a laptop with a replacement ac cord that isn't the exact spec of the original. It works but only at a very specific level of insertion and wiggle
This just sounds silly. Do you not have the original cord you can cut the connector from and attach to your replacement? Just an idea...
This just sounds silly. Do you not have the original cord you can cut the connector from and attach to your replacement? Just an idea...
Not to mention, if the power jack doesn't fit correctly, does the power brick have the correct voltage and amperage rating? I would say polarity too, but if it powers on, it must be correct. If the voltage/amperage rating isn't right, it can burnout the power brick and release a sweat carcinogenic plastic smell.
As an addendum, you can issue the 'sync' command to force the OS to write everything. Once it returns, you can be sure your data is written. Great for personal systems, but I understand you don't want to make this habit on a busy server, as it may cause I/O delays as the server continues to process other commands.
Interesting...then should I do this, just to make sure all data has been written? This [I]is[I] a personal system...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.