Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Hello 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.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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 and savedefault N with the commandline tool grub-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:

  default saved

  # boot entry 0
  title    Default boot
  root     hd(0,0)
  kernel   /boot/vmlinuz-2.6.xx UUID=xxxxxxx ro
  savedefault

  # boot entry 1
  title    Temp boot
  root     hd(0,1)
  kernel   /boot/vmlinuz  UUID=yyyyyyyy ro
  savedefault 0

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.

share|improve this answer
    
Thanks for grub-set-default! –  osgx Feb 4 '10 at 15:01
1  
i think i'm wrong about Grub2's grub-set-default! woot! members.iinet.net/%7Eherman546/p20/… –  quack quixote Feb 5 '10 at 3:46

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.

share|improve this answer
    
It is not a "plan", but my own server on remote collocation. –  osgx Feb 4 '10 at 2:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.