树莓派Linux挂载硬盘提示只读问题解决

树莓派Linux挂载硬盘提示只读问题解决

  • 一、解决过程

     
树莓派挂载硬盘做nas,一段时间后硬盘突然变为只读,无法写入新文件

一、解决过程

1.卸载硬盘

 sudo umount /dev/sda2

参数:
 -a, --all               unmount all filesystems
 -A, --all-targets       unmount all mountpoints for the given device in the
                           current namespace
 -c, --no-canonicalize   don't canonicalize paths
 -d, --detach-loop       if mounted loop device, also free this loop device
     --fake              dry run; skip the umount(2) syscall
 -f, --force             force unmount (in case of an unreachable NFS system)
 -i, --internal-only     don't call the umount.<type> helpers
 -n, --no-mtab           don't write to /etc/mtab
 -l, --lazy              detach the filesystem now, clean up things later
 -O, --test-opts <list>  limit the set of filesystems (use with -a)
 -R, --recursive         recursively unmount a target with all its children
 -r, --read-only         in case unmounting fails, try to remount read-only
 -t, --types <list>      limit the set of filesystem types
 -v, --verbose           say what is being done
 -q, --quiet             suppress 'not mounted' error messages
 -N, --namespace <ns>    perform umount in another namespace

 -h, --help              display this help
 -V, --version           display version

2.若此时出现 target is busy的提示,则说明有进程正在使用此硬盘;若无此提示则跳过此步骤

查看使用的进程:fuser -mv /home/pi/nas
杀死占用的进程:fuser -kv /home/pi/nas

参数:
-a:显示命令行中指定的所有文件;
-k:杀死访问指定文件的所有进程;
-i:杀死进程前需要用户进行确认;
-l:列出所有已知信号名;
-m:指定一个被加载的文件系统或一个被加载的块设备;
-n:选择不同的名称空间;
-u:在每个进程后显示所属的用户名。

3.修复硬盘(可跳过)

sudo ntfsfix /dev/sda2

参数:
-b, --clear-bad-sectors Clear the bad sector list
-d, --clear-dirty       Clear the volume dirty flag
-h, --help              Display this help
-n, --no-action         Do not write anything
-V, --version           Display version information

4.重新挂载硬盘

sudo mount -o rw /dev/sda2

5.通过df命令查看挂载情况,并验证硬盘支持读写的状态

df

树莓派Linux挂载硬盘提示只读问题解决_第1张图片
6.通过mount命令查看硬盘读写状态

mount

参数:
Options:
 -a, --all               mount all filesystems mentioned in fstab
 -c, --no-canonicalize   don't canonicalize paths
 -f, --fake              dry run; skip the mount(2) syscall
 -F, --fork              fork off for each device (use with -a)
 -T, --fstab <path>      alternative file to /etc/fstab
 -i, --internal-only     don't call the mount.<type> helpers
 -l, --show-labels       show also filesystem labels
 -n, --no-mtab           don't write to /etc/mtab
     --options-mode <mode>
                         what to do with options loaded from fstab
     --options-source <source>
                         mount options source
     --options-source-force
                         force use of options from fstab/mtab
 -o, --options <list>    comma-separated list of mount options
 -O, --test-opts <list>  limit the set of filesystems (use with -a)
 -r, --read-only         mount the filesystem read-only (same as -o ro)
 -t, --types <list>      limit the set of filesystem types
     --source <src>      explicitly specifies source (path, label, uuid)
     --target <target>   explicitly specifies mountpoint
     --target-prefix <path>
                         specifies path use for all mountpoints
 -v, --verbose           say what is being done
 -w, --rw, --read-write  mount the filesystem read-write (default)
 -N, --namespace <ns>    perform mount in another namespace

 -h, --help              display this help
 -V, --version           display version

树莓派Linux挂载硬盘提示只读问题解决_第2张图片

通过/dev/sda2 on /home/pi/nas type fuseblk (rw,nosuid,nodev,noexec,relatime,user_id=   0,group_id=0,allow_other,blksize=4096)
可以看出,硬盘已经支持读写

你可能感兴趣的:(树莓派,嵌入式,Linux,linux,嵌入式,树莓派)