多年来,我一直使用各种 USB MP3 播放器来播放播客。两天前,突然间,我无法向播放器添加文件,因为权限被拒绝。它已安装并可读取,但无法向其复制或移动文件。
我可以通过输入以下命令来纠正此问题:
sudo umount /dev/sdc && sudo mount -o rw,users,umask=000 /dev/sdc /mnt/sdc
但这回避了以下问题:这是怎么发生的?我应该怎么做才能恢复其自动挂载 R/W 状态?
当我运行时,journalctl -f
我得到以下信息:
Aug 09 07:09:14 cliff-desktop kernel: usb 1-1.4: new high-speed USB device number 6 using ehci-pci
Aug 09 07:09:14 cliff-desktop kernel: usb 1-1.4: New USB device found, idVendor=0781, idProduct=74e7
Aug 09 07:09:14 cliff-desktop kernel: usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Aug 09 07:09:14 cliff-desktop kernel: usb 1-1.4: Product: Clip Sport Aug 09 07:09:14 cliff-desktop kernel: usb 1-1.4: Manufacturer: SanDisk Aug 09 07:09:14 cliff-desktop kernel: usb 1-1.4: SerialNumber: 974773246CE44042
Aug 09 07:09:14 cliff-desktop mtp-probe[6248]: checking bus 1, device 6: "/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4"
Aug 09 07:09:14 cliff-desktop mtp-probe[6248]: bus: 1, device: 6 was not an MTP device
Aug 09 07:09:14 cliff-desktop kernel: usb-storage 1-1.4:1.0: USB Mass Storage device detected
Aug 09 07:09:14 cliff-desktop kernel: scsi host6: usb-storage 1-1.4:1.0
Aug 09 07:09:14 cliff-desktop kernel: usbcore: registered new interface driver usb-storage
Aug 09 07:09:14 cliff-desktop upowerd[1711]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4
Aug 09 07:09:14 cliff-desktop upowerd[1711]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0
Aug 09 07:09:14 cliff-desktop colord-sane[6261]: io/hpmud/pp.c 627: unable to read device-id ret=-1
Aug 09 07:09:15 cliff-desktop kernel: scsi 6:0:0:0: Direct-Access SanDisk Clip Sport PQ: 0 ANSI: 0 CCS
Aug 09 07:09:15 cliff-desktop kernel: scsi 6:0:0:1: Direct-Access SanDisk Clip Sport PQ: 0 ANSI: 0 CCS
Aug 09 07:09:15 cliff-desktop kernel: sd 6:0:0:0: Attached scsi generic sg3 type 0
Aug 09 07:09:15 cliff-desktop kernel: sd 6:0:0:1: Attached scsi generic sg4 type 0
Aug 09 07:09:15 cliff-desktop kernel: sd 6:0:0:0: [sdc] 8179712 1024-byte logical blocks: (8.38 GB/7.80 GiB)
Aug 09 07:09:15 cliff-desktop kernel: sd 6:0:0:0: [sdc] Write Protect is off
Aug 09 07:09:15 cliff-desktop kernel: sd 6:0:0:0: [sdc] Mode Sense: 00 c0 00 00
Aug 09 07:09:15 cliff-desktop kernel: sd 6:0:0:1: [sdd] Attached SCSI removable disk
Aug 09 07:09:15 cliff-desktop kernel: sd 6:0:0:0: [sdc] Write cache: disabled, read cache: disabled, doesn't support DPO or FUA
Aug 09 07:09:15 cliff-desktop kernel: sdc:
Aug 09 07:09:15 cliff-desktop kernel: sd 6:0:0:0: [sdc] Attached SCSI removable disk
当我使用完全相同的电线插入外部硬盘时,它可以完美运行。
错误在哪里?我该如何解决?
答案1
我$HOME/mnt/mp3
使用 将我的几个 mp3 播放器安装到我的目录下lsblk
,然后执行我的fixmp3
脚本,脚本如下:
#!/bin/bash
# Umount, Repair (via fsck.fvat) and Mount a device (/dev/sdx)
# Walt Sullivan, Walt Sullivan Software, Ltd.
# determine my name
me=$0
me=${me##*/}
# -h or --help
help () {
cat >&2 <<EOF
${me} [-h|--help] [-d|--debug] [-v|--verbose]
${me}: FIXME put your help message here FIXME .
EOF
exit 2
}
declare -i debug=0 verbose=0
TEMP=`getopt -o dhv --long debug,help,verbose \
-n 'FIXME.bash' -- "$@"`
if [[ $? != 0 ]] ; then echo "${me} --help for help." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true ; do
case "$1" in
-d|--debug) debug=1; shift;;
-h|--help) help; shift;;
-v|--verbose) verbose=1; shift;;
--) shift; break;;
*) echo "Internal error! ${me} --help for help";exit 1;;
esac
done
NEED_sudo="sudo "
uid=$( /usr/bin/id -u )
[ $uid -eq 0 ] && NEED_sudo=
# Use ${NEED_sudo} as a prefix for commands that need to run as root
#${NEED_sudo}wc -l /etc/shadow
while [[ $# -gt 0 ]] ;do
target="$1"
shift
mntdir="$HOME/mnt/mp3/${target##*/}"
[[ -d "$mntdir" ]] || mkdir --mode=755 "$mntdir"
${NEED_sudo}umount $target
${NEED_sudo}fsck.vfat -w -y $target
${NEED_sudo}mount -t vfat -o rw,user,users,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2 $target $mntdir
done
exit 0
我必须将自己添加到多个组中才能获得所需的系统管理访问权限。这可能不适用于您的问题,但是:
walt@bat:~(130)$ id
uid=1000(walt) gid=1000(walt) groups=1000(walt),4(adm),7(lp),20(dialout),24(cdrom),27(sudo),101(systemd-journal),106(input),113(lpadmin),141(wireshark),142(motion),143(libvirtd)
journalctl
当我插入 Sansa Clip Zip 时会显示以下内容:
Aug 09 21:15:11 bat kernel: usb 1-1.5: new high-speed USB device number 67 using ehci-pci
Aug 09 21:15:11 bat kernel: usb 1-1.5: New USB device found, idVendor=0781, idProduct=74e5
Aug 09 21:15:11 bat kernel: usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Aug 09 21:15:11 bat kernel: usb 1-1.5: Product: Sansa Clip Zip
Aug 09 21:15:11 bat kernel: usb 1-1.5: Manufacturer: SanDisk
Aug 09 21:15:11 bat kernel: usb 1-1.5: SerialNumber: 671DE90B6751C3A80000000000000000
Aug 09 21:15:11 bat kernel: usb-storage 1-1.5:1.0: USB Mass Storage device detected
Aug 09 21:15:12 bat kernel: scsi host6: usb-storage 1-1.5:1.0
Aug 09 21:15:12 bat mtp-probe[7103]: checking bus 1, device 67: "/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5"
Aug 09 21:15:12 bat mtp-probe[7103]: bus: 1, device: 67 was not an MTP device
Aug 09 21:15:12 bat kernel: scsi 6:0:0:0: Direct-Access SanDisk Sansa Clip Zip 4 v01. PQ: 0 ANSI: 0
Aug 09 21:15:12 bat kernel: scsi 6:0:0:1: Direct-Access SanDisk Sansa Clip Zip 4 v01. PQ: 0 ANSI: 0
Aug 09 21:15:12 bat kernel: sd 6:0:0:0: Attached scsi generic sg1 type 0
Aug 09 21:15:12 bat kernel: sd 6:0:0:1: Attached scsi generic sg2 type 0
Aug 09 21:15:12 bat kernel: sd 6:0:0:0: [sdb] 7683072 512-byte logical blocks: (3.93 GB/3.66 GiB)
Aug 09 21:15:12 bat kernel: sd 6:0:0:1: [sdc] Attached SCSI removable disk
Aug 09 21:15:13 bat kernel: sd 6:0:0:0: [sdb] Write Protect is off
Aug 09 21:15:13 bat kernel: sd 6:0:0:0: [sdb] Mode Sense: 04 00 00 00
Aug 09 21:15:13 bat kernel: sd 6:0:0:0: [sdb] No Caching mode page found
Aug 09 21:15:13 bat kernel: sd 6:0:0:0: [sdb] Assuming drive cache: write through
Aug 09 21:15:13 bat kernel: sdb:
Aug 09 21:15:13 bat kernel: sd 6:0:0:0: [sdb] Attached SCSI removable disk