LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-08-2006, 08:20 AM   #1
MuddledAB
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Rep: Reputation: 0
Resizing partition after installation


Sob _ I've just lost what I'd written by being logged out and I thought I'd cleared all the cookies!
I'll give it another go.

Have a 60G hard-drive which ran Windows ME (FAT32, I think)until just before Xmas when it finally died leaving me unable to access the system. I managed to get all the important files off the drive by putting it in another computer. Decided to install RH9 (had a set of CD's) - no problem there and then updated to kernel version 2.4.20-31.9. It was only then that I realised that I had only access to approx. 30G. I had thought that when I installed the Linux system on its own that it would overwrite (silly me!). Is there any way that I can resize the partition without reformatting the drive and having to start all over again.
Apologies if I'm duplicating - I couldn't find an answer!
Thanks
Anne
 
Old 01-08-2006, 08:25 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
well you shouldn't really resize the partition, as you;ve said "partition" and not "partitions" for one thing... Linux is designed to run using mupltiple partitions each for a different function. In your situation, which i'm assuming is a laregly single user desktop environment, i'd suggest using the unused space as a dedicated /home partition instead. just use cfdisk or a similar tool to create a partition in the free space, format it using "mke2fs -j /dev/hdaX" and then mount it and copy everytrhign currently in /home to that parittion. then just delete the old files in the old home and add a line to /etc/fstab to permanently mount it as /home on boot.

doing this means if you are in a situation where you want to install say, Fedora or Ubunutu over the top, you can tell it to nuke the main partitions and redo them, but leave your personal files in /home untouched. much nicer.
 
Old 01-08-2006, 08:36 AM   #3
MuddledAB
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Newbie Registered: Jan 2006 Posts: 3 Distribution: Resizing partition after inst

Many thanks for the prompt response - I'll give this a go, and take your advice 'cos I will very likely want to install a newer distribution sometime.
 
Old 01-08-2006, 10:15 AM   #4
MuddledAB
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Excuse stupidity. fdisk -l gives me this information

Disk /dev/hda: 60.0 GB, 60000000000 bytes
255 heads, 63 sectors/track, 7294 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 4046 32395072+ 83 Linux
/dev/hda3 4047 4111 522112+ 82 Linux swap

I know its easy to wipe everything with a wrong move. How do I create a partition in the free space using this information? Thanks for your patience.
 
Old 01-08-2006, 10:50 AM   #5
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
There's a nice tool, qtparted, which provides a visual interface to parted, a partition editor.

I seem to recollect that SuSE used apt, so -- if that's correct -- try an apt-get qtparted to install it (and parted), then try to use it (as root) to either expand your /dev/hda2 or (more likely) create a new /dev/hda4 from cylinders 4412 through 7293 (which your fdisk output suggests are free).

If that's not correct, use google to locate the qtparted and parted rpms for SuSE, download them, and use rpm to install them. Or whatever is appropriate for SuSE. (Sorry I use mostly Fedora, and RedHat's yum for installation and updates.)
 
Old 01-08-2006, 11:49 AM   #6
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
MuddledAB,

I would recommend using an easier utility to partition your disk. The cfdisk utility provides a nice graphic interface to a command line window. I noticed from your listing of fdisk -l that you have space at the end of your hard disk so this will be easy.

log on as root
open a terminal window (konsole, gnome-terminal, ...)
enter /sbin/cfdisk /dev/hda

You will see a display of your hard disk partitions. You should also be able to see the free space at the end of your hard disk.

Use the keyboard up/down arrow keys to highlight the unpartitioned space on your hard disk. Then use the keyboard left/right arrow keys to highlight an action at the bottom. I don't have any free space on any disks right now so I can't be sure what you will see. Basically you want to create a primary partition, then you want to tell cfdisk what type of partition it is. You want type 83. Then you write the changes to the disk. You should reboot the computer. When the computer is running again you want to create a file system on the partition.

You will use the mkfs command to create a file system on your new partition. You should read a bit about this command in the man pages before you use it. This is the command if you wanted to create a Reiser file system.

mkfs -t reiserfs -c /dev/hda4

If that complains about an unknown type then try this command.

mkfs -t reiser -c /dev/hda4

This command could take awhile because the -c option tells mkfs to check for bad blocks. You can leave the -c out if you feel lucky.

Unfortunately I'm unable to try each of these commands so I might make a syntax error.

===

Next you want to mount this new file system and copy your old /home stuff into this directory. Still as root enter these commands. I was able to test the pax command without altering my own disks.

