# I want to stretch my partition. [SOLVED]

## Nebetsu

I tried using qtparted but it doesn't want to resize it. I have it like this:

hda1: linux (ext3): ~18GB

hda2: free space: ~18GB

hda3: linux swap: ~1GB

What I want to do is stretch hda1 so it fills up the free space. Does anyone know how I can go about doing this?Last edited by Nebetsu on Wed Oct 11, 2006 12:57 am; edited 1 time in total

----------

## yabbadabbadont

I believe that you have to delete the partition containing the free space (hda2) so that the partitioner will see that it is truly free.  Then you should be able to resize hda1.

Edit: You should be able to do all of this from qtparted.

----------

## Nebetsu

I can't delete it. It's just free space in between hda1 and hda3 I guess.

----------

## drwook

Well I've done exactly this a good number of times using qtparted...  Are you sure there's no partition there where you think there's free space?  Have you tried right clicking and seeing if there's a delete option?  If so, there's a partition there  :Wink: 

Personally I'd always advise a backup before doing this...  Never had a problem myself but...

----------

## x22

All partitions on hda have to be unmounted to do this.

If qtparted does not work, you may use gparted or parted or fdisk + hdparm (for reloading partition table) + resize2fs.

----------

## drwook

 *x22 wrote:*   

> All partitions on hda have to be unmounted to do this.
> 
> If qtparted does not work, you may use gparted or parted or fdisk + hdparm (for reloading partition table) + resize2fs.

 

Interestingly I'm fairly certain I've done this inside a running system a couple of times without unmounting  :Wink:   Although generally I use a knoppix CD so I don't have to care what's on the system already...

gparted's nice too, but essentially does the same thing.  If gparted works and qtparted doesn't, I'd think about opening a bug (probably upstream)...

----------

## Sachankara

A tip: Buy a new harddisk, create a Device Mapper volume group on it, create a couple of partitions (logical volumes) on it in ReiserFS or XFS and then transfer all your data from the old drive to the new one. With LVM you'll be able to resize partitions on live file systems, while you're using them and they are mounted. LVM also have other cool stuff like mirroring, snapshots, bad block relocation, etc. It's actually quite simple to use.  :Smile: 

For example: If I want to add 1 GiB to my home partition, all I have to do is this: 

```
$ lvextend -L+1G /dev/volumegroup/home

$ xfs_growfs /home
```

----------

## syg00

Let's see some real information - output from "fdisk -l".

----------

## padoor

if u delete the hda3 it might see the free space.

cfdisk also may be useful to get some more info about the hdd.

----------

## Nebetsu

 *syg00 wrote:*   

> Let's see some real information - output from "fdisk -l".

 

```
yajuu nebetsu # fdisk -l

Disk /dev/hda: 40.0 GB, 40037760000 bytes

255 heads, 63 sectors/track, 4867 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/hda1               1        2350    18876343+  83  Linux

/dev/hda3            4701        4867     1341427+  82  Linux swap / Solaris
```

I cut off the part about my other hard drives because I don't think that matters. 

And I've tried to right click and delete the partition. That's the first thing I did.

----------

## yabbadabbadont

You will have to be booted from a live cd in order to resize a partition on the drive.  Or at least be booted using a harddrive other than the one containing the partition you wish to change.  Basically, the drive can't be in use at all when you do it.

----------

## syg00

I generally also recommend Knoppix for all "recovery" type work, but in this case the gparted livecd would probably be the go.

There is nothing I can see in the fdisk list to indicate why the resizing shouldn't work.

Personally I generally do these things by hand rather than use a GUI.

However, last time I tried to resize an ext2(3), I could never get it to complete successfully. Others have had better luck.

Now I just don't bother - I delete the partitions(s) involved, create new, make the filesystem of choice and restore. May take a little longer, but you know what happened at each stage. And it's not done that often in a normal environment.

The suggestion to use LVM is also something to think about. If I didn't screw with my systems so much I would use it without question.

----------

## Nebetsu

It's not mounted. It's not being used. I'm using QTParted. It's not resizing... >>

----------

## padoor

Device Boot      Start         End      Blocks   Id  System

/dev/hda1               1        2350    18876343+  83  Linux

/dev/hda3            4701        4867     1341427+  82  Linux swap / Solaris

the cylinder numbers are not continuous .there is a gap from 2351 to 4700

u can afford to delete the swap for temporary and make the continuous space available

than only it can see the freespace to resize .after resizing u can make swap again.

----------

## devsk

 *Nebetsu wrote:*   

