LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Expanding disk space (https://www.linuxquestions.org/questions/linux-general-1/expanding-disk-space-823698/)

linux69 08-02-2010 11:22 PM

Expanding disk space
 
Hi,

I am running OpenSuse 11.3 in a virtual machine (Parallels for MAC Tiger). I initially used the default disk space of 8GB, but now I needed more space so I expanded it to 20GB, but in Linux, the partitions (2 in total) still have the same size. How can I expand them to get to use the new space I allocated?

The configuration below was originally automatically set by the system
4GB /dev/sda2 mounted on /
2.2GB /dev/sd3 mounted on /home

Thanks
W

i92guboj 08-03-2010 02:21 AM

You probably resized the partition, but not the fs inside of it. To resize ext2/3 fs's you can use the resize2fs tool. Not much idea about the rest of fs's.

pobrika 08-03-2010 04:30 AM

How to Resize a ext3 / ext3 partition.
 
Here is what I have used in the past and works for the ext2/3 filesystem.

It is always worth making a backup before playing with disks. Since it is a virtual machine you will probably get a way with a snapshop :)

1. Boot your system with a CDROM/USB using any of the rescue linux sysrescue, ubuntu or pmagic etc

2. Open a Terminal and follow the commands.
replace xXwith 2 or 3 eg /dev/sdaX with /dev/sda2

umount /dev/sdaX(just in case if it is mounted)

3. Do a filesystem check before making any changes

Code:

fsck -n /dev/sdaX


Output should hopefully be something like below:

Code:

/dev/sdaX: clean, <SOMESIZE>>

4. Removed the journal from /dev/sdaX, this will make it an ext2 partition which we can then resize

Code:

tune2fs -O ^has_journal /dev/sdaX


5. Do a filesystem check for integrity

Code:

e2fsck -f /dev/sdaX


6. resize the partition (with resize2fs without options takes your max size of the partiton)
Code:

resize2fs /dev/sdaX


7. Next run another filesystem check.

Code:

fsck -n /dev/sdaX


8. Create journal on the resized partition /dev/sdaX, this will turn sdaX from a ext2 to ext3 partition again
Code:

tune2fs -j /dev/sda3


9. Reboot the system.

Fingers crossed it should work with no issues.
Hope this helps.

bert brink 08-03-2010 07:28 AM

Please don't use all these commands as described above. There is a simple way to extend your disk and it's called qparted. Look for it on internet. There are several bootable CD's available containing a minimal linux distribution and this program. You simply boot from CD and start qparted. Qparted will detect your harddisk and it's structure. select the partition and extend the size.

i92guboj 08-03-2010 08:07 AM

Quote:

Originally Posted by bert brink (Post 4053877)
Please don't use all these commands as described above. There is a simple way to extend your disk and it's called qparted. Look for it on internet. There are several bootable CD's available containing a minimal linux distribution and this program. You simply boot from CD and start qparted. Qparted will detect your harddisk and it's structure. select the partition and extend the size.

I don't advise using QParted. In my humble opinion it is the quickest way to send your partitions to hell. It happened to me in the past, and the latest QParted release is many years old. No bugfixes ever happens in QParted, and the last version is based in qt 3.3.x.

So, please, don't disregard the usage of well tested tools that have been working for far longer than a decade in favour of tools that have (at most) alpha-quality like QParted.

If you want to use a GUI I suggest using GParted instead. At least, it's being actively developed and bug-fixed regularly.

linux69 08-03-2010 08:49 PM

Quote:

Originally Posted by i92guboj (Post 4053516)
You probably resized the partition, but not the fs inside of it. To resize ext2/3 fs's you can use the resize2fs tool. Not much idea about the rest of fs's.

I tried resize2fs /dev/sda2 1500000, so it told me "The containing partition or device is only 1311232 (4k) blocks. You requested a size of 1500000", so i tried

resize2fs /dev/sda2 1311232

it claims that it had expanded it "The file system on /dev/sda2 is now 1311232 long", but when I fdisk -l, i still see the same original size. I tried reboot, but still the same thing.

I am considering a reinstall since the system is new, but i would still like to know how it is done because i am sure i will need it in the future.

Thanks

pobrika 08-03-2010 09:29 PM

Did you run tune2fs -O ^has_journal /dev/sda2 first?

Also there is no need to specify the size on the resize command as it will resize to the maximum size of the partition.

pobrika 08-03-2010 09:34 PM

Looking at teh problem again, I see the issue.

You can not make sda2 bigger as it finishes where sda3 starts therefore there is not enough space, you will need to resize sda3 first.

You are probably best of using the gparted tools for this.


http://www.susegeek.com/utility/gpar...r-in-opensuse/

My method works great if you have backed up your partition using dd then restore to a different size disk.

linux69 08-03-2010 09:48 PM

same thing. it pretends it works, but nothing happens. first i tried your suggestion alone, rebooted, then tried it again and the resize command after. is it possible it is not saving because it is a VM?

sadly i did not have any problems installing opensuse on a VM, but i get all kinds of errors when i try to install it on other machines. i tried 3 different machines with different types and powers CPUs :(

pobrika 08-03-2010 11:05 PM

Have tried using gparted? Or use pmagic http://partedmagic.com/ just over 100Mb download.

I admit I don't use Suse myself prefer redhat / centos or crunchbang

linux69 08-04-2010 01:09 AM

Quote:

Originally Posted by pobrika (Post 4054929)
Have tried using gparted? Or use pmagic http://partedmagic.com/ just over 100Mb download.

I admit I don't use Suse myself prefer redhat / centos or crunchbang

I don't think this is what I need. I have acronis, but I am working in a virtual machine. The partition has been allocated, the problem is getting Linux to use it.

I always wanted to use redhat, but back then when it was free I chose to use slackware because it came with a book that I bought :)

Now I like openSuse because the installation looks very professional and starts up in a high resolution without having to try and figure things out. Also the fact that is sponsored by Novell makes me feel comfortable that it works well. I tried Ubuntu, but i didn't like it that much.

i92guboj 08-04-2010 02:11 AM

Quote:

Originally Posted by linux69 (Post 4054834)
I tried resize2fs /dev/sda2 1500000, so it told me "The containing partition or device is only 1311232 (4k) blocks. You requested a size of 1500000", so i tried

resize2fs /dev/sda2 1311232

it claims that it had expanded it "The file system on /dev/sda2 is now 1311232 long", but when I fdisk -l, i still see the same original size. I tried reboot, but still the same thing.

We have to separate two things here. Fdisk only sees partitions, it's fs-agnostic. So it will just list the partitions that are listed in an MBR-based partition table, and nothing else. It can list the fs-type for many fs's, but that's about it. It doesn't properly see the fs inside a given partition it just reads a byte (a number) and let us know that number in a human readable format (fs type).

You have to look at the fdisk -l output carefully to know whether the partitions are there and whether there's free space. You have to look at the bound of partitions. If there's no free space then you will have to make it using parted or one of its GUIs first. All in all, if you truly need to resize partitions and move them around I'd first backup and use GParted (there's a livecd on their site if you don't have any).

If you can't understand the fdisk -l output just post it here.


All times are GMT -5. The time now is 10:57 PM.