You are not logged in.

#1 2023-12-26 19:13:57

PandaSoli
Member
Registered: 2023-10-11
Posts: 7
Website

[SOLVED] Handle Flash drivers

Hey guys, recently I've lost all my flash drivers' data when dealing with it.
I noticed the problem was probably the way I do it when I had the same problem on Gentoo (at first I was trying on Arch).

So, this is the way I manually plug and unplug my flash drive, do you see any problem?

On Plug

mount /dev/sdX /mnt/flashdrive1

Before Physically Unplug

umount /mnt/flashdrive1
eject /dev/sdX

Last time I formatted it and put some files, I didn't lost them because I didn't use eject.
Btw, I think I "lost" them because when I replug it, lsblk doesn't detect any partition.

Last edited by PandaSoli (2023-12-27 15:50:51)

Offline

#2 2023-12-26 19:31:59

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Handle Flash drivers

eject(1) wrote:
NOTES
       eject only works with devices that support one or more of the four methods of ejecting. This
       includes most CD-ROM drives (IDE, SCSI, and proprietary), some SCSI tape drives, JAZ drives, ZIP
       drives (parallel port, SCSI, and IDE versions), and LS120 removable floppies.

For USB sticks only the `umount` command is needed before removing the device.

USB sticks are frangible by nature, especially if you bought a cheap one, so it probably just wore out.


Jin, Jîyan, Azadî

Offline

#3 2023-12-26 19:54:34

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,048

Re: [SOLVED] Handle Flash drivers

Btw, I think I "lost" them because when I replug it, lsblk doesn't detect any partition.

Run "dmesg -w", plug  in the drive and post the tail dmesg produced.
Also (afterwards)

lsblk -f
fdisk -l /dev/sdX # replace the X w/ the actual device

But that't not a symptom of an unclean retraction, but rather a dying flash drive…

Offline

#4 2023-12-26 20:28:36

PandaSoli
Member
Registered: 2023-10-11
Posts: 7
Website

Re: [SOLVED] Handle Flash drivers

Thank you very much @Head_on_a_Stick!
I'll take more care about man's notes section from now on.
@seth Not gonna relost my data to test it bro hahaha it just got solved. And thank you for helping too!

Last edited by PandaSoli (2023-12-26 20:31:23)

Offline

#5 2023-12-27 02:27:42

mpan
Member
Registered: 2012-08-01
Posts: 1,599
Website

Re: [SOLVED] Handle Flash drivers

Head_on_a_Stick wrote:
eject(1) wrote:
NOTES
       eject only works with devices that support one or more of the four methods of ejecting. This
       includes most CD-ROM drives (IDE, SCSI, and proprietary), some SCSI tape drives, JAZ drives, ZIP
       drives (parallel port, SCSI, and IDE versions), and LS120 removable floppies.

For USB sticks only the `umount` command is needed before removing the device.

Contrary to the name, eject command’s operation is not limited to physically ejectable media. It combines multiple operations, which have a similar human-observable effect. Among these are USB mass storage devices, which eject shuts down. This is what “safely remove” features do in desktop environments. In the very first line of the description (emphasis added):

eject(1) wrote:

eject allows removable media (typically a CD-ROM, floppy disk, tape, JAZ, ZIP or USB disk) to be ejected under software control.

What isn’t needed, is the umount command: eject performs unmounting, if neccessary.


PandaSoli claims it’s solved, but I don’t see how. I also don’t know, how the data is going to be “relost” by reading the stick. I agree with seth, that it looks like a dying USB stick.

Last edited by mpan (2023-12-27 02:29:13)


Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#6 2023-12-27 10:21:11

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Handle Flash drivers

I am prepared to accept that failure to pass the eject command might cause issues with a USB-connected powered spinning rust drive but I find it doubtful that the same would apply to an unpowered USB stick, which is what this thread is about.

The thread is [SOLVED] because the OP was asking if they did anything wrong, which they did not.


Jin, Jîyan, Azadî

Offline

#7 2023-12-27 14:52:04

PandaSoli
Member
Registered: 2023-10-11
Posts: 7
Website

Re: [SOLVED] Handle Flash drivers

mpan What do you mean with it shuts down the flash drive?
I may sounds like a dumb question but, if a flash device lost its energy it lost the data it stores as it stores data with energy (not the best explanation),
or you mean that it closes the I/O connection? if this is what it does, how may I turn it on again?

I said it was resolved because so far what I understood was that I was doing wrong by using eject.

Head_on_a_Stick
Yes, it was just to know what I was doing wrong exactly.

But if you don't mind, as you guys said a lot of interesting things, I would like to keep this topic open to make some tests to understand better the problem, because I don't think my flash drivers are of poor quality.
I'll make tests sync, those commands seth said, and others I've found in another forum so far.

Offline

#8 2023-12-27 15:07:54

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,048

Re: [SOLVED] Handle Flash drivers

if a flash device lost its energy it lost the data it stores as it stores data with energy

That depends very much on what you define as "flash drive", but certainly not for https://en.wikipedia.org/wiki/NAND_flash_memory (ie. your average usb key)

I was doing wrong by using eject

Eject for all intents and purposes isn't necessary (again: assuming this is a regular-ass usb key) but won't harm and certainly not cause the symptoms you described.

I don't think my flash drivers are of poor quality

s/think/hope/g

others I've found in another forum so far

Do not type random stuff you've found on the interwebz into an interactive shell - recipe for disaster.

Offline

#9 2023-12-27 15:23:05

PandaSoli
Member
Registered: 2023-10-11
Posts: 7
Website

Re: [SOLVED] Handle Flash drivers

I don't get those circuity stuff.

but won't harm and certainly not cause the symptoms you described.

That's why I wanna understand what is going on.

Meaning of "think"
Meaning of "guess"

Do not type random stuff you've found on the interwebz into an interactive shell - recipe for disaster.

That's exactly what I'm doing being here.
But of course, i'm not a dumb-asshole that would type doas umount -fdaR.

btw, I've discovered smth.
If I run eject /dev/sdX, dmesg -w shows:

sdX: detected capacity change from 15633408 to 0

Last edited by PandaSoli (2023-12-27 15:29:32)

Offline

#10 2023-12-27 15:32:47

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,048

Re: [SOLVED] Handle Flash drivers

I don't get those circuity stuff.

Post the output of the commands in #3
The gist of the wikipedia article is that the type of memory that's commonly used in usb keys is not volatile and the information will stay there without external power. Unlike eg. RAM.

btw, I've discovered smth.

You've discovered that if you eject a device it's logically gone

Post the output of the commands in #3

Offline

#11 2023-12-27 15:37:23

PandaSoli
Member
Registered: 2023-10-11
Posts: 7
Website

Re: [SOLVED] Handle Flash drivers

seth

$ lsblk -f
NAME FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                               
├─sda1
│    swap   1           0c2670dc-65d6-47d3-beb6-3acf30e01c2c                [SWAP]
├─sda2
│    ext4   1.0         eadaf4a5-a61f-49b4-837b-87e9d685233b   60.2M    59% /boot
└─sda3
     ext4   1.0         4d9a5502-b822-49df-90a3-555bc5a83626  395.4G     8% /
sdb                                                               
sdc                                                               

$ sudo fdisk -l /dev/sdc
fdisk: cannot open /dev/sdc: No medium found

This is what happens with I run them after running eject.
PS: Ignore sdb, I got no idea what it is, but I'm sure my device is sdc.

Offline

#12 2023-12-27 15:38:49

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,048

Re: [SOLVED] Handle Flash drivers

This is what happens with I run them after running eject.

seth wrote:

if you eject a device it's logically gone

Re-plug the device first.

Offline

#13 2023-12-27 15:47:06

PandaSoli
Member
Registered: 2023-10-11
Posts: 7
Website

Re: [SOLVED] Handle Flash drivers

$ lsblk -f
NAME FSTYPE FSVER LABEL   UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                               
├─sda1
│    swap   1             0c2670dc-65d6-47d3-beb6-3acf30e01c2c                [SWAP]
├─sda2
│    ext4   1.0           eadaf4a5-a61f-49b4-837b-87e9d685233b   60.2M    59% /boot
└─sda3
     ext4   1.0           4d9a5502-b822-49df-90a3-555bc5a83626  395.4G     8% /
sdb                                                               
sdc                                                               
├─sdc1
│    exfat  1.0   Ventoy  DC20-8060                               
└─sdc2
     vfat   FAT16 VTOYEFI B2C8-40D2                               

;-; it must be kidding me.
last time I had a really important data loss even re-plugging it didn't show any partitions, this is why I asked for help.
maybe because this time I ran sync before umount and eject?

I don't understand what just happened.
I'm really sorry for screwing your time for nothing guys.
I'll probably only discover the reason in the next data loss situation.

Offline

#14 2023-12-28 01:59:14

mpan
Member
Registered: 2012-08-01
Posts: 1,599
Website

Re: [SOLVED] Handle Flash drivers

Head_on_a_stick: to be clear, my intention was noting that eject does work and has a particular function for USB media. Not that it played role here.

PandaSoli: again, invoking sync is not needed. umount will perform a sync call.


Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

Board footer

Powered by FluxBB