newbiee
Posts: 9
Joined: Mon Aug 26, 2013 3:16 pm

SD Card corrupted when hdd disconnected without unmount

Sun May 04, 2014 8:02 am

Hello,

I have a RaspberryPi model B with Archlinux installed. I have the system, cache, etc. on SD card, but I also have mounted 2,5" harddrive in an external powered case. I use RaspberryPi as a NAS server to access the data on the harddrive (mounted on /mnt, samba and there is also a downloader application stored on SD card, but accessing data on HDD).

The problem is, that about once a month somebody in the house accidentally nudges (pushes) the RaspberryPi a little and because the external powered case connection is loose, the HDD disconnects.

That's fine with me, but the RaspberryPi doesn't take this well and the SD card is corrupted, so besides connecting the HDD again I have to open the rPi case and reformat the card from backup which is exhausting to do once a month..

Is it possible to somehow make the RaspberryPi to withstand the HDD disconnection loss (shut the downloaded app, samba, anything..)?

User avatar
DougieLawson
Posts: 39126
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: SD Card corrupted when hdd disconnected without unmount

Sun May 04, 2014 8:58 am

Try updating to the latest firmware with the re-written USB interface code. Hitting the HDD should just be a USB disconnection event it shouldn't crash the OS.

sudo apt-get install rpi-update
sudo rpi-update
sudo reboot
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

newbiee
Posts: 9
Joined: Mon Aug 26, 2013 3:16 pm

Re: SD Card corrupted when hdd disconnected without unmount

Sun May 04, 2014 10:03 pm

Does this apply also to Archlinux? As I said in the question above I don't use Raspbian (doesn't support applications I need).

If so, is

Code: Select all

pacman -Syu
enough?

User avatar
DougieLawson
Posts: 39126
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: SD Card corrupted when hdd disconnected without unmount

Mon May 05, 2014 9:05 am

No idea how the folks running Arch do this stuff.

I've no idea why a Linux newbie would choose Arch rather than Raspbian.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: SD Card corrupted when hdd disconnected without unmount

Mon May 05, 2014 9:36 am

I've no idea why a Linux newbie would choose Arch rather than Raspbian.
I would assume this quote answers your question:
I don't use Raspbian (doesn't support applications I need).
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: SD Card corrupted when hdd disconnected without unmount

Tue May 06, 2014 3:43 am

Yes, Pacman is our package manager in Arch. That should work, as far as using pacman for updating goes.

But here is a thought - I have had problems (although not as extreme as yours) because one of my USB sockets on my Pi is loose, and I find that if I stick a thin wooden toothpick in, it tightens the connection and makes the cable less likely to wobble. While more resilient software is good too, if you can do anything to keep the cable or connector from wobbling or coming loose, that would be a good idea as well.

Also, if formatting another card is that much hassle, having to get it set up and all that, you might make two cards at the same time so you have one ready. I understand that maybe opening up the case is a big deal, but you might not always have time to also do the formatting when that happens, and if you make a point of having a spare formatted backup card ready to use, that might make things easier if the card gets corrupted again.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

newbiee
Posts: 9
Joined: Mon Aug 26, 2013 3:16 pm

Re: SD Card corrupted when hdd disconnected without unmount

Mon Jun 16, 2014 7:29 pm

Hello,

thanks for the idea. I managed to get a new cable and HDD case - it's not loosened now, but the problem persist. I believe there is a problem with software configuration.

The harddrive is partitioned as 2* ext3 partition. It's the latest Archlinux from for rPi from this site + samba + fatrat package + all the subpackages it needs. Nothing else.

The /etc/fstab table looks like this:

Code: Select all

/dev/sda2  /mnt/myfolder    ext3    rw,sync  0  2
And I also have a graphic memory set to low (I don't use GUI, just SSH console + samba for data).

Code: Select all

gpu_mem_512=64
Any ideas why the linux crashes when HDD is forced unmount (unplugged without unmouting first)?

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: SD Card corrupted when hdd disconnected without unmount

Tue Jun 17, 2014 2:59 am

Power surge??? If you have things set up via a powered hub that back feeds power, that could do cause Pi to crash and reboot.

But you really should not be unplugging the drive without properly unmounting the file system.

If you have logging enabled, you might see the kworker or something else going nuts when the drive disappears, have you run dmesg right after an event, or looked at /var/log/everything.log?

The Pi only has so much memory and if it performing emergency rescue operations, everything else pretty much grinds to a halt, at least from what I see with my Pi.

That sync in your /etc/fstab may be part of the problem - I mean, if you unplug while it is trying to sync, not so cool. i realize these may be accidental events, but may be a recipe for trouble.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

newbiee
Posts: 9
Joined: Mon Aug 26, 2013 3:16 pm

Re: SD Card corrupted when hdd disconnected without unmount

Fri Aug 22, 2014 12:38 pm

In the end it had to be software related because I have solved the issue by switching to Raspbian (I had to find an alternative Debian-based applications for my needs).

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26660
Joined: Sat Jul 30, 2011 7:41 pm

Re: SD Card corrupted when hdd disconnected without unmount

Fri Aug 22, 2014 1:13 pm

newbiee wrote:In the end it had to be software related because I have solved the issue by switching to Raspbian (I had to find an alternative Debian-based applications for my needs).
I'm intrigued to know what package was available on Arch but not on Raspbian.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

Return to “Arch”