0

I have a Debian system which has been set up quite a long time ago with default partition sizes as suggested by the installer. Turns out that the root and /usr partitions are too small for my needs. For instance, I don't have enough space to install a new kernel.

Disk layout is as follows:

# df|grep sdb
/dev/sdb1               264445    235155     15637  94% /  
/dev/sdb9            472007120 292643816 155386696  66% /home
/dev/sdb8               381138     27042    334418   8% /tmp
/dev/sdb5              4806904   4276636    286084  94% /usr
/dev/sdb6              2885780    845500   1893692  31% /var

# fdisk -l /dev/sdb

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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: 0x000c26ca

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          34      273073+  83  Linux
/dev/sdb2              35       60801   488110927+   5  Extended
/dev/sdb5              35         642     4883728+  83  Linux
/dev/sdb6             643        1007     2931831   83  Linux
/dev/sdb7            1008        1053      369463+  82  Linux swap / Solaris
/dev/sdb8            1054        1102      393561   83  Linux
/dev/sdb9            1103       60801   479532186   83  Linux

I would like to shrink the /home partion (which is located at the "end" of the disk) by cutting about 10 GB from the beginning and then giving 5 GB each to the root partition and /usr. This would mean to move /dev/sdb[2-8] to make room for the additional space for root and /usr.

The system is console-only.

Is there a way to do these changes without loosing data on root, /usr, /var and /home?

1 Answer 1

1

Your partition layout is something like this (correct me if I'm wrong):

| root | usr | var | tmp | home |
       |        extended        |

To do what you want, you will have to:

  • Shrink /home in 10GB (and maybe move it 10GB to the right);
  • Move to the right 10GB /var, /tmp and /usr;
  • Grow /usr in 5GB;
  • Shrink the logical partition in 5GB;
  • Grow / in 5GB

I would not say it is impossible, but I see many ways this could go wrong.

I faced a somehow similar situation and decided to backup everything to external disks and recreate everything. If you have the resources to do this I advise you to do so, as you reduce a lot the risk of data loss and you should save a lot of time (move/shrinking partitions can take some time).

If you don't have the possibility to do as me, as you are running in a terminal system I think the best tool to do that is parted. It lets you resize and move partitions.

Note: if you choose to recreate everything, I strongly advise you to use LVM. In a situation like this it would make unnecessary to move partitions and growing/shrinking much more easy and safe.

Edit

As bodhi said, if you have the possibility to use a live CD/USB with gparted (which is included in Ubuntu) it will make your task much easier. GParted lets you resize and move partitions by just dragging.

1
  • 1
    parted will work , it is the back end for the graphical tool gparted. I highly advise you run it from a live CD as you can not resize partitions while they are mounted, and if you are booting a live CD, might as well use gparted. +1 to using LVM in the future.
    – Panther
    May 16, 2013 at 17:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .