# SSD e2fsck in /etc/fstab

**URL:** <https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581>\
**Category:** Jetson AGX Orin\
**Tags:** ssd, chinese\
**Created:** [December 12, 2024, 3:39am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581 "2024-12-12T03:39:23Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiangyinghao](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jiangyinghao](https://forums.developer.nvidia.com/u/jiangyinghao)\
**Post date:** [December 12, 2024, 3:39am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/1 "2024-12-12T03:39:23Z")

</div>

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

```auto
# /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

```

---

<div class="post-metadata">

**Author:** ![jiangyinghao](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jiangyinghao](https://forums.developer.nvidia.com/u/jiangyinghao)\
**Post date:** [December 12, 2024, 3:42am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/2 "2024-12-12T03:42:30Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![KevinFFF](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kevinfff/32/15508_2.png) [@KevinFFF](https://forums.developer.nvidia.com/u/KevinFFF)\
**Post date:** [December 12, 2024, 5:11am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/4 "2024-12-12T05:11:43Z")

</div>

Hi jiangyinghao,

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

> [@jiangyinghao](#):
>
> 硬盘经常出现问题

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?)

---

<div class="post-metadata">

**Author:** ![jiangyinghao](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jiangyinghao](https://forums.developer.nvidia.com/u/jiangyinghao)\
**Post date:** [December 12, 2024, 6:26am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/5 "2024-12-12T06:26:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KevinFFF](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kevinfff/32/15508_2.png) [@KevinFFF](https://forums.developer.nvidia.com/u/KevinFFF)\
**Post date:** [December 13, 2024, 1:46am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/6 "2024-12-13T01:46:48Z")

</div>

> [@jiangyinghao](#):
>
> 主要的现象是挂载的系统变成只读

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

> [@jiangyinghao](#):
>
> 频繁的手动执行指令可能效率比较低，所以是否可以将这个修复指令加入到开机启动里面呢？

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

---

<div class="post-metadata">

**Author:** ![jiangyinghao](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jiangyinghao](https://forums.developer.nvidia.com/u/jiangyinghao)\
**Post date:** [December 13, 2024, 2:56am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/7 "2024-12-13T02:56:40Z")

</div>

> [@KevinFFF](#):
>
> Yes, you can add the custom command to the script during boot up.

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

---

<div class="post-metadata">

**Author:** ![jiangyinghao](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jiangyinghao](https://forums.developer.nvidia.com/u/jiangyinghao)\
**Post date:** [December 16, 2024, 6:49am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/8 "2024-12-16T06:49:16Z")

</div>

hi,我在/etc/rc.local中加入磁盘修复，但是没有起作用。  
加入  
`e2fsck -y /dev/nvme0n1p1 > /home/titan/a.log`  
查看日志，发现因为已经挂载所以导致执行失败。  
 ![image](https://global.discourse-cdn.com/nvidia/original/4X/5/4/9/54970b86700727ce731a3b0c358157a7a0ec97d5.png)

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

---

<div class="post-metadata">

**Author:** ![KevinFFF](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kevinfff/32/15508_2.png) [@KevinFFF](https://forums.developer.nvidia.com/u/KevinFFF)\
**Post date:** [December 16, 2024, 9:03am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/9 "2024-12-16T09:03:46Z")

</div>

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](https://docs.nvidia.com/jetson/archives/r36.4/DeveloperGuide/SD/FlashingSupport.html#modifying-jetson-ram-disk) for details.

---

<div class="post-metadata">

**Author:** ![jiangyinghao](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jiangyinghao](https://forums.developer.nvidia.com/u/jiangyinghao)\
**Post date:** [December 20, 2024, 8:24am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/11 "2024-12-20T08:24:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KevinFFF](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kevinfff/32/15508_2.png) [@KevinFFF](https://forums.developer.nvidia.com/u/KevinFFF)\
**Post date:** [December 23, 2024, 3:58am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/12 "2024-12-23T03:58:09Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![jiangyinghao](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jiangyinghao](https://forums.developer.nvidia.com/u/jiangyinghao)\
**Post date:** [December 23, 2024, 7:46am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/14 "2024-12-23T07:46:54Z")

</div>

好的，目前已经基本可以调试、打印和输出，但是现在没有办法确保修复指令是否被执行。  
我将e2fsck可执行文件拷贝到了bin下  
 ![image](https://global.discourse-cdn.com/nvidia/original/4X/7/d/e/7de4882514405276c40d74f4cc9cf0da4498beb0.png)  
然后我在init里面加入了e2fsck加入命令如下

```auto

```

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;

```auto
但是，最后并没有看到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是未执行吗？

---

<div class="post-metadata">

**Author:** ![KevinFFF](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kevinfff/32/15508_2.png) [@KevinFFF](https://forums.developer.nvidia.com/u/KevinFFF)\
**Post date:** [December 24, 2024, 2:22am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/15 "2024-12-24T02:22:57Z")

</div>

> [@jiangyinghao](#):
>
> [12.070607] e2fsck /dev/mmcblkOp1:  
> [12.074157]  
> [12.075711] e2fsck /dev/mmcblkOp1:

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.

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

```

and please add this command before rootfs mounted.

---

<div class="post-metadata">

**Author:** ![jiangyinghao](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jiangyinghao](https://forums.developer.nvidia.com/u/jiangyinghao)\
**Post date:** [December 24, 2024, 2:34am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/16 "2024-12-24T02:34:13Z")

</div>

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

```auto
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](https://forums.developer.nvidia.com/t/ram-disk/317729/23)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [January 16, 2025, 5:00am UTC](https://forums.developer.nvidia.com/t/ssd-e2fsck-in-etc-fstab/316581/18 "2025-01-16T05:00:46Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
