我将 SD 卡的文件系统格式更改为 NTFS,以便系统上的应用程序可以写入它。我无法再访问它,所以我将它改回了 FAT,但我仍然无法以 root 或普通用户身份访问它。作为 root,它没有列出。至于以用户身份访问,我收到一个错误弹出窗口,上面写着“无法访问 32 GB 卷,无权执行操作。”
该df
命令给出以下输出:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mmcblk0p1 10732080 8523064 1640800 84% /
devtmpfs 995380 0 995380 0% /dev
shmfs 997360 52396 944964 6% /dev/shm
tmp 997360 19924 977436 2% /tmp
tmpfs 199476 56 199420 1% /run
tmpfs 5120 0 5120 0% /run/lock
run 997360 448 996912 1% /var/host/dbus
/dev/mapper/encstateful 3164880 139276 3009220 5% /var/host/timezone
/dev/root 1763840 1583608 180232 90% /lib/modules/3.18.0-13527-gc2f2230
media 997360 4 997356 1% /var/host/media
/home/.shadow/dbb3045.../vault 10732080 8523064 1640800 84% /home/friskybits/Downloads
none 997360 0 997360 0% /sys/fs/cgroup
none 997360 4
该sudo lsblk -f
命令给出以下输出:
NAME FSTYPE LABEL MOUNTPOINT
loop0
└─encstateful (dm-1) ext4
loop1 squashfs
loop2 squashfs
loop3 squashfs
loop4 squashfs
loop5 squashfs
loop6 squashfs
zram0 [SWAP]
mmcblk0rpmb
mmcblk0boot0
mmcblk0boot1
mmcblk0
├─mmcblk0p1 ext4
├─mmcblk0p2
├─mmcblk0p3 ext4 ROOT-A
│ └─vroot (dm-0)
├─mmcblk0p4
├─mmcblk0p5 ext4 ROOT-A
├─mmcblk0p6
├─mmcblk0p7
├─mmcblk0p8 ext4 OEM
├─mmcblk0p9
├─mmcblk0p10
├─mmcblk0p11
└─mmcblk0p12 vfat EFI-SYSTEM
mmcblk1
└─mmcblk1p1 vfat
该sudo lsblk -m
命令给出以下输出:
NAME SIZE OWNER GROUP MODE
loop0 3.1G root disk brw-rw----
└─encstateful (dm-1) 3.1G root root brw-------
loop1 397.5M root disk brw-rw----
loop2 48.8M root disk brw-rw----
loop3 4K root disk brw-rw----
loop4 4K root disk brw-rw----
loop5 4K root disk brw-rw----
loop6 4K root disk brw-rw----
zram0 2.8G root disk brw-rw----
mmcblk0rpmb 4M root disk brw-rw----
mmcblk0boot0 4M root disk brw-rw----
mmcblk0boot1 4M root disk brw-rw----
mmcblk0 14.7G root disk brw-rw----
├─mmcblk0p1 10.5G root disk brw-rw----
├─mmcblk0p2 16M root disk brw-rw----
├─mmcblk0p3 2G root disk brw-rw----
│ └─vroot (dm-0) 1.7G root root ---------
├─mmcblk0p4 16M root disk brw-rw----
├─mmcblk0p5 2G root disk brw-rw----
├─mmcblk0p6 512B root disk brw-rw----
├─mmcblk0p7 512B root disk brw-rw----
├─mmcblk0p8 16M root disk brw-rw----
├─mmcblk0p9 512B root disk brw-rw----
├─mmcblk0p10 512B root disk brw-rw----
├─mmcblk0p11 8M root disk brw-rw----
└─mmcblk0p12 16M root disk brw-rw----
mmcblk1 29.7G root disk brw-rw----
└─mmcblk1p1 29.7G root disk brw-rw----
该sudo parted -ls
命令给出以下输出:
Model: Linux device-mapper (crypt) (dm)
Disk /dev/mapper/encstateful: 3297MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Number Start End Size File system Flags
1 0.00B 3297MB 3297MB ext4
Error: /dev/mmcblk0rpmb: unrecognised disk label
Warning: Error fsyncing/closing /dev/mmcblk0rpmb: Input/output error
Error: /dev/mmcblk0boot0: unrecognised disk label
Error: /dev/mmcblk0boot1: unrecognised disk label
Model: MMC 400073 (sd/mmc)
Disk /dev/mmcblk0: 15.8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
11 32.8kB 8421kB 8389kB RWFW
6 8421kB 8422kB 512B KERN-C
7 8422kB 8422kB 512B ROOT-C
9 8422kB 8423kB 512B reserved
10 8423kB 8423kB 512B reserved
2 10.5MB 27.3MB 16.8MB KERN-A
4 27.3MB 44.0MB 16.8MB KERN-B
8 44.0MB 60.8MB 16.8MB ext4 OEM msftdata
12 128MB 145MB 16.8MB fat16 EFI-SYSTEM boot
5 145MB 2292MB 2147MB ext2 ROOT-B
3 2292MB 4440MB 2147MB ext2 ROOT-A
1 4440MB 15.7GB 11.3GB ext4 STATE msftdata
Warning: /dev/mmcblk1 contains GPT signatures, indicating that it has a GPT table. However, it does not have a valid fake msdos partition table, as it should. Perhaps it was corrupted -- possibly by a program that doesn't understand GPT partition tables. Or perhaps you deleted the GPT table, and are now using an msdos partition table. Is this a GPT partition table?
Error: The backup GPT table is corrupt, but the primary appears OK, so that will be used.
Model: SD SS32G (sd/mmc)
Disk /dev/mmcblk1: 31.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
11 32.8kB 8421kB 8389kB RWFW
6 8421kB 8422kB 512B KERN-C
7 8422kB 8422kB 512B ROOT-C
9 8422kB 8423kB 512B reserved
10 8423kB 8423kB 512B reserved
2 10.5MB 27.3MB 16.8MB KERN-A
4 27.3MB 44.0MB 16.8MB KERN-B
8 44.0MB 60.8MB 16.8MB OEM msftdata
12 128MB 145MB 16.8MB EFI-SYSTEM boot
5 145MB 147MB 2097kB ROOT-B
3 147MB 2244MB 2097MB ROOT-A
1 2244MB 2263MB 18.9MB STATE msftdata
我如何访问 SD 卡?
答案1
在 SD 卡上安装一个 FAT32 分区,并为所有人提供写入权限
(假设: SD 卡被视为/dev/mmcblk1
,mmcblk1p1
用分区的实际字母替换,例如,sdb1
如果 USB 闪存盘或通过 USB 连接的 SD 卡,/dev/mmcblk1p1
---> /dev/sdb1
)
sudo mkdir -p /mnt/sd1 # only if you want a new mountpoint
sudo umount /dev/mmcblk1p1 # only if already mounted (but with bad permissions)
sudo mount -o rw,users,umask=000 /dev/mmcblk1p1 /mnt/sd1 # mount
或(如果通过 USB 连接)
sudo mkdir -p /mnt/sd1 # only if you want a new mountpoint
sudo umount /dev/sdb1 # only if already mounted (but with bad permissions)
sudo mount -o rw,users,umask=000 /dev/sdb1 /mnt/sd1 # mount
检查权限
ls -ld /mnt/sd1
测试
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
以下命令行说明了不同的替代方案,在这种情况下假设设备/dev/sdb1
$ sudo umount /mnt/sd1; sudo mount -o rw,users,umask=077 /dev/sdb1 /mnt/sd1;ls -ld /mnt/sd1
drwx------ 2 root root 4096 jan 1 1970 /mnt/sd1 # only root has permissions
$ sudo umount /mnt/sd1; sudo mount -o rw,users,umask=033 /dev/sdb1 /mnt/sd1;ls -ld /mnt/sd1
drwxr--r-- 2 root root 4096 jan 1 1970 /mnt/sd1 # users have read permissions
$ sudo umount /mnt/sd1; sudo mount -o rw,users,umask=022 /dev/sdb1 /mnt/sd1;ls -ld /mnt/sd1
drwxr-xr-x 2 root root 4096 jan 1 1970 /mnt/sd1 # users have read and execute permissions
$ sudo umount /mnt/sd1; sudo mount -o rw,users,umask=011 /dev/sdb1 /mnt/sd1;ls -ld /mnt/sd1
drwxrw-rw- 2 root root 4096 jan 1 1970 /mnt/sd1 # users have read and write permissions
$ sudo umount /mnt/sd1; sudo mount -o rw,users,umask=000 /dev/sdb1 /mnt/sd1;ls -ld /mnt/sd1
drwxrwxrwx 2 root root 4096 jan 1 1970 /mnt/sd1 # users have full permissions
如果此方法无效
如果这不起作用,您可以在以下链接中找到解决方案,或者至少找到解释,
答案2
听起来您已经打开了某个已安装 SD 卡的应用程序,阻止 root/用户安装它。检查 gparted 是否已打开它。