mkdir /mnt/tmp
mount /dev/hda4 /mnt/tmp
cd /home
pax -r . -w /mnt/tmp -v -pe

The pax command copies your files to the new partition. Next enter these commands.

umount /mnt/tmp
mount /dev/hda4 /home
ls -la /home

Hopefully you will see all of the files that you had in your old /home directory. Did you notice that we didn't delete anything in the original /home directory that is located on /dev/hda2? You can mount a partition on a directory that has files in it. The files in the directory are not harmed, they are just hidden. This way if the pax command didn't work you still have the original /home directory with all of the files still there.

When you are satisfied that all of the files were copied to the new partition you can unmount the new partition and delete the original files.

Now you want to put a line in your /etc/fstab file to tell Linux to mount your new partition when the system starts. I'm not exactly sure what to enter as the file system (whether it's reiser or reiserfs) but the next line should be entered into your /etc/fstab.

/dev/hda4 /home reiser defaults 1 1

I'm pretty sure that would work. If reiser doesn't work then reiserfs might work. You can test it by entering the following commands.

mount
umount /home
mount
mount -a
mount

This sequence of commands first lists all of the mounted partitions, then it unmounts the partition on the /home directory, then it lists all of the mounted partitions, then it tries to mount all of the partitions listed in the /etc/fstab file, and lastly it lists all of the mounted partitions. Naturally we are listing all of the mounted partitions between each action in order to see if there is a difference between these listings. If the mount -a command did not mount /dev/hda4 back to the /home directory then we have made an error. Otherwise you should be all set. Post back if you encounter problems.

Last edited by stress_junkie; 01-08-2006 at 12:07 PM.
 
Old 01-08-2006, 02:08 PM   #7
MuddledAB
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Original Poster
Rep: Reputation: 0
stress junkie

This is now the info from fdisk -l. I have managed to reduce my drive by almost a half and got rid of 3000+ cylinders it would seem.
Don't have cfdisk so using fdisk, which really shouldn't be a problem, you would think.

Disk /dev/hda: 33.8 GB, 33820286976 bytes
255 heads, 63 sectors/track, 4111 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 4046 32395072+ 83 Linux
/dev/hda3 4047 4111 522112+ 82 Linux swap

Obviously this tells me I have now no free space to create any new partition.
I fear this was my own fault in thinking I needed an extended partition (I tried this before your post came through). That'll teach me to proceed without asking.
I had then decided off my own bat that it really should have been primary and tried to fix it - big mistake! Anyway net result is the above. It could be worse - I could have wiped the lot.
Is there hope for me or should I cut my losses while the going is good!!
Any way of refinding the lost 'bits'?

Creeps into corner deeply embarassed.
 
Old 01-08-2006, 02:50 PM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
you do not have a 60gb hard drive... it says it's 33.8 gb... that data isn't anythign to do with your linux installation, but the raw physical disk. unless your partition table really is totally screwed and the figures fdisk is being told by the drive don't match those printed on the disk that is.

Last edited by acid_kewpie; 01-08-2006 at 02:51 PM.
 
Old 01-08-2006, 02:58 PM   #9
MuddledAB
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Chris
If you look at my second post above timed today 4.15pm you'll see that my hard drive was 60g then. So I guess I totally screwed up the partition table
 
Old 01-08-2006, 03:17 PM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
Hmm, yeah you did didn't you.... let's see if i can find anythign, got me wondering now...
 
Old 01-08-2006, 03:52 PM   #11
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
You could first look at the hard drive specifications using hdparm. This is the listing from my Maxtor 80 GB EIDE drive.

# hdparm /dev/hda

/dev/hda:
multcount = 16 (on)
IO_support = 1 (32-bit)
unmaskirq = 1 (on)
using_dma = 1 (on)
keepsettings = 0 (off)
readonly = 0 (off)
readahead = 256 (on)
geometry = 65535/16/63, sectors = 81964302336, start =0

You will notice that the number of sectors is equal to the number of bytes on the disk. It looks weird but that's what it says.

Something else that you can look at is the motherboard CMOS setting for your disk. You might want to power off the computer, then start it and get into the CMOS setup. If the disk looks okay then boot Linux and see what fsck -l says. I believe, but cannot be sure, that fsck and fdisk look at the disk partition table while hdparm will look directly at the hard disk. So if hdparm shows the right disk size but fsck and fdisk do not show the right size then acid_kewpie is probably correct about the partition table being messed up. It shouldn't be that difficult to fix if that's all that it is. You should be able to use fdisk or parted to fix the table.
 
