LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 07-17-2023, 04:37 AM   #1
dwawlyn
LQ Newbie
 
Registered: Jul 2023
Posts: 5

Rep: Reputation: 0
Advice? External USB harddrive accidentally unplugged (no activity at time). Re-plugged, but mountpoint/findmnt/lsblk disagree if mounted?


[sorry, brand-new user, not sure how to format/tag]


So I just accidentally bumped and and unplugged the cable on an external USB harddrive.


- There was no activity at the time.

- It's btrfs


---
I just plugged it back in, and...

- `mountpoint [[path]]` #=> "`[[path]] is a mountpoint`"

- `lsblk` doesn't show it as having a mountpoint

- `findmnt` #=>
Code:
```
TARGET    	SOURCE                             	FSTYPE	OPTIONS                                                                                  	
/         	/dev/sda3[/@/.snapshots/1/snapshot]	btrfs 	rw,relatime,ssd,discard=async,space_cache=v2,subvolid=266,subvol=/@/.snapshots/1/snapshot	
[...]     	                                   	      	                                                                                         	
[...]     	                                   	      	                                                                                         	
[...]     	                                   	      	                                                                                         	
└─[[path]]	/dev/sdb1                          	btrfs 	ro,nosuid,nodev,relatime,space_cache,subvolid=5,subvol=/                                 	
```
- but
` sudo ls [[path]]`
#=>
`ls: reading directory '[[path]]': Input/output error`


---
What should I do/check?

Like, I am *aware* of `fsck`,
but I don't know anything specific about how/why to use it...?

Basically, what are my unknown-unknowns here?
 
Old 07-17-2023, 06:17 AM   #2
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: One main distro, & some smaller ones casually.
Posts: 5,773

Rep: Reputation: Disabled
After plugging it in, run

Code:
sudo demesg|tail
To find what the system has designated it, /dev/sd?

Then hopefully you can just remount it.

(Otherwise, a reboot should remount it.)
 
Old 07-18-2023, 11:19 PM   #3
dwawlyn
LQ Newbie
 
Registered: Jul 2023
Posts: 5

Original Poster
Rep: Reputation: 0
Thank you,
but by the time I got your reply I had already just done `umount [mountpoint]`
and that solved it and everything seems fine.
(Didn't even need to reboot.)

(
Although I think I was a bit less clear than I should've been that I meant to ask like:
I *assume* I can just umount it,
or at the worst reboot,
but I figured I should first check in case someone went like:
Quote:
no! don't reboot yet!
first you should [do X] because [arcane cache/journaling details]!
)
 
Old 07-19-2023, 04:09 AM   #4
selfprogrammed
Member
 
Registered: Jan 2010
Location: Minnesota, USA
Distribution: Slackware 13.37, 14.2, 15.0
Posts: 687

Rep: Reputation: 158Reputation: 158
When the USB got pulled, the USB system got notified of the loss and udev would have torn down the
the associated system hooks, like a mount.
So it became unmounted.

** It was not cleanly unmounted.
Pending operations may have been sitting in disk cache, and not written out to the drive.
There is a timer on these pending operations, which is set to a few seconds, but they could
be left pending for an unknown amount of time.

If the machine was idle for even a minute since the last use of that drive, it is
likely that all pending operations were actually committed to the drive, at the time
it got unplugged. However, the system does not know this and the drive is still marked as
not being cleanly unmounted.
There is also no guarantee of this, depending on who wrote the btrfs filesystem driver.

Usually the system knows this the next time it is mounted, and will complain at you.
It wants to check the drive filessystem for errors. Especially as some of the pending writes
to the drive can have possibly been directory writes.

I do not have btrfs installed so I was unable to check if it installs all the programs.
Look under /sbin for fsck programs.

>> ls /sbin/fsck*
See if there is one for btrfs (such as fsck.btrfs).
If there is then you unmount your btrfs drive, and then run a fsck on it.

Read the man page for the fschk first, as fsck may ask you questions,
or expect you to give it switches.
>> man fsck

Some of the usual switches
-a : automatic repair, no questions (fsck.msdos)
-p : automatic repair, no questions (fsck.ext2)
-y : answer yes to all questions
-n : make no changes to the filesystem (just checking)
-f : force checking even if the filesystem if marked clean
-v : verbose

If the filesystem has been re-mounted, and marked clean by the system, then fsck will try to skip the checking (which is lengthy).
That is because this fsck may be invoked for all devices on a system, or by other indirections.
There may still be undiscovered inconsistencies.
Use the -f to force it to do the checking, when you know it needs to be checked (like what happened here).

Of course, only root usually has access to files in /sbin, so it is not in the usual user PATH.
But /sbin/fsck might work for drives that are usually mounted by a user, which depends on device permissions, (so just try it).

# For whatever dev your btrfs drive shows up at.
>> /sbin/fsck.btrfs -f -v /dev/sdc4

Otherwise you can check for other btrfs support.
>> man btrfs

>> ls /sbin/*btr*

Last edited by selfprogrammed; 07-19-2023 at 04:17 AM.
 
1 members found this post helpful.
  


Reply

Tags
btrfs, externalharddrive, fsck, mounting, usb


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] umount said /dev/sdd is not mounted; yet lsblk said it is mounted to /run/media/ ? andrewysk Linux - Newbie 8 05-29-2021 05:29 PM
How to differentiate a mounted usb stick vs plugged in but not mounted usb stick. andrewysk Linux - Newbie 22 04-05-2021 03:42 PM
A puzzling problem: Gparted and my file manager disagree about how much empty space there is on my harddrive. g_s Linux - General 4 08-27-2019 08:02 PM
mount vs findmnt, how is findmnt more robust? ericsimard Linux - General 3 02-02-2019 06:34 AM
Computer crashes when network plugged/unplugged qscomputing Linux - General 1 05-01-2006 02:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 02:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration