Author Topic: [ solved ] USB stick giving permission problems  (Read 464 times)

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2420
  • Any Bugs in site?
[ solved ] USB stick giving permission problems
« on: November 07, 2012, 05:35:17 AM »
Since 2006 I have had a LEXMARK JumpDrive, small 128 MB USB stick. When visiting BelgiumHolland and Scandinavia for 3 months, this was hanging around my neck with personal details and passwords etc. This is formatted FAT16/VFAT so it could be read in almost any computer.  

On this drive there is a text file holding many many registration details of more general nature, easy to get to.  The file gets regular use when new registrations made to various items. I think it was in the last two months I noticed I can read the file but I also get Recovery message in Kwrite.  Recovery message claim that file not shut down properly.  The file is opened from user Dolphin, looking at properties in Dolphin, permissions gert:root which probably is ok.  What has me concerned, the file is also marked as executable

When opened and Recovery message shows,  for some reason the file content now is two identical copies, using recover option deletes the extra copy. The file then looks fine.  When I now want to close the file however, I can not do this.  I don't have Authority  ???.

Confusion reigns, let me show some details:

Quote
[root@localhost gert]# fdisk -l
......................
...........

Disk /dev/sdd: 128 MB, 128974848 bytes
8 heads, 32 sectors/track, 984 cylinders, total 251904 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb867ac45

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1   *          32      250623      125296    6  FAT16
[root@localhost gert]#


Quote
                             cfdisk (util-linux-ng 2.18)

                                 Disk Drive: /dev/sdd
                             Size: 128974848 bytes, 128 MB
                   Heads: 8   Sectors per Track: 32   Cylinders: 984

    Name         Flags       Part Type   FS Type           [Label]         Size (MB)
 -------------------------------------------------------------------------------------
    sdd1         Boot         Primary    vfat             [LEXAR MEDIA]       128.32
                              Pri/Log    Free Space                             0.66

Going to do some Konsole work. USB stick not mounted in Dolphin any longer:

Quote
[root@localhost gert]# mount -t vfat /dev/sdd1 /here
[root@localhost gert]#

Checking what is mounted:

Quote
[root@localhost gert]# mount
/dev/sdb8 on / type ext3 (rw)
none on /proc type proc (rw)
none on /dev/pts type devpts (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
gvfs-fuse-daemon on /home/gert/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=gert)
/dev/sdd1 on /here type vfat (rw)
[root@localhost gert]#
Hmmm, well the stick is mounted on /here as intended. Almost habitually I use /here and /there
as help directories (Old-Polack's influence)

Quote
[gert@localhost ~]$ ls -l /here
total 1720
drwxr-xr-x 3 root root   2048 Aug 31  2007 000848739Jose-000877809Gert/
-rwxr-xr-x 1 root root    610 Nov  7 09:50 0-Font_Danish_Character_Problem.txt*
drwxr-xr-x 7 root root   4096 Nov  7 14:29 0-Holding/
.................
..........
[gert@localhost ~]$

Quote
[gert@localhost ~]$ ls -l /here/0-Holding/
total 2258
................................
..........
-rwxr-xr-x 1 root root   79846 Dec  8  2011 !!!!!_Reference_080613 .glk*
-rwxr-xr-x 1 root root   83209 Nov  7 09:58 !!!!!_Reference_111204----080613 .glk*
.................
......
[gert@localhost ~]$

1.. the file name of course is rather bad I guess  !!!!!_Reference_111204----080613 .glk
2.. all the files marked as executable
3.. it is not all files that is causing trouble

As this seems to indicate the file is owner:group  root:root, then user gert will have trouble writing to the file.??
Last night once directories just disappeared when using Dolphin for navigation, my hearbeat changed when I saw that, quickly using an XP machine showed all ok. that was when I went to work more with the konsole.

Some pointers would be most welcome. I seem to have forgotten what a USB stick should look like permission wise.
« Last Edit: November 10, 2012, 03:44:48 PM by wedgetail »
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline kjpetrie

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3980
Re: USB stick giving permission problems
« Reply #1 on: November 07, 2012, 05:46:52 AM »
FAT cannot handle Unix file permissions. All files are owned by the user who mounted them and grouped to root. All permissions for owner, group and others are set when a FAT-formatted file system is mounted in Linux. You seem to have a 022 umask operating on the mount point modifying these permissions.

The problem you have is either:

1. The drive was removed from a computer after writing without unmounting it first, or
2. The drive is failing.

Try running fsck on it (unmounted, of course) in Linux or scandisk/checkdisk in Windows.
-----------
KJP
-----------------------------------------------------------
PClos64 RC1 on Intel D945GCLF2 motherboard (Atom 330), 2GB DDR2 RAM, Maxtor STM325031, HL-DT-ST DVDRAM GSA-H42N, Amilo LSL 3220T monitor. Also Acer 5810TG (with custom kernel) and Asus eeePC 2G surf

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2420
  • Any Bugs in site?
Re: USB stick giving permission problems
« Reply #2 on: November 07, 2012, 06:00:07 AM »
kjpetrie
Thanks very much. Totally forgotten about the Unix permissions on FAT.

Quote
1. The drive was removed from a computer after writing without unmounting it first, or......

Distinct possibility, though I do try to be very careful but I know I have missed in the past.   :-[

Quote
You seem to have a 022 umask operating on the mount point modifying these permissions.

Errrhhh, I think you have lost me, do you mean everything has been set read only?

Is it safe to run fsck on a FAT format?? 
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline kjpetrie

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3980
Re: USB stick giving permission problems
« Reply #3 on: November 08, 2012, 05:17:37 AM »
Every user has a umask which is applied to default file permissions. 022 means no mask for the owner of the file, but write is masked for everyone else. I simply observed that the files on the stick had no write permission for group and others which, as FAT can't supply it, must have come from the kernel applying a umask.

The stick is not being mounted RO, as mount says it is rw.

fsck is a master call to a suite of file system checking programs and will simply choose the right program according to the format of the partition. So far as I know, the Linux version is completely safe, but if you're really worried it might do something Windows won't understand you can always use a Windows machine to do the job. I suspect it's actually the same basic program on the back end anyway, as FAT predates MS's version of DOS and I think the tools do as well!
« Last Edit: November 08, 2012, 05:21:18 AM by kjpetrie »
-----------
KJP
-----------------------------------------------------------
PClos64 RC1 on Intel D945GCLF2 motherboard (Atom 330), 2GB DDR2 RAM, Maxtor STM325031, HL-DT-ST DVDRAM GSA-H42N, Amilo LSL 3220T monitor. Also Acer 5810TG (with custom kernel) and Asus eeePC 2G surf

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2420
  • Any Bugs in site?
Re: USB stick giving permission problems
« Reply #4 on: November 10, 2012, 05:28:58 AM »
kjpetrie
Thanks for explanation, I wish I had a bit more time looking at the permissions problem. Sometime next year I may come back and re-visit this thread. Sorry for acknowledging a bit later than I would like. Did want to get my speed test program running over the weekend.  The program are now working well eneough, it is a bit rough but fine for the time being.

Well the story on the permissions is:  I took the USB stick to my wife's Windows XP machine , found something that said it would repair the drive.  I think the function was located near the "Defragger" routine.  I ran it and as far as I could see nothing happened apart from I was told it was now ok.  After having pondered the message a bit I took it back to the Linux machine.

I could not see any apparent difference. I tried out saving to the file and all seemed to be correct.  I will leave it at this for the time being and mark the problem solved. 
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen