Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

What program do you recommend me for extending the Ubuntu filesystem (the ext3 partition "/")? Except for gparted which has to boot from USB stick... is there any other software that I can try directly?

Thanks

share|improve this question

migrated from stackoverflow.com Feb 26 '11 at 22:51

This question came from our site for professional and enthusiast programmers.

2  
Never extend a mounted filesystem. Boot from GParted. –  mathepic Feb 27 '11 at 1:57
1  
GParted doesn't need to be booted from a USB stick. And yes, don't extend a mounted file system. –  boehj May 8 '11 at 22:35

3 Answers 3

I do these things always manually using fdisk and resize2fs, however this is a little dangerous if you don't know what to do.

The steps would be as follows. You need to be root for that or use sudo in front of the commands. No guarantees for you data. Use at your own risk.

First I recommend to make a backup of your data. Then backup the existing partition table in ASCII and binary form to a usbstick using:

fdisk /dev/sda -lu > /media/usbstick/sda.txt
dd if=/dev/sda of=/media/usbstick/sda.mbr count=1

I assume here that your harddrive is called /dev/sda here.

You can then first resize your partition by removing it and recreating it bigger at the exact same position (!) as before. You need of course some space after the partition on your harddrive.

fdisk -u /dev/sda

Enter p followed by ENTER to print the existing partition table, remember the Start position of the partition. Delete it using d and the partition number and recreated it with n at the exact same start position. Write the table with w.

Then use resize2fs /dev/sda1 (or whatever you partition number is) to resize the file system to the new partition size. This should work while the file system is mounted. An off-line resize is however more recommended.

share|improve this answer
    
This will not work while the filesystem is mounted because fdisk can not update the in memory partition table while the disk is in use. –  psusi Apr 8 '11 at 19:22
1  
@psusi: This will work while the filesystem is mounted, the kernel will just keep using the old partition table until the next reboot or after you run partprobe or kpartx. Newer versions of fdisk tell you that after you exit it. I always did it like that and never had a problem. If you don't have partprobe or kpartx simply reboot afterwards. –  Martin Scharrer Apr 8 '11 at 19:31
    
the fdisk part will work and the kernel will keep using the old partition table, but the resize2fs will fail since the kernel is still using the old partition table. You can use partprobe or kpartx to reload that specific partition when fdisk fails because a DIFFERENT partition on the disk is in use ( and parted/gparted take care of this for you ), but they still can not update that partition to the new size if it is in use. –  psusi Apr 9 '11 at 3:08

Resizing / is safe only with live cd. Use GParted or Ubuntu/Mint live CD. Linux Mint has GParted installed on live CD.

share|improve this answer

If you are using LVM, then simply run lvextend to increase the size of the lv, then resize2fs to expand the fs to use the additional space. If you are not using LVM, then it is not possible to do while the system is in use.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.