Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


outdoorsnz

676 posts

Ultimate Geek


#298598 30-Jun-2022 12:56
Send private message

I run 32bit Raspberry PI OS on my 8gb RPI 4 with USB SSD (enclosure) booting.

 

The problem is that both USB3 connections are very touchy if you knock the plugged in USB 3 cable.

 

I have tried a few different cables and seems to be the USB 3 slots. Perhaps they have become a little worn with unplugging.

 

This results in having to pull the power cable. Touch wood this has not nuked my system yet. But I fully expect to get a nasty boot up one of these days.

 

I move between addresses, but at home I use a powered USB hub monitor stand to avoid this.

 

Two questions:

 

1. OS still runs with very limited options. i.e. VLC keeps playing radio streaming. Terminal bash works but command shutdown or reboot don't work. Menu etc doesn't work. Is there a manual bash command that would allow me to reboot or shutdown?

 

2. Should I try and bend the USB pins up?

 

Thanks


View this topic in a long page with up to 500 replies per page Create new topic
 1 | 2
timmmay
20591 posts

Uber Geek

Trusted
Lifetime subscriber

  #2936473 30-Jun-2022 13:42
Send private message

Might be time to replace the Pi.




outdoorsnz

676 posts

Ultimate Geek


  #2936476 30-Jun-2022 13:45
Send private message

timmmay:

 

Might be time to replace the Pi.

 

 

Maybe at some point with a 400 as the Pi Fan wine can drive you nuts!


timmmay
20591 posts

Uber Geek

Trusted
Lifetime subscriber

  #2936483 30-Jun-2022 13:48
Send private message

Mine sits in a closed cupboard in a warm room and works as a server, no fan just passive cooling in an aluminum case. Right now the Pi is 47 degrees.




roobarb
653 posts

Ultimate Geek

Trusted

  #2936491 30-Jun-2022 14:05
Send private message

Assuming Rasbian, then

 

sudo shutdown -h now

 

and

 

sudo reboot

 

are the shell command you were asking for.

 

Not sure on your setup, but if the problem is unreliable power, you could boot the RPI4 from an SD-Card with a read-only filesystem and then store your movies on the USB drive.

 

The "raspi-config" tool lets you set up a read-only filesystem so loss of power should not corrupt the SD card as it is never written to.

 

 


roobarb
653 posts

Ultimate Geek

Trusted

  #2936508 30-Jun-2022 14:14
Send private message

Replacing the PI sounds excessive if all you need is to re-install the operating system. If the USB 3 ports are truly worn out then the USB 2 ports should still be capable of streaming video.

 

https://core-electronics.com.au/guides/raspberry-pi/read-only-raspberry-pi/

 

 


outdoorsnz

676 posts

Ultimate Geek


  #2936533 30-Jun-2022 15:10
Send private message

roobarb:

 

Assuming Rasbian, then

 

sudo shutdown -h now

 

and

 

sudo reboot

 

are the shell command you were asking for.

 

Not sure on your setup, but if the problem is unreliable power, you could boot the RPI4 from an SD-Card with a read-only filesystem and then store your movies on the USB drive.

 

The "raspi-config" tool lets you set up a read-only filesystem so loss of power should not corrupt the SD card as it is never written to.

 

 

Raspberry Pi OS.

 

Not a power issue as using a proper RPI 5.1v 3A power supply. Knocking USB cable must cause drive to get disconnected.

 

The usual shutdown / reboot commands don't work. Something like command not found message.  And booting from SSD not SD card as mentioned.


outdoorsnz

676 posts

Ultimate Geek


  #2936534 30-Jun-2022 15:14
Send private message

timmmay:

 

Mine sits in a closed cupboard in a warm room and works as a server, no fan just passive cooling in an aluminum case. Right now the Pi is 47 degrees.

 

 

Going off-topic, but yes passive case could work. Though I am pushing my pi with the usual heavy desktop use and over clocked to the full spec. Hums along quite nicely.


 
 
 

Trade NZ and US shares and funds with Sharesies (affiliate link).
outdoorsnz

676 posts

Ultimate Geek


  #2936535 30-Jun-2022 15:17
Send private message

roobarb:

 

Replacing the PI sounds excessive if all you need is to re-install the operating system. If the USB 3 ports are truly worn out then the USB 2 ports should still be capable of streaming video.

 

https://core-electronics.com.au/guides/raspberry-pi/read-only-raspberry-pi/

 

 

Agree. I don't think USB 2 would give great performance for solid state drive boot. I'm hoping others have had this problem and found a solution to fix.


outdoorsnz

676 posts

Ultimate Geek


  #2936538 30-Jun-2022 15:40
Send private message

I think the below link answers my question on how to force reboot / shutdown. The important part being /sbin/...

 

https://www.linuxforfreshers.com/2020/10/inputoutput-error-how-to-reboot-or.html?m=1

 

 

 

# reboot or init 6

 

bash: /sbin/reboot: Input/output error

 

# shutdown -r now

 

bash: /sbin/shutdown: Input/output error


roobarb
653 posts

Ultimate Geek

Trusted

  #2936578 30-Jun-2022 17:17
Send private message

I would suggest backing up the files you want to keep, and reinstalling the OS from scratch and then copy back your video files etc.

 

If the operating system is hosed then there is really no point in trying to fix it when a reinstall will get you back running.

 

The reason I suggested running from from a read-only file system on an SD card is then you solve three problems..

 

1. the machine should survive removal of power without being shutdown elegantly because the SD card is much less likely to be corrupted

 

2. you separate your video and data from the operating system

 

3. the machines main operations won't be affected by problematic USB connections.

 

So I meant OS on sd-card, data on USB drive.


outdoorsnz

676 posts

Ultimate Geek


  #2936581 30-Jun-2022 17:31
Send private message

roobarb:

 

I would suggest backing up the files you want to keep, and reinstalling the OS from scratch and then copy back your video files etc.

 

If the operating system is hosed then there is really no point in trying to fix it when a reinstall will get you back running.

 

The reason I suggested running from from a read-only file system on an SD card is then you solve three problems..

 

1. the machine should survive removal of power without being shutdown elegantly because the SD card is much less likely to be corrupted

 

2. you separate your video and data from the operating system

 

3. the machines main operations won't be affected by problematic USB connections.

 

So I meant OS on sd-card, data on USB drive.

 

 

Sorry I should have said my system is fine at the moment. More trying to future proof myself as I don't like having to resort to pulling the power cord.

 

Your solution would work if I had a SD card for booting from but makes perfect sense for a SD card boot / USB data approach.


roobarb
653 posts

Ultimate Geek

Trusted

  #2936606 30-Jun-2022 18:12
Send private message

outdoorsnz:

 

Sorry I should have said my system is fine at the moment. More trying to future proof myself as I don't like having to resort to pulling the power cord

 

I would suggest it is not fine if you have to pull the power cable. The system is misconfigured and you will eventually corrupt your filesystem. If the USB drive is solid state then you may brick it. An 8 gig sd-card is only $5, that is plenty for basic raspbian given your data would be on the USB. 


fe31nz
1234 posts

Uber Geek


  #2936764 30-Jun-2022 23:26
Send private message

I have the same problem with the USB 3 ports on my RPi 4B.  I am currently booting it from a SATA SSD in a dual USB 3 mount, and the standard USB 3 cable that comes with the mount does not seem to fit well into the RPi sockets.  I had a similar problem with my data/charging cable that came with my Samsung Galaxy Tab S2 tablet - I originally thought I was having a problem with its battery as it was not charging properly.  But a new high quality cable (Pudney from JB HiFi) with a USB connector that fitted more tightly fixed that problem, so I have been thinking of getting a new USB 3 B to A cable for the RPi to see if it would fix that too.  In the past, when I have had similar problems with USB 2 DVB-T tuners on my MythTV box, I found that using a longer cable that allowed me to tape the cable down on the table at the back of the PC made things much better.  Where I have my RPi at present does not allow for trying that, and I want  the RPi to be mobile anyway.

 

It seems to me that the standard USB A sockets and the plugs that are supposed to fit in them are just made with very sloppy tolerances and do not fit well most of the time.  I suspect that the RPi 4B sockets are cheap ones and fit worse than most.

 

On the shutdown failure front, every time you fail to shut down an SSD or hard drive partition properly you risk corruption of the partition's filesystem.  With an SSD, if you power it off before shutdown is complete, there is risk of permanent damage to the SSD itself (not just the filesystems), although that is a fairly small risk in modern SSDs.  If you power off the RPi or unplug the cable to the drive, then you will have a significant risk of corruption of the filesystem.  It depends on the type of the filesystem.  For Raspbian, that is normally EXT4, which is a journalled filesystem and that is what usually saves you from massive corruption every time you fail to shut down properly.  With EXT2 before journalling, massive corruption was expected with a bad shutdown.  When things are written to a journalled filesystem, they are normally written first to a journal data area that is set aside for this purpose.  The journal is just a set of data to be written and the locations it is to be written to.  The trick with journals is that the operating system tells the journal that it has completed sending a related set of writes and the journal marks that.  Then the drive will do all the writes in that section of the journal as a group, so that they all happen or all do not happen if something goes wrong.  On boot, the system checks the journal area and if anything is waiting there that is a full set of operations, it will then be done, as a group.  Any writes that are not part of a full set will be discarded.  So the system is able to keep all the writes to update the filesystem data on the partition to extend a file, for example, as one group, and not get one update in one table done and fail to get another table updated to match.

 

However, even with the journal, every time you get a partition that was not shut down properly, you MUST, ALWAYS, run fsck -f on that partition before using it again, to fix any filesystem corruption that exists.  If there was writing going on to the partition at the time it lost power or lost the connection to the RPi, there is a very high likelihood of corruption of the filesystem.  If you fail to run fsck -f before the next time something writes to that partition, the existing corruption can propagate the damage to other places and cause permanent damage, where important things like the filesystem tables themselves can be overwritten with other data.  You can lose the entire partition.  If you always do an fsck -f before using a potentially damaged partition, you can still have files that are truncated or lost, but they will only be the files that were being written to, not other random locations on the partition.  And there is a high probability that fsck will be able to repair the filesystem.

 

As this is a well known problem, the system does try to help.  It marks any partition that has been written to as "dirty" on the first write, and on shutdown only marks it as "clean" when all the data has been written to the partition.  And it delays shutdown until all data is written.  So if you power off a drive or have it disconnected before shutdown is complete, on reboot the system will see that the partition is dirty.  And it will usually then run fsck -f automatically if it is trying to boot from that partition.  It will not necessarily do this - there is an option in fstab that controls this behaviour, but it is normally set on when a new boot partition is created.  The option is the last number on each fstab line - it should be set to 1 for a boot partition (so that boot partitions are checked first), and 2 for normal partitions.  If it is set to 0, no checking is done at boot time.

 

Even with the boot time dirty check and automatic fscks, there can be situations where it actually requires multiple fsck -f runs to fix all the errors, and it can require human decisions to get the best recovery.  Once I had to run fsck -f seven! times on the boot partition on my mother's MythTV box (Ubuntu) before all the errors were fixed.  So I highly recommend never relying on the automatic fscks at boot time, and doing all fscks manually.  To do that, you need to be able to boot to a different device or partition and use that different system to manually run fsck -f on as many times as it takes all partitions until it runs without fixing anything.  To do this, I have three different methods I use.  One is having the ability to do PXE network booting, so that I can boot from a live boot image stored on my PXE server.  The second method I use is to have a second bootable partition on a system.  That partition is not normally mounted (or is only mounted read-only) when the main boot partition is in use, so it does not get damaged in any bad shutdown.  I use grub to boot to the second boot partition and then use it to run fscks.  The third method I use is to have a USB stick that contains live boot images for the various operating systems I use.  To do that these days, the best tool I have found is Ventoy:

 

https://ventoy.net

 

