Actually, that won't replicate the problem you're trying to replicate. In order to do that, you need to induce an error which causes e2fsck to exit with a preenhalt statement when you run it with the -p option.
So for example:
# debugfs -w -R "write /etc/motd test-file" /tmp/foo.img debugfs 1.40.8 (13-Mar-2008) Allocated inode: 12 # debugfs -w -R "unlink test-file" /tmp/foo.img debugfs 1.40.8 (13-Mar-2008) # debugfs -w -R "set_super_value state 2" /tmp/foo.img debugfs 1.40.8 (13-Mar-2008) # e2fsck -p /tmp/foo.img /tmp/foo.img contains a file system with errors, check forced. /tmp/foo.img: Unattached inode 12
/tmp/foo.img: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY. (i.e., without -a or -p options) # echo $? 4
Actually, that won't replicate the problem you're trying to replicate. In order to do that, you need to induce an error which causes e2fsck to exit with a preenhalt statement when you run it with the -p option.
So for example:
# debugfs -w -R "write /etc/motd test-file" /tmp/foo.img
debugfs 1.40.8 (13-Mar-2008)
Allocated inode: 12
# debugfs -w -R "unlink test-file" /tmp/foo.img
debugfs 1.40.8 (13-Mar-2008)
# debugfs -w -R "set_super_value state 2" /tmp/foo.img
debugfs 1.40.8 (13-Mar-2008)
# e2fsck -p /tmp/foo.img
/tmp/foo.img contains a file system with errors, check forced.
/tmp/foo.img: Unattached inode 12
/tmp/foo.img: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
(i.e., without -a or -p options)
# echo $?
4