hi
我们将硬盘通过/etc/fstab进行挂载,但硬盘经常出现问题但是可以通过e2fsck -y /dev/nvme0n1p1 指令修复。
频繁的手动执行指令可能效率比较低,所以是否可以将这个修复指令加入到开机启动里面呢?在挂载硬盘之前进行修复,这样就避免了磁盘损坏的情况产生。
我的/etc/fstab文件内容如下

# /etc/fstab: static file system information.
#
# These are the filesystems that are always mounted on boot, you can
# override any of these by copying the appropriate line from this file into
# /etc/fstab and tweaking it as you see fit.  See fstab(5).
#
# <file system> <mount point>             <type>          <options>                               <dump> <pass>
/dev/root            /                     ext4           defaults                                     0 1
/dev/nvme0n1p1 /data/ ext4 defaults 0 2

我在网上了解到,可以在/etc/fstab上加入fsck=/bin/fsck参数,但是这个参数是否有修复的作用?网上资料大多数说的都是检查的作用。

/dev/nvme0n1p1 /data/ ext4 defaults,fsck=/bin/fsck 0 2

Hi jiangyinghao,

Are you using the devkit or custom board for AGX Orin?
What’s the Jetpack version in use?

What problem do you hit?
Do you run any application or read/write something to cause disk error?

Is the issue specific to current NVMe SSD? (i.e. have you tried another NVMe SDD with the same issue?)

使用的custom board for xavier,
主要的现象是挂载的系统变成只读,使用e2fsck -y 命令就可以修复

How do you reproduce this issue?
Could it be caused from any application you run?

Yes, you can add the custom command to the script during boot up.

hello,是的,但是在开机的时机需要在/etc/fstab 挂载之前执行e2fsck修复,请问在哪个脚本中加入呢?

hi,我在/etc/rc.local中加入磁盘修复,但是没有起作用。
加入
e2fsck -y /dev/nvme0n1p1 > /home/titan/a.log
查看日志,发现因为已经挂载所以导致执行失败。
image

所以这个磁盘修复应该在磁盘挂载前进行修复,在/etc/fstab 文件中配置后,应该在哪个脚本中加入磁盘修复呢?

Since you want to add the command before it mounts rootfs, please try to add your command in init script of initrd image.
Please refer to Modifying Jetson RAM Disk for details.

hi,请问在ram disk中怎么写才能在串口中有输出?
比如我想在ram disk 中串口输出“ok”

You can just refer to other lines in init script to use echo for the print.
e.g.

echo "Rootfs mounted over ${rootdev}" > /dev/kmsg;

好的,目前已经基本可以调试、打印和输出,但是现在没有办法确保修复指令是否被执行。
我将e2fsck可执行文件拷贝到了bin下
image
然后我在init里面加入了e2fsck加入命令如下

mmc=$(e2fsck -y /dev/mmcblk0p1)
nvme=$(e2fsck -y /dev/nvme0n1p1)
test=$(ls)

echo “e2fsck /dev/mmcblkOp1:” > /dev/kmsg;
echo “${mmc}” > /dev/kmsg;
echo “e2fsck /dev/nvme0n1p1:” > /dev/kmsg;
echo “${nvme}” > /dev/kmsg;
echo “test:” > /dev/kmsg;
echo “${test}” > /dev/kmsg;

但是,最后并没有看到e2fsck指令有输出信息,串口日志如下

[ 12.042586] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
[ 12.054310] Rootfs mounted over mmcblk0p1
[ 12.070607] e2fsck /dev/mmcblkOp1:
[ 12.074157]
[ 12.075711] e2fsck /dev/mmcblkOp1:
[ 12.079246]
[ 12.080795] test:
[ 12.082801] bin
[ 12.082801] boot
[ 12.082801] data
[ 12.082801] dev
[ 12.082801] etc
[ 12.082801] home
[ 12.082801] lib
[ 12.082801] lost+found
[ 12.082801] media
[ 12.082801] mnt
[ 12.082801] opt
[ 12.082801] proc
[ 12.082801] root
[ 12.082801] run
[ 12.082801] sbin
[ 12.082801] srv
[ 12.082801] sys
[ 12.082801] tmp
[ 12.082801] usr
[ 12.118122] var
[ 12.119937] jyh build initrd
[ 12.122929] Switching from initrd to actual rootfs
[ 12.245074] systemd[1]: System time before build time, advancing clock.

很奇怪,这e2fsck是未执行吗?

It seems your custom messages are printed?
but why they are both for /dev/mmcblkOp1? it seems you run e2fsck for nvme0n1p1!?

I would suggest you just running the command like the following one.

e2fsck -y /dev/nvme0n1p1 > /dev/kmsg;

and please add this command before rootfs mounted.

ok,我解释一下,这两个是代码中写错了,这只是打印,不重要的,谢谢

mmc=$(e2fsck -y /dev/mmcblk0p1)
nvme=$(e2fsck -y /dev/nvme0n1p1)
test=$(ls)

echo “e2fsck /dev/mmcblkOp1:” > /dev/kmsg;
echo “${mmc}” > /dev/kmsg;
echo “e2fsck /dev/nvme0n1p1:” > /dev/kmsg;
echo “${nvme}” > /dev/kmsg;
echo “test:” > /dev/kmsg;
echo “${test}” > /dev/kmsg;

另外我的问题在新的topic重新提出,您可以在新的topic中回复,谢谢。
RAM DISK - Jetson & Embedded Systems / Jetson AGX Orin - NVIDIA Developer Forums