JP Vossen on 27 Feb 2012 20:30:12 -0800

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] VI without a swapfile?

On 02/27/2012 08:57 PM, wrote:
Date: Mon, 27 Feb 2012 20:02:53 -0500
From: Jeff Bailey<>
Without getting into all the gory details, I have a loopback filesystem
mounted (a file containing a filesystem) which is considered 100% full
(according to "df").

I need to edit a file on that mount.  "vi" complains about not being
able to create a swapfile, but allows me to edit.  The problem is that I
can't save an edited version, even if all I do is delete lines.  I think
this stems from the fact that vi tries to save a backup copy, and fails
since there's no room.

Short version: edit elsewhere or use 'ed'.

Long version:
If the changes are non-trivial, I think the "edit elsewhere and cat back into place" is the best solution. In my experience, all the other solutions I tried like vi, 'sed -i', 'perl -i' actually wrote elsewhere and moved. The "-i" for "in place" really means "duplicate owner & perms." If you don't believe me, run 'stat' before and after and check the inodes.

Having said that, 'ed' should work, if it is actually installed on the "minimal" system. It's required by SUS/POSIX, but depending on how formal and minimal the file system is trying to be... 'ed' is even scriptable, though that sounds like overkill in this case. Remember that 'ed' is a line editor designed for teletypes, so it's even more stone knives and bear claws than 'vi'. (And I say that with affection, since I *like* vi. :)

You will likely need a cheat sheet, see the man page on basically any Unix or Linux system installed in the last, oh, 35 years or so... :-) Or start at

I used 'ed' for recipe 17.14 Editing a File in Place in the _bash Cookbook_ precisely because (in my 'stat' tests at the time) it really does overwrite the same file, it's scriptable, and it's always there.

Ha, just for fun I went and looked and I still have c:\windows\system32\edlin on XP. I don't find it on Win7, though you can get a FreeDOS version with support for long file names now. is short and interesting and just proves there is *nothing* more permanent than a temporary solution.

JP Vossen, CISSP            |:::======|
My Account, My Opinions     |=========|
"Microsoft Tax" = the additional hardware & yearly fees for the add-on
software required to protect Windows from its own poorly designed and
implemented self, while the overhead incidentally flattens Moore's Law.
Philadelphia Linux Users Group         --
Announcements -
General Discussion  --