
大約一個月前,我在我的 Kubuntu 16.10 機器上運行了一些定期更新(不幸的是我不記得軟體包的名稱)。現在,一個月後,我嘗試在 USB 隨身碟上寫入一些數據,但突然無法使用。
USB 磁碟已被識別,我只需使用 GUI 即可連接它,例如透過點擊 Dolphin 或 Konqueror 中的「連接磁碟機」圖示。我能夠從 USB 記憶棒讀取數據,但是當我嘗試將文件複製到 USB 記憶棒時,出現以下錯誤(waran
是我的用戶名,A874-2FAD
是 USB 記憶棒的名稱):
征服者:
Access denied. Could not write to '/media/waran/A874-2FAD'
使用命令列複製 ( cp testfile.jpg /media/waran/A874-2FAD/
):
cp: cannot create regular file '/media/waran/A874-2FAD/testfile.jpg': Permission denied
我已經用 4 個不同的 USB 記憶棒、2 個 SD 卡(直接透過筆記本上的讀卡機或使用外部讀卡機)和一個 CF 卡(使用外部讀卡機)進行了嘗試(未成功)。我在這台電腦上有雙重啟動,從 Windows 10 寫入記憶棒效果很好。如果這有助於縮小問題範圍,我可以使用 USB 電纜從 Kubuntu 進行列印。
我還注意到,目錄中有一些新資料夾/media
。之前/media/
包含一個名為 的資料夾waran/
,該資料夾中僅包含目前連接的 USB。
現在看起來像這樣(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 ..
有什麼建議嗎?為什麼結構突然改變?如何直接從 Kubuntu 寫入 USB 記憶棒?
編輯:感謝 sudodus 的回答,我意識到,因為root
我有寫入權限,所以我可以在隨身碟上寫入。更改/media/waran
權限不起作用,透過命令列手動安裝驅動器也沒有改變權限問題。
編輯:df
卸載U盤後的結果:
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
df
安裝 USB 隨身碟後的結果:
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
所以看來筆式驅動器已成功卸載和安裝,但在沒有 root 權限的情況下我仍然無法編輯內容。
答案1
在沒有得到任何新想法之後,我將問題重新發佈到 Ubuntu 論壇。 https://ubuntuforums.org/showthread.php?t=2348773
Coffeecat 建議我卸載該usbmount
軟體包 ( apt-get remove usbmount
)。現在我可以在沒有 root 權限的情況下更改隨身碟的內容。
答案2
root
擁有/media/waran
以及透過自動方法安裝的內容。您可以以 root 身分建立檔案或將檔案複製到 USB 磁碟機嗎?嘗試
sudo bash -c "echo 'Hello World' > /media/waran/A874-2FAD/hello.txt"
一種替代方法是更改/media/waran
sudo chmod ugo+rwx /media/waran
改變所有權的另一種選擇
sudo chown waran /media/waran
重啟。如果這不起作用,或者您不想要這樣的解決方案,您可以使用命令列方法(可能包含在 shellscript 或別名中)。
假設:U盤被視為/dev/sdx,並且有一個FAT32或NTFS分區,將x替換為實際盤符,例如b:/dev/sdx1
--->/dev/sdb1
sudo mkdir -p /mnt/sd1 # only if you want a new mountpoint
sudo umount /dev/sdx1 # only if already mounted (but with bad permissions)
sudo mount -o rw,users,umask=000 /dev/sdx1 /mnt/sd1 # mount
ls -ld /mnt/sd1 # check permissions
sudo bash -c "echo 'Hello World' > /mnt/sd1/hello.txt" # test writing with sudo
cat /mnt/sd1/hello.txt # test reading (as user)
ls -l /mnt/sd1 # check permissions of the content
rm /mnt/sd1/hello.txt # test removing (as user)
echo 'I am a user' > /mnt/sd1/user.txt # test writing (as user)
修改掛載選項“umask”以適合您的需求。umask=000
意味著每個人都可以完全存取已安裝的分割區。