You are not logged in.

#1 2025-11-28 12:14:55

Gregosky
Member
From: UK
Registered: 2013-07-26
Posts: 184

umount corrupts the pendrive, even if sync-ed before umount-ing

Hi!

I recently purchased AES256 encrypted pendrive and want to use it as /boot
I already have 2 such pendrives from another vendor that I have been using as /boot since 2019, but recently one of them stopped working so I thought it would be nice to have a backup
The pendrive I purchased mounts correctly, then after system upgrade I do this:

mount /uefi
rm -rf /uefi/EFI
cp -r -p /root/uefi/EFI /uefi
sync
umount /uefi

but when I run fsck.vfat the command returns `Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.`

dmesg shows below:

[14308.227546] usb 2-6: new SuperSpeed USB device number 4 using xhci_hcd
[14308.239138] usb 2-6: New USB device found, idVendor=12c9, idProduct=8001, bcdDevice= 0.01
[14308.239152] usb 2-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[14308.239158] usb 2-6: Product: keyu
[14308.239163] usb 2-6: Manufacturer: TIH_chip
[14308.239168] usb 2-6: SerialNumber: 2025060500598
[14308.260115] usb-storage 2-6:1.0: USB Mass Storage device detected
[14308.260303] scsi host0: usb-storage 2-6:1.0
[14309.308055] scsi 0:0:0:0: Direct-Access                               1.00 PQ: 0 ANSI: 2
[14309.310023] sd 0:0:0:0: [sda] 60411904 512-byte logical blocks: (30.9 GB/28.8 GiB)
[14309.310279] sd 0:0:0:0: [sda] Write Protect is off
[14309.310287] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
[14309.310599] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[14309.332620]  sda: sda1 sda2
[14309.333055] sd 0:0:0:0: [sda] Attached SCSI removable disk
[14312.453589] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

The older pendrive I was using like this since 2019 freezes on umount once all data is written the console unfreezes and I always thought that's the indicator I can safely remove the stick from USB port. I never had any problems with it, so I guess the new pendrive is different in some way, but I don't know how to avoid unproper umounts...

How would I umount that drive without causing filesystem issues?

Offline

#2 2025-11-28 15:45:13

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

Re: umount corrupts the pendrive, even if sync-ed before umount-ing

If the dirty bit is ever set it will remain there until you fsck and remove it. This can have happened on any system at any time
Fix it, see whether the concerned behavior stays afterwards.

Offline

#3 2025-11-28 16:24:04

Gregosky
Member
From: UK
Registered: 2013-07-26
Posts: 184

Re: umount corrupts the pendrive, even if sync-ed before umount-ing

I removed dirty bit with `mkfs.vfat` before reattaching, after a few tries and seeing this pendrive suddenly misses disk label and upon mounting I see partition is empty I suspect I got broken device

Offline

#4 2025-11-28 16:47:23

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

Re: umount corrupts the pendrive, even if sync-ed before umount-ing

Did you select/change the FAT table?

The drive might need some overhead for the encryption, do you yank it immediately after the umount?
Does it help to https://man.archlinux.org/man/eject.1 it?

Offline

#5 2025-11-28 20:33:03

Gregosky
Member
From: UK
Registered: 2013-07-26
Posts: 184

Re: umount corrupts the pendrive, even if sync-ed before umount-ing

The pendrive I have is the one with "hardware" encryption (they come with 0-9 keypad attached), I don't know if the encryption is real and how it's done - the only thing I do is to unlock it with the keypad and then attach it to the laptop (I don't want to post Amazon link here, but if you search for "encrypted pendrive" you'll probably see one of these on first page)

I created new GPT partition table with fdisk, then added 2 partitions (2Gb and whatever remains), set first partition type to EFI, then set legacy BIOS bootable flag on first partition, then I copied MBR binary with

dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/bios/mbr.bin of=/dev/sda

Then mkfs.vfat on both, and dosfslabel on first (I mount by label so I can have all my pendrives mounted the same way)
Then copy my syslinux files into it, sync, umount, and wait;
Thank you for mentioning eject, I did test with and without it, and always waited couple of minutes before doing anything - more I look into it more I think this particular pendrive is broken - I have 2 more from another vendor and they don't display that behavior. It makes me sad because I paid $50 for this particular pendrive, bad luck..

Offline

Board footer

Powered by FluxBB