Ventoy supports USB booting from a huge range of boot images (including Windows) and you can have as many images on one USB stick as will fit.  You just select which image to boot from the Ventoy menu after you boot the USB stick.  But I do not know if Ventoy itself supports booting on an RPi.  If it does not, then you would need to create a dedicated USB stick with a bootable Raspbian image on it.

 

With an external drive, you can also plug it into another PC with a compatible operating system and do the fscks there, which is what I do for my RPi.


outdoorsnz

676 posts

Ultimate Geek


  #2937868 3-Jul-2022 12:45
Send private message

@fe31NZ. Great reply. Plenty to digest.

 

fe31nz:

 

It seems to me that the standard USB A sockets and the plugs that are supposed to fit in them are just made with very sloppy tolerances and do not fit well most of the time.  I suspect that the RPi 4B sockets are cheap ones and fit worse than most.

 

I will hunt for a better fitting cable or even an adapter to make the connection tight. Looking at the USB connection just now I can see it is on a very slight angle confirming the ill fitting USB cable.

 

On the shutdown failure front, every time you fail to shut down an SSD or hard drive partition properly you risk corruption of the partition's filesystem.  With an SSD, if you power it off before shutdown is complete, there is risk of permanent damage to the SSD itself (not just the filesystems), although that is a fairly small risk in modern SSDs.  If you power off the RPi or unplug the cable to the drive, then you will have a significant risk of corruption of the filesystem.  It depends on the type of the filesystem.  For Raspbian, that is normally EXT4, which is a journalled filesystem and that is what usually saves you from massive corruption every time you fail to shut down properly.  With EXT2 before journalling, massive corruption was expected with a bad shutdown.  When things are written to a journalled filesystem, they are normally written first to a journal data area that is set aside for this purpose.

 

Where I live, the power goes out at least 5-10 times per year due to either wind, faults or maintenance. So either power forced reboot or input/output fault is quite on the cards. Worst is power flicking on/off few times in a row. Which hadskilled a few Pi OS's and maybe why a few SD-Cards no longer work at all. Wonder if any one has used a Pi Pico / ESP32 + battery power back to provide a battery backup solution if the power drops out. Will investigate that idea.

 

Will look into Ventoy and/or  tar image backup to have something to fall back to if worst case situation happens touch wood. Thanks


fe31nz
1234 posts

Uber Geek


  #2938012 4-Jul-2022 00:38
Send private message

outdoorsnz:

 

Where I live, the power goes out at least 5-10 times per year due to either wind, faults or maintenance. So either power forced reboot or input/output fault is quite on the cards. Worst is power flicking on/off few times in a row. Which has killed a few Pi OS's and maybe why a few SD-Cards no longer work at all. Wonder if any one has used a Pi Pico / ESP32 + battery power back to provide a battery backup solution if the power drops out. Will investigate that idea.

 

 

You are normally able to set up any PC BIOS to not automatically reboot after a power failure.  I am not sure about how to do that on an RPi though, but that is the best idea if you are going to get multiple short power recoveries and failures.  That situation pretty much guarantees that you will get another power failure while the system is in the middle of recovering from the previous one, which gives a very high probability of permanent corruption of your boot partition.  Even with a UPS, you probably only want the RPi to be able shut down gracefully  after a power failure, rather than keep running for very long.  UPSes that can keep things running for hours are very, very expensive.


 1 | 2
View this topic in a long page with up to 500 replies per page Create new topic





News and reviews »

Gen Threat Report Reveals Rise in Crypto, Sextortion and Tech Support Scams
Posted 7-Aug-2025 13:09


Logitech G and McLaren Racing Sign New, Expanded Multi-Year Partnership
Posted 7-Aug-2025 13:00


A Third of New Zealanders Fall for Online Scams Says Trend Micro
Posted 7-Aug-2025 12:43


OPPO Releases Its Most Stylish and Compact Smartwatch Yet, the Watch X2 Mini.
Posted 7-Aug-2025 12:37


Epson Launches New High-End EH-LS9000B Home Theatre Laser Projector
Posted 7-Aug-2025 12:34


Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.