>  *syg00 wrote:*   Let's see some real information - output from "fdisk -l". 
> 
> ```
> yajuu nebetsu # fdisk -l
> 
> ...

 you don't require to boot into any livecd or use any specialized tools to handle this particular case. boot into this system. login as root. swapoff the swap. Use fdisk and delete hda3. delete hda1. recreate hda1 with 'n' and 'p' with start 1 and end 4700. recreate hda2 with 'n' and 'p' with the rest of cylinders. change its type to 82 with 't'. write the table with 'w'. reboot. 2.6 kernels allow online resizing. Once booted, login as root and use resize2fs to resize /dev/hda1 to new size. change fstab to point swap at hda2.

Remember to make full backup on another disk or host before trying this. Do not attempt if you are scared of fdisk and don't know what it does.

----------

## Nebetsu

Would I have to use Norton Ghost or would I be able to do a standard copy?

----------

## devsk

 *Nebetsu wrote:*   

> Would I have to use Norton Ghost or would I be able to do a standard copy?

 you mean for the backup? use whatever you normally feel comfortable with i.e. something which you have used before and you know works for you. if ghost it is, use ghost. I typically use dar for backups because it allows to do incremental backups.

----------

## padoor

i would say the backup is not necessary if the parted is used carefully.

u can boot from the cd and run parted.

delete the hda3 and extend the hda to higher cylinder numbers and save.

make hda2 swap and save change the drive letter in fstab also.

it should not kill the existing data or installation.

if u are not sure how to do then better back it up and do afresh partition.

think of how u restore the backed up installation after making new partitions.

----------

## devsk

 *padoor wrote:*   

> i would say the backup is not necessary if the parted is used carefully.

 backup is always necessary....  :Wink: 

----------

## drwook

 *devsk wrote:*   

>  *padoor wrote:*   i would say the backup is not necessary if the parted is used carefully. backup is always necessary.... 

 

Well, they only have to be necessary once for them to be worthwhile...  :Wink: 

----------

## Gentree

 *Nebetsu wrote:*   

> It's not mounted. It's not being used. I'm using QTParted. It's not resizing... >>

 

qtparted is a program not on OS. I suggest you clarify what you think you are doing before proceeding.

It may help others if you clarify here once you've worked it out.

You have ample info here on what to do but thread carefully, you have one foot firmly in the abyss.  :Cool: 

----------

## Nebetsu

 *Gentree wrote:*   

>  *Nebetsu wrote:*   It's not mounted. It's not being used. I'm using QTParted. It's not resizing... >> 
> 
> qtparted is a program not on OS. I suggest you clarify what you think you are doing before proceeding.
> 
> It may help others if you clarify here once you've worked it out.
> ...

 

I used the Knoppix live cd and made sure that none of my drives were mounted. Then I opened QTParted by clicking on it in the K menu. Then I tried to resize it, but the resize option in the menu and the one that appears when you right click the partition has been greyed out and does not work.

----------

## yabbadabbadont

If you have a swap partition on any of your drives, knoppix will use it by default unless you specify "noswap" as an option when you boot the cd.  If you didn't do that you can, from a terminal, issue "swapoff -a" to disable swap.  You can use the "free" command in a terminal to see if swap is currently active.

----------

## Nebetsu

 *yabbadabbadont wrote:*   

> If you have a swap partition on any of your drives, knoppix will use it by default unless you specify "noswap" as an option when you boot the cd.  If you didn't do that you can, from a terminal, issue "swapoff -a" to disable swap.  You can use the "free" command in a terminal to see if swap is currently active.

 

Disabled swap in Knoppix and it still won't resize.

----------

## yabbadabbadont

 *Nebetsu wrote:*   

>  *yabbadabbadont wrote:*   If you have a swap partition on any of your drives, knoppix will use it by default unless you specify "noswap" as an option when you boot the cd.  If you didn't do that you can, from a terminal, issue "swapoff -a" to disable swap.  You can use the "free" command in a terminal to see if swap is currently active. 
> 
> Disabled swap in Knoppix and it still won't resize.

 

Sounds like it is time to do a full backup and repartition the disc...

----------

## Nebetsu

 *yabbadabbadont wrote:*   

>  *Nebetsu wrote:*    *yabbadabbadont wrote:*   If you have a swap partition on any of your drives, knoppix will use it by default unless you specify "noswap" as an option when you boot the cd.  If you didn't do that you can, from a terminal, issue "swapoff -a" to disable swap.  You can use the "free" command in a terminal to see if swap is currently active. 
> 
> Disabled swap in Knoppix and it still won't resize. 
> 
> Sounds like it is time to do a full backup and repartition the disc...

 

Ok. Would I have to use Ghost to do it or would I just be able to copy and paste everything to another hard drive? I know with Windows, it screws up if you try to copy and paste everything and you pretty much have to Ghost it. Does Linux have the same issue?

----------

## Gentree

seems like you're keen to go ahead without backups so please dont come running for help if you blow out your system.

devsk has given you the basic moves. One thing he did not say explicitly is that you can delete partitions in tools like fdisk and parted and as long as you recreate them before saving the partition table you are OK. Deleting an entry does not wipe the partition data. But if you save the partition table without restoring it you will not be able to find that data.

You want to change the end of hda1 but the begining must be _exactly_ the same. I see fdisk is giving you + signs , this means the boundaries it is showing are not exact. Either change units or try parted. (I dont say it's "better" but in this case I find it clearer than fdisk.)

I suggest you start to read the doc before diving in. This is one area where you really _need_ to know what you are doing before you start. 

You seem to skip over the advise that is telling how to do this and just post more questions. 

Your current approach of "I'm using QTparted and it's greyed out , what gives?!" indicates that you do not have the knowlege to proceed.

I suggest you get up to speed on this while you still have hda1.

 :Cool: 

----------

## yabbadabbadont

 *Nebetsu wrote:*   

>  *yabbadabbadont wrote:*    *Nebetsu wrote:*    *yabbadabbadont wrote:*   If you have a swap partition on any of your drives, knoppix will use it by default unless you specify "noswap" as an option when you boot the cd.  If you didn't do that you can, from a terminal, issue "swapoff -a" to disable swap.  You can use the "free" command in a terminal to see if swap is currently active. 
> 
> Disabled swap in Knoppix and it still won't resize. 
> 
> Sounds like it is time to do a full backup and repartition the disc... 
> ...

 

Yes.  You would need to use some form of backup software, like dar.  You might also look into using the stage4 backup method found here: http://blinkeye.ch/mediawiki/index.php/GNU/Linux_System_Backup_Script_%28stage4%29

I have used the stage4 method a few times without any major issues when restoring.

----------

## Roman_Gruber

Hi

use the gparted live cd or live usb version

see my answer

https://forums.gentoo.org/viewtopic-t-504928-highlight-.html

----------

## Nebetsu

tw04l124: Thank you so much! The live CD was easy to use and it took less than 10 minutes. You are my hero!

----------