Old 01-08-2006, 05:11 PM   #12
MuddledAB
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Well! What gremlins are about today? After 2 reboots I was getting disk space available 33g or thereabouts.

hdparm gave this

/dev/hda:
multcount = 16 (on)
IO_support = 0 (default 16-bit)
unmaskirq = 0 (off)
using_dma = 1 (on)
keepsettings = 0 (off)
readonly = 0 (off)
readahead = 8 (on)
geometry = 4111/255/63, sectors = 66055248, start = 0


Went into CMOS and everything looked ok.
Booted up again and did another /sbin/fdisk -l
and got this

Disk /dev/hda: 60.0 GB, 60000000000 bytes
255 heads, 63 sectors/track, 7294 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 4046 32395072+ 83 Linux
/dev/hda3 4047 4111 522112+ 82 Linux swap


back to what it was when I started.

What I'm going to do is start afresh tomorrow. Thank you all for your assistance and sorry for wasting your time. I've no idea why it has righted itself.

Stress junkie - I'll work through your post and see how it goes.
Just hope I don't mess up again
Thanks all!
 
Old 01-08-2006, 06:33 PM   #13
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
I'm sure that acid_kewpie would agree you haven't wasted anyone's time. Since you're using fdisk this is the procedure:

/sbin/fdisk /dev/hda
m p n w
m will display the commands available
p will display the partition table
n will create a partition, you want type 83
w will write the new partition table out to disk and exit fdisk

If you get confused and just want to exit fdisk without making any changes then use the q command.

It's a good idea to reboot before working with the new partition.

Last edited by stress_junkie; 01-08-2006 at 06:39 PM.
 
Old 01-09-2006, 05:05 AM   #14
MuddledAB
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Have added new partition as shown below - note the drive size is now back to 33GB - Perhaps because no file system attached yet to /dev/hda4?

[root@localhost anne]# /sbin/fdisk -l

Disk /dev/hda: 33.8 GB, 33820286976 bytes
255 heads, 63 sectors/track, 4111 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 4046 32395072+ 83 Linux
/dev/hda3 4047 4111 522112+ 82 Linux swap
/dev/hda4 4112 7294 25567447+ 83 Linux

I intend doing (c option doesn't seem to be supported) -

[root@localhost anne]# /sbin/mkfs -t reiserfs /dev/hda4

which will do this

<-------------mkfs.reiserfs, 2002------------->
reiserfsprogs 3.6.4

mkfs.reiserfs: Guessing about desired format..
mkfs.reiserfs: Kernel 2.4.20-31.9 is running.
Format 3.6 with standard journal
Count of blocks on the device: 6391861
Number of blocks consumed by mkreiserfs formatting process: 8407
Blocksize: 4096
Hash function used to sort names: "r5"
Journal Size 8193 blocks (first block 18)
Journal Max transaction length 1024
inode generation number: 0
UUID: 720d5185-db48-4694-b5a8-d924b95343f7
ATTENTION: YOU SHOULD REBOOT AFTER FDISK!
ALL DATA WILL BE LOST ON '/dev/hda4'!
Continue (y/n):


Just playing it safe here I take it this will be OK and not obliterate the rest of hda bearing in mind the 33GB anomaly?

And finally do I reboot before mounting this file system and transferring /home?

Thanks
 
Old 01-09-2006, 05:45 AM   #15
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
The fdisk -l shows that hda4 is okay. The cylinders don't overlap another partition and the last cylinder number is the same as the highest cylinder number shown when the disk capacity was reported to be 60 GB.

The question about the reported capacity changing may be related to your first post. You said that the disk had been running Windows ME and that it had died. The fact that it was running Windows ME says that it is old. The fact that it died may be related to the changing reports of its capacity. It seems to be running well enough to do this disk partitioning. It may run Linux for years with no problems or it may stop working altogether today or tomorrow. Just keep that in mind when you're using it. Backup your data whenever you've put new data on the drive. Use this drive to be for experiments only.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Problem Resizing Linux Partition From Partition magic John_Emad SUSE / openSUSE 5 02-16-2005 12:42 PM
resizing partition greg108 Red Hat 1 08-12-2004 01:23 PM
need help resizing an ext3 partition with an underlying partition... spiroth10 Linux - Software 1 07-30-2004 12:21 PM
Resizing my partition. Saitoku Linux - Newbie 2 06-02-2004 06:08 PM
? on resizing partition eroica Mandriva 0 05-11-2004 11:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:52 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration