LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-24-2005, 06:32 AM   #1
Dee-ehn
Member
 
Registered: Apr 2004
Distribution: Suse 9 pro
Posts: 52

Rep: Reputation: 15
Resizing a running Ext3 partition


Some days ago my system's harddrive started to produce errors, so I had to put in a new one. The new one is somewhat bigger than the old one, but that's ok.

I ghosted (I had to use ghost because other imaging problems didn't want to image an errornous source drive) my old to my new drive. Everything works well, but the root partition on the new drive has the size of the old root partition; a couple of gigabytes remains unused.

How can I resize this partition without loosing all data on it? Is there a clever way to do so?

Thanx in advance
 
Old 01-24-2005, 07:17 AM   #2
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
well, you could use a partitionning program. use google to look for one.
 
Old 01-24-2005, 07:26 AM   #3
Dee-ehn
Member
 
Registered: Apr 2004
Distribution: Suse 9 pro
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by mrcheeks
well, you could use a partitionning program. use google to look for one.
I looked into parted but I don't know how I can find what part of the disc isn't used or seen.

When I fire up fdisk it says that there are no free sectors anymore..
 
Old 01-24-2005, 08:56 AM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Can you post the results of the command: fdisk -l and list what partitions are used for and what partition you want to resize?
 
Old 01-24-2005, 09:37 AM   #5
Dee-ehn
Member
 
Registered: Apr 2004
Distribution: Suse 9 pro
Posts: 52

Original Poster
Rep: Reputation: 15
Sure thing, here it is!

Code:
Disk /dev/hda: 8455 MB, 8455200768 bytes
16 heads, 63 sectors/track, 16383 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1         125       62968+  83  Linux
/dev/hda2             126       16383     8194032    5  Extended
/dev/hda5             126        1118      500440+  82  Linux swap
/dev/hda6            1119       16383     7693528+  83  Linux

Disk /dev/hdc: 20.5 GB, 20525137920 bytes
255 heads, 63 sectors/track, 2495 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1               1         609     4891761   83  Linux
/dev/hdc2             610        2495    15149295    5  Extended
/dev/hdc5             610        1218     4891761   83  Linux
/dev/hdc6            1219        2495    10257471   83  Linux

Disk /dev/hdd: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdd1               1        9729    78148161   83  Linux

Disk /dev/hde: 80.0 GB, 80026361856 bytes
16 heads, 63 sectors/track, 155061 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hde1   *           1      155061    78150712+  fd  Linux raid autodetect

Disk /dev/hdf: 80.0 GB, 80026361856 bytes
16 heads, 63 sectors/track, 155061 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdf1   *           1      155061    78150712+  fd  Linux raid autodetect

Disk /dev/hdg: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


Disk /dev/hdh: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
If I do a df -h I get this:
Code:
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda6             5.1G  4.0G  851M  83% /
/dev/hdc1             4.6G  698M  4.0G  15% /vmware/easygate
/dev/hdc5             4.6G  1.7G  3.0G  36% /vmware/win2k
/dev/hdc6             9.7G   33M  9.6G   1% /ftp
/dev/hdd1              74G   25G   50G  34% /download
/dev/md1              147G  105G   43G  72% /md/1
/dev/md0               74G   61G   14G  82% /md/0
none                  252M     0  252M   0% /dev/shm
As the hda contains two more partitions: /boot (64mb or so) and a swap partition (512mb) I don't know what to do and where to look. I kinda miss 2Gb.
 
Old 01-24-2005, 09:48 AM   #6
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Quote:
/dev/hda6 1119 16383 7693528+ 83 Linux
That says you have root on a nice biggggg partition.

Quote:
Filesystem Size Used Avail Use% Mounted on
/dev/hda6 5.1G 4.0G 851M 83% /
This says that you need to resize the filesystem to fit the partition size.

The partition needs to be in an unused condititon for this so I boot up with a live cd like knoppix.
Note: On my FC3 box the program called e2fsck is not current enough on the live cd so I use the FC3 resue cd for that. You shouldn't have that problem with Suse 9 but thought I'd mention it just in case.
Code:
e2fsck -f /dev/hda6
resize2fs -f /dev/hda6
 
Old 01-24-2005, 11:18 AM   #7
Dee-ehn
Member
 
Registered: Apr 2004
Distribution: Suse 9 pro
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by homey
That says you have root on a nice biggggg partition.


This says that you need to resize the filesystem to fit the partition size.

The partition needs to be in an unused condititon for this so I boot up with a live cd like knoppix.
Note: On my FC3 box the program called e2fsck is not current enough on the live cd so I use the FC3 resue cd for that. You shouldn't have that problem with Suse 9 but thought I'd mention it just in case.
Code:
e2fsck -f /dev/hda6
resize2fs -f /dev/hda6
Euh.. my / partition is only 7.5Gb big... that's not big, right?
 
Old 01-24-2005, 11:32 AM   #8
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Sorry got the numbers mixed up. Do you want to make that partition larger?
 
Old 01-24-2005, 11:40 AM   #9
Dee-ehn
Member
 
Registered: Apr 2004
Distribution: Suse 9 pro
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by homey
Sorry got the numbers mixed up. Do you want to make that partition larger?
Well I have this part of the disk that Fdisk doesn't see (but it must exist; I guess Ghost messed that up) and I want either to add that to the hda6 partition or make a new partition..
 
Old 01-24-2005, 12:03 PM   #10
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Fdisk -l /dev/hda is just on showing you the available unpartitioned space on your drive. If you're interested, I have a script for showing that.
You copy this into a file named test
chmod +x test
Then you run it like this .... ./test /dev/hda


Code:
#!/bin/bash
##### This script calculates hard drive space.
##### example:  ./drive /dev/hda

##############################################
#  Ensure that root is running the script.
#
WHOAMI=`/usr/bin/whoami`
if [ $WHOAMI != "root" ]; then
	echo
	echo "You must be root to run this!"
	echo
      exit 1
fi
##############################################

usage()
{
        echo "Usage: $0 /dev/hd#"
        exit 1;
}

test "$1" || usage

if ! [ -e $1 ]; then
    echo "$1 does not exist. Exiting."
    exit 1
fi

if [ -e $1 ]; then

drive=`/sbin/sfdisk -s $1`
echo
for i in `/sbin/sfdisk -l $1 | \
grep -e "^[/dev]" | awk '{print $1}'`;
do
a=`/sbin/sfdisk -s $i 2> /dev/null`
part=$((($a + 0) / 1024))
totalused=$(($totalused + ($a + 0)))
echo "Partition $i used $part MB"
done
echo

else
    exit 1
fi

#####
size=$(($drive / 1024))
used=$(($totalused / 1024))
free=$((($drive - $totalused) / 1024 +1))
#
echo " Total drive size    $size   MB"
echo " Partitioned size    $used   MB"
echo " Unpartitioned size  $free   MB"
echo
echo
#####
 
Old 01-24-2005, 12:13 PM   #11
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Device Boot Start End Blocks Id System
/dev/hda1 * 1 125 62968+ 83 Linux
/dev/hda2 126 16383 8194032 5 Extended
/dev/hda5 126 1118 500440+ 82 Linux swap
/dev/hda6 1119 16383 7693528+ 83

Ok , sorry about being the air head today. That shows that your Extended partition /dev/hda2 is way too small. I would ghost your root partition /dev/hda6 to a safe location the remove #6, #5 ,#2 partitions.
Then, using fdisk, recreate the extended partition #2 and have it use up the rest of the drive.
Then, using fdisk, recreate #5 ( as a logical partition ) make it the swap partition and run the command: mkswap /dev/hda5
Then, restore the ghost image to partition #6 and make it the size you want.

Last edited by homey; 01-24-2005 at 12:14 PM.
 
Old 01-24-2005, 05:38 PM   #12
TieN
LQ Newbie
 
Registered: Feb 2003
Location: UK
Distribution: Slackware/Gentoo
Posts: 19

Rep: Reputation: 0
SystemRescueCd

Well being a very lazy man i like this (http://www.sysresccd.org/) bootable tools cd. It has parted, a nice partition magic clone and partimage a ghost clone, both of which are easy to use. QtParted is really sweet and runs a quality framebufffer gui thingy and partimage has a simple curses ui, however i have found partimage to be unreliable with ntfs.

Hope this is handy for someone
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Resizing an ext3 LVM Partition PenguinPwrdBox Linux - Software 1 09-04-2005 02:34 AM
Resizing/reformatting ext3 partition mark.johnson Linux - Hardware 3 04-25-2005 01:48 PM
Resizing Ext3 partition to replace XP Sigmund Linux - General 7 01-26-2005 10:48 AM
Resizing a partition (ext3) herc Linux - Hardware 1 12-26-2003 04:17 PM
Resizing EXT3 partition using parted??? Hegemon Linux - General 1 01-21-2003 12:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration