I want to resize (shrink) root ext3 fs partition of remote Debian 5.0 system. There is no LVM.
Is it possible without using a livecd? E.g. via custom initrd.img.
And second problem - Can I instuct grub to use different options only at first next reboot, but not at the second and subsequent.
It's certainly possible; the only thing you need to shrink your root filesystem is another root filesystem to boot into.
I don't know if a custom initrd.img will be sufficient. (It might be. I'd love to hear a way to do it.)
If it were me, I'd make a minimal system installation on another partition, containing only the necessary tools. You'd reboot into this partition and resize your primary root partition from there. (If you're using a Debian-based distribution, the article Installing Linux from Linux describes a good method for doing this.)
If your system drive is full but you have a swap partition, you might temporarily repurpose it to be that secondary root partition. Since the secondary system only needs the base system, filesystem tools, and SSH, it can live on a very small partition. Your system can probably live without swap while you're setting up for this procedure.
As for Grub, with Grub v1 you can use the Grub menu commands
default saved
andsavedefault N
with the commandline toolgrub-set-default
to set a one-time-boot option. I wrote up a how-to for doing boot-once with Grub v1 in another answer.The short version: setup your
/boot/grub/menu.lst
thusly:Grub will boot the "Default boot" entry by default, and if you want to reboot into the "Temp boot" entry you can run
grub-set-default 1
and reboot. The reboot will use the temporary default, boot the "Temp boot" entry, and save the "Default boot" entry as the next reboot.With Grub2, the basic idea is the same, though configuration is obviously a little different. This site has lots of info on Grub2 and reports that
grub-set-default
works under Grub2 as well.I would expect you could put everything you need into your initrd, and then unmount root (I'd put everything you normally have in your initrd, plush the ssh or what ever for remote, + the fs etc tools), this way you don't risk much.
The other thing is, what happens if you screw up? The added down time might make another plan a better choice, such as adding a disk to the system.