I have a problem and I appreciate if anyone can help me.


fdisk -l:

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d89a5

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1        88086528   625141759   268527616    5  Extended
/dev/sda2   *        2048    80273407    40135680   83  Linux
/dev/sda4        80273408    88086527     3906560   82  Linux swap / Solaris

Partition table entries are not in disk order


df -h:

Filesystem                                              Size  Used Avail Use% Mounted on
rootfs                                                   38G   35G  1.1G  98% /
udev                                                     10M     0   10M   0% /dev
tmpfs                                                   397M  968K  396M   1% /run
/dev/disk/by-uuid/bcc39c18-9057-488c-a281-68377e15ce7f   38G   35G  1.1G  98% /
tmpfs                                                   5.0M     0  5.0M   0% /run/lock
tmpfs                                                   1.6G  1.4M  1.6G   1% /run/shm



sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=505836,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=405884k,mode=755)
/dev/disk/by-uuid/bcc39c18-9057-488c-a281-68377e15ce7f on / type ext4 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1593060k)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)

I've read the post "How can I expand ext4 partition size on debian" in which Stéphane Chazelas came up with a good solution, by using fdisk -u /dev/sda. But as you see exactly after Linux partition (/dev/sda2) the swap partition is placed, so means I can't extend sda2 by adding more space at the END cause it will overlap with swap.

Now is it possible to extend sda2 by overlapping with swap and add more space, then START the swap exactly after the END of sda2!? In other word, the swap will be move forward and then the sda2 can grow as much as needed, so we can start the swap exactly after it!! If it's completely wrong, would anyone please help me?


  • Is keeping the machine up during all this part of the game? (Disk sizes and no LVM sound like a desktop machine?) Commented Dec 5, 2014 at 18:55
  • @UlrichSchwarz I couldn't understand your question completely. I can say that it's a desktop machine.
    – mabedis
    Commented Dec 7, 2014 at 17:06
  • ok, so that means that things like "restart from a Live CD and do stuff" are an option, so, yeah, DopeGhoti's approach looks good. (Things are more difficult if you can't restart the machine because, for example, you're running a web server on it that needs to stay available during the whole process.) Commented Dec 7, 2014 at 17:20
  • Thanks for your help and recommendation. The solution @DopeGhoti come up with, seems to be good. I'm backing up my data, so then I can apply his solution. I'll give the result in his answer after I try it.
    – mabedis
    Commented Dec 9, 2014 at 15:38

1 Answer 1


First, back everything up, as you should always do when faffing about with partitions.

Turn off the swap with swapoff /path/to/swap_partition (optional), boot up a GPartEd LiveCD or other live distro with GPartEd. Remove the swap partition, extend your sda2 partition as desired, and create a new swap partition in the remaining space if desired.

  • Thanks for your help. Your suggestion worked very well. I did 'swapoff /dev/sda4' and then I used Boot-Repair-Disk LiveCD in which contains Gparted and after that I deleted swap and extended 'sda2'. Thanks a lot
    – mabedis
    Commented Dec 13, 2014 at 18:13
  • Excellent; I'm glad to hear this worked for you!
    – DopeGhoti
    Commented Dec 23, 2014 at 17:30

You must log in to answer this question.

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