I've got free unpartitioned space which I'd like to use to expand my root partition. The server runs under Debian Squeeze and I'm administrating it with no GUI. How can I do that?

Do I need the free unpartitioned space to be right after /dev/sda1 ?

Here is my list of partitions (as you can see the total disk space is bigger than the total size of my partitions, so I have unpartitioned space):

admin@ks387290:/etc/mysql$ sudo fdisk -l

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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: 0x0001cee1

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1306    10485760+  83  Linux
/dev/sda2            1306       53523   419435689   83  Linux
/dev/sda3          121536      121601      525536   82  Linux swap / Solaris
/dev/sda4           53524      121535   546306390    5  Extended
/dev/sda5           53524      121406   545270166   83  Linux

Partition table entries are not in disk order

admin@ks387290:/etc/mysql$ df -h
Sys. de fichiers    Taille  Uti. Disp. Uti% Monté sur
/dev/sda1              10G  3,8G  5,7G  40% /
tmpfs                 994M     0  994M   0% /lib/init/rw
udev                   10M  152K  9,9M   2% /dev
tmpfs                 994M     0  994M   0% /dev/shm
/dev/sda2             397G  233M  377G   1% /home
/dev/sda5             512G  3,0G  483G   1% /var
  • 1
    You'll get much better answers if you actually ask a question. – Safado Feb 24 '12 at 17:14
  • Your answer is YES – Tablemaker Feb 24 '12 at 17:17
  • Sorry guys, it's edited. – koskoz Feb 24 '12 at 17:25

Your life will be MUCH easier if you move things off of your root partition onto another mountpoint rather than trying to expand /dev/sda1.

If you really want to expand it with your current setup, you'll pretty much be doing the equivalent of a backup/restore.

| improve this answer | |
  • Agreed. Try copying your /home folder (or /usr or whatever one you want) over to the new partition and create an entry for it in /etc/fstab – Safado Feb 24 '12 at 19:34
  • I can move all my file system to another partition without losing datas? I can have my root partition at the end, meaning sda6? – koskoz Feb 25 '12 at 8:53
  • Instead of putting more data into /, put it onto another filesystem. – MikeyB Feb 27 '12 at 18:09

The easiest is to reboot with a gparted boot cd and use that to resize. Where is you root partition? Is it /dev/sda1? What are sda2, sda5? What do you mean "by no GUI"?

| improve this answer | |
  • No GUI means I do it in command lines, so no GParted. sda1 is the root partition, sda2 the /home partition, sda3 the swap and sda5 /var. I understood that sda4 is used by sda5. – koskoz Feb 25 '12 at 8:51

You have very little if any free space that I can see (remember to account for swap space, and to use df -H (rather than -h) for the same size GB as fdisk and the disk manufacturer). Look at the cylinder counts in the start and end columns of fdisk.

In theory you could boot off a live cd and use parted and grow or shrink your filesystems (depending on what sort of filesystems they are, eg ext3 or xfs) but you'll gain nothing and risk losing the lot.

You could think about carving /var into smaller partitions but really, is there any point?

| improve this answer | |
  • Can I delete sda2, make it smaller and then delete sda1 and make it bigger, starting at the first block? – koskoz Feb 26 '12 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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