You have a (Debian) Linux server at some web hoster and you want to change the partition table. Unfortunately, there is just one big partition on which your linux resides.
But there is a way to do it if you have a swap partition that's big enough: Create a small Linux on your swap partion. Boot it and resize/repartition your current root partition. Finally, you can reboot your old Linux on the reduced partition. Here is a step-by-step manual showing how to do it.
Dectivate swap:
$ swapoff -a
Change the partition type of the swap partition to linux (83) using (c)fdisk.
Format the partition (hdaX stands for your swap partition):
$ mkreiserfs /dev/hdaX
Copy the whole file system there:
$ mount -o notail /dev/hdaX /mnt
$ tar clf - -C / .| tar xf - -C /mnt
Change the /mnt/etc/fstab:
If the swap partition is too small for your current file system, you can debootstrap a new one there. But check the networking configuration afterwards - otherwise you won't reach your machine.
Change /etc/lilo.conf:
Run lilo to check if /etc/lilo.conf is correct:
$ lilo
If you want, you can reboot now to make sure you didn't make any mistake so far.
Run
$ lilo -R LinuxSwap
reboot
$ shutdown -r now; exit
wait until your machine is up again, log on and check with
$ df
whether you booted from the swap space.
Now make the swap partition the default:
Reboot back to your old partition:
$ shutdown -r now; exit
When the machine is up again change /etc/lilo.conf so that LinuxSwap is the default.
Run lilo again:
$ mount /dev/hdaX /mnt
$ lilo
Reboot:
$ shutdown -r now; exit
From now on, your machine will always boot from the former swap partition.
Delete your old root partition and create a new one with parted, fdisk or cfdisk.
$ mkreiserfs /dev/hdaY
$ mount -o notail /dev/hdaY /mnt
$ tar clf - -C / .| tar xf - -C /mnt
Change the /mnt/etc/fstab so that root is /dev/hdaY
Finally, I made lilo boot the old partition again, rebooted and turned the former swap partition back into a swap partition.
I recommand running lilo from the new root disk.
Check that in /mnt/etc/lilo.conf, the default points to the new root disk.
Change the root device back to /dev/hdaY in /mnt/etc/fstab.
Run lilo in chroot:
$ mount /dev/hdaX /mnt/mnt/
$ chroot /mnt/
$ lilo
(You can ignore the warnings)
Now you can reboot:
$ exit
$ shutdown -r now;exit
Once you are logged in again, check again where you are:
$ df
Turn /dev/hdaX back to swap partition
$ mkswap /dev/hdaX
Change the partition type of /dev/hdaX back to Linux Swap (82) with parted, fdisk or cfdisk
Edit /etc/fstab and remove the comment from swap
Reboot one more time and check whether you have again swap:
$ df
Now you are done!
This document is free; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
This document is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You can get a copy of the GNU GPL at at
Written by .
--- Fight spam with alias addresses from safersignup.com! ---