Debian root partition resizing

I just noticed that the root partition of my not-so-long-ago configured server is only 5gb

thats not much seeing as i allready use 4gb and still need to install a lot of things...

i was foolish enough to use the default config from OVH assuming they know their stuff :P

since i have some data on the data partition it would be a pain in the ... to backup and reconfigure it all

is it possible to repartition the drive to use a new part of the drive say 15-20gb without data loss ? by simply copying the root partition to a new place (from sda2) ? i can live with loosing the 5gb of the start of the drive :P


heres df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             5.0G  3.9G  897M  82% /
tmpfs                 998M     0  998M   0% /lib/init/rw
udev                   10M  144K  9.9M   2% /dev
tmpfs                 998M     0  998M   0% /dev/shm
/dev/sda2             226G  7.2G  208G   4% /home

and fdisk -l

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000db26

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         653     5242880+  83  Linux
Partition 1 does not end on cylinder boundary.    <== now this is bad.. thx OVH :F
/dev/sda2             653       30336   238426112   83  Linux
/dev/sda3           30336       30401      526016   82  Linux swap / Solaris

What I think that I'd do is to something like this:

  1. cd /home
  2. mkdir home
  3. mv * home
  4. put the contents of the current root directory to /home using dump/restore
  5. edit the new fstab to show root as /dev/sda2 and /dev/sda1 as spare.
  6. You'll have to run grub to point the booting to the right location (pretty easy).
  7. And you have a large root on /dev/sda2 and maybe use /dev/sda1 as scratch space.

I think that this will be easier than trying mess with repartitioning.


For offline resizing partition, I am using GParted Live CD.

You can do these operations online (with the system powered on), but it would be more difficult and with grater risk. For this you will need to unmount the /home partition, shrink it, move the data at the end of partition, edit partition table, grow / partition online, remount /home.