Operating System - Linux
1822142 Members
3446 Online
109640 Solutions
New Discussion юеВ

e2fsadm works fine from command line but fails when in script

 
SOLVED
Go to solution
Matt Shaffer_1
Regular Advisor

e2fsadm works fine from command line but fails when in script

I'm running linux redhat E3 update 4. Kernel is 2.4.21. When I run /sbin/e2fsadm -L-5g /dev/vg00/backup from the command line it works great. But when I run this within a script I get:
/sbin/e2fsadm -L-5g /dev/vg00/backup
e2fsck 1.32 (09-Nov-2002)
e2fsck: need terminal for interactive repair

I've tried to use -n to skip the e2fsck but then I get 'must run e2fsck first'. If I add e2fsck before my e2fsadm command in the script, e2fsck runs fine but then e2fsadm still comes back with 'must run e2fsck first'. Ultimately, what I want to happen is that my /sbin/e2fsadm -L-5g /dev/vg00/backup runs fine within the script.
2 REPLIES 2
Ivan Ferreira
Honored Contributor
Solution

Re: e2fsadm works fine from command line but fails when in script

From the man page:

-n Avoid the filesystem check before the resize operation. A filesystem check is mandatory before resize2fs(8), but is optional for ext2resize(8), and is not allowed for ext2online(8) because the filesystem is mounted.

By default, for mounted filesystems e2fsadm will look for resize2fs first, and failing that it will look for ext2resize. For mounted filesystems it will try to run ext2online.

So, maybe its trying to use resize2fs. You have the following options:

Use idependent commands to accomplish the task, e2fsck(8), lvextend(8), lvreduce(8), and resize2fs(8), ext2resize(8),ext2online(8).

Umount first the filesystem and remove the resize2fs command.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Matt Shaffer_1
Regular Advisor

Re: e2fsadm works fine from command line but fails when in script

.