环境搭配:
centos7.5
e2fsck version: 1.4.29
resize2fs version:1.4.29
rc.local 运行脚本中有需扩充LVM空间脚本,其中有两个语句为:
/sbin/e2fsck -f /dev/vg/data
/sbin/resize2fs /dev/vg/data
开机启动运行过程中通过打印信息得知错误原因为e2fsck 执行过程中报错:
e2fsck : need terminal for interfactive repairs
导致resize2fs无法执行
解决问题方法:
1、修改/sbin/e2fsck -f /dev/vg/data为/sbin/e2fsck -fp /dev/vg/data
以下为manpage 中 p参数说明:
-p Automatically repair ("preen") the file system. This option will cause e2fsck to automatically fix any filesystem problems that can be safely fixed without human intervention. If e2fsck discovers a problem which may require the system administrator to take additional corrective action, e2fsck will print a description of the problem and then exit with the value 4 logically or'ed into the exit code. (See the EXIT CODE section.) This option is normally used by the system's boot scripts. It may not be specified at the same time as the -n or -y options.
2、将 /dev/vg/data挂载后执行/sbin/resize2fs /dev/vg/data,此时将会启用在线扩充模式,/sbin/e2fsck -f /dev/vg/data执行失败不会影响resize2fs执行扩充。