Suddenly unable to write to usb sticks, the /media structure changed

8,862

After not getting any new ideas here anymore, I reposted the question to Ubuntu Forums. https://ubuntuforums.org/showthread.php?t=2348773

Coffeecat advised me to uninstall the usbmount package (apt-get remove usbmount). Now I am able to change the content of a pendrive without root permissions.

Share:
8,862

Related videos on Youtube

jenda
Author by

jenda

Updated on September 18, 2022

Comments

  • jenda
    jenda over 1 year

    About a month ago I have run some regular updates on my Kubuntu 16.10 machine (unfortunately I can't remember the names of the packages). Now, a month later, I tried to write some data on my USB stick and it suddenly doesn't work.

    The USB disk is recognized and I am able to connect it simply using the GUI, for example by clicking the "connect drive" icon in Dolphin or Konqueror. I am able to read data from the USB stick, but when I try to copy a file to the stick, i get following errors (waran is my username, A874-2FAD is the name of the USB stick):

    Konqueror:

    Access denied. Could not write to '/media/waran/A874-2FAD'
    

    Copying using command line (cp testfile.jpg /media/waran/A874-2FAD/):

    cp: cannot create regular file '/media/waran/A874-2FAD/testfile.jpg': Permission denied
    

    I have tried it (unsuccessfully) with 4 different USB sticks, 2 SD cards (directly through the card reader on my notebook or using an external card reader) and a CF card (using an external card reader). I have dual boot on this computer, writing to sticks from Windows 10 worked just fine. If it helps narrowing the problem, I am able to print from Kubuntu using an USB cable.

    Also I noticed, that I have some new folders in the /media directory. Previously /media/ contained one folder called waran/, in this folder were only the currently connected USBs.

    Now it looks like this (ls -aRl):

    .:
    total 44
    drwxr-xr-x  11 root  root  4096 Oct 22 20:36 .
    drwxr-xr-x  25 root  root  4096 Dec 20 21:47 ..
    lrwxrwxrwx   1 root  root    45 Oct 15 13:46 .directory -> /etc/kubuntu-default-settings/directory-media
    lrwxrwxrwx   1 root  root    42 Oct 15 13:46 .hidden -> /etc/kubuntu-default-settings/hidden-media
    lrwxrwxrwx   1 root  root     4 Oct 22 20:36 usb -> usb0
    drwxr-xr-x   2 root  root  4096 Oct 22 20:36 usb0
    drwxr-xr-x   2 root  root  4096 Oct 22 20:36 usb1
    drwxr-xr-x   2 root  root  4096 Oct 22 20:36 usb2
    drwxr-xr-x   2 root  root  4096 Oct 22 20:36 usb3
    drwxr-xr-x   2 root  root  4096 Oct 22 20:36 usb4
    drwxr-xr-x   2 root  root  4096 Oct 22 20:36 usb5
    drwxr-xr-x   2 root  root  4096 Oct 22 20:36 usb6
    drwxr-xr-x   2 root  root  4096 Oct 22 20:36 usb7
    drwxr-x---+  4 waran waran 4096 Jan  5 21:27 waran
    
    ./usb0:
    total 8
    drwxr-xr-x  2 root root 4096 Oct 22 20:36 .
    drwxr-xr-x 11 root root 4096 Oct 22 20:36 ..
    
    ./usb1:
    total 8
    drwxr-xr-x  2 root root 4096 Oct 22 20:36 .
    drwxr-xr-x 11 root root 4096 Oct 22 20:36 ..
    
    ./usb2:
    total 8
    drwxr-xr-x  2 root root 4096 Oct 22 20:36 .
    drwxr-xr-x 11 root root 4096 Oct 22 20:36 ..
    
    ./usb3:
    total 8
    drwxr-xr-x  2 root root 4096 Oct 22 20:36 .
    drwxr-xr-x 11 root root 4096 Oct 22 20:36 ..
    
    ./usb4:
    total 8
    drwxr-xr-x  2 root root 4096 Oct 22 20:36 .
    drwxr-xr-x 11 root root 4096 Oct 22 20:36 ..
    
    ./usb5:
    total 8
    drwxr-xr-x  2 root root 4096 Oct 22 20:36 .
    drwxr-xr-x 11 root root 4096 Oct 22 20:36 ..
    
    ./usb6:
    total 8
    drwxr-xr-x  2 root root 4096 Oct 22 20:36 .
    drwxr-xr-x 11 root root 4096 Oct 22 20:36 ..
    
    ./usb7:
    total 8
    drwxr-xr-x  2 root root 4096 Oct 22 20:36 .
    drwxr-xr-x 11 root root 4096 Oct 22 20:36 ..
    
    ./waran:
    total 20
    drwxr-x---+  4 waran waran 4096 Jan  5 21:27 .
    drwxr-xr-x  11 root  root  4096 Oct 22 20:36 ..
    drwxr-xr-x   2 root  root  8192 Jan  1  1970 A874-2FAD
    drwxr-xr-x   2 waran waran 4096 Oct 22 22:19 System\x20Reserved
    
    ./waran/A874-2FAD:
    total 12
    drwxr-xr-x  2 root  root  8192 Jan  1  1970 .
    drwxr-x---+ 4 waran waran 4096 Jan  5 21:27 ..
    
    ./waran/System\x20Reserved:
    total 8
    drwxr-xr-x  2 waran waran 4096 Oct 22 22:19 .
    drwxr-x---+ 4 waran waran 4096 Jan  5 21:27 ..
    

    Any advice? Why did the structure suddenly change? How can I write to my USB sticks directly from Kubuntu?

    Edit: Thanks to sudodus's answer I realized, that as root I have the write permissions and I am able to write on the pendrive. Changing /media/waran permissions didn't work, mounting the drive manually through command-line didn't change the permission issue either.

    Edit: Result of df after unmounting the USB stick:

    Filesystem     1K-blocks      Used Available Use% Mounted on
    udev             1948092         0   1948092   0% /dev
    tmpfs             394580     26256    368324   7% /run
    /dev/sda5       23706164  15941220   6537672  71% /
    tmpfs            1972892     40900   1931992   3% /dev/shm
    tmpfs               5120         4      5116   1% /run/lock
    tmpfs            1972892         0   1972892   0% /sys/fs/cgroup
    /dev/sda6      780771600 450109520 290978140  61% /home
    tmpfs             394576         0    394576   0% /run/user/119
    tmpfs             394576        24    394552   1% /run/user/1000
    

    Result of df after mounting the USB stick:

    Filesystem     1K-blocks      Used Available Use% Mounted on
    udev             1948092         0   1948092   0% /dev
    tmpfs             394580     26256    368324   7% /run
    /dev/sda5       23706164  15941248   6537644  71% /
    tmpfs            1972892     41156   1931736   3% /dev/shm
    tmpfs               5120         4      5116   1% /run/lock
    tmpfs            1972892         0   1972892   0% /sys/fs/cgroup
    /dev/sda6      780771600 450109520 290978140  61% /home
    tmpfs             394576         0    394576   0% /run/user/119
    tmpfs             394576        24    394552   1% /run/user/1000
    /dev/sdb1        7849228    263772   7585456   4% /mnt/sd1
    

    So it seems the pendrive was successfully unmounted and mounted, still I am not able to edit the contents without root permissions.

  • jenda
    jenda over 7 years
    Thanks to your answer I realized, that I am able to write / remove files as root. I have tried to change ownership, but it doesn't help. Your assumption about the pendrive being seen as /dev/sdx was correct and it is indeed formatted as FAT32. But even using the shell method, only root is able to edit the content. (The file hello.txt is owned by root and I am not able to remove it. I am also not able to create the file user.txt: bash: /mnt/sd1/user.txt: Permission denied.) Any Ideas?
  • sudodus
    sudodus over 7 years
    Have you unmounted the partition, and then tried to mount it with sudo mount -o rw,users,umask=000 /dev/sdx1 /mnt/sd1 (should be one line)?
  • jenda
    jenda over 7 years
    I did sudo umount /dev/sdx1, then sudo mount -o rw,users,umask=000 /dev/sdx1 /mnt/sd1 (I substituted the x in sdx1 with the current drive letter). Then I tried to create a file using echo "test" > /mnt/sd1/testfile.txt and got this following error: bash: /mnt/sd1/testfile.txt: Permission denied.
  • sudodus
    sudodus over 7 years
    This works for me in Lubuntu 16.04.1 LTS. I must admit that I don't understand why it does not work for you. What is the output of ls -ld /mnt/sd1 ?
  • jenda
    jenda over 7 years
    ls -ld /mnt/sd1 returns this: drwxr-xr-x 3 root root 4096 Jan 1 1970 /mnt/sd1
  • sudodus
    sudodus over 7 years
    So it seems that umask=000 in the mount command did not work. You should get drwxrwxrwx - write access also for group and others. Are you sure that you managed to unmount the drive before trying to mount it? Please post the output of df after trying to unmount the drive.
  • jenda
    jenda over 7 years
    I edited my question and added the df output after unmounting and after remounting the USB stick. (It would be too chaotic in a comment.)
  • sudodus
    sudodus over 7 years
    We need help. Can you help us solve this problem?
  • RTbecard
    RTbecard over 5 years
    This worked for me. usbmount caused a number of obscure USB errors on my system (Ubuntu 18.04). USB flash drives were always mounted as read only even when I manually mount from terminal and I could not mount USB HDDs (resulted in mounting errors). Uninstalling this immediately fixed all issues. Also, copying files with sudo while usbmount was installed (the only way) was an order of magnitude slower than normal.