LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-07-2003, 05:27 PM   #1
WorldBuilder
Member
 
Registered: Mar 2003
Location: Massachusetts, USA
Distribution: RH 8, Solaris, Windoze eXPunged
Posts: 520

Rep: Reputation: 30
MasterC, can you (or anyone else) help with parted?!


Hi all,

I have a problem that I THINK "parted" will fix. The problem is that I had never even heard of "parted" until a few days ago, and I certainly don't know how to use it. I have read countless docs about it, including examples, but I am getting nowhere. When I installed my server OS (RH 8 Pro), I only made / and /home partitions. Swap too, of course. In other words, no /boot, /var/usr, /etc. The / partition is /dev/hda1 and /home is /dev/hda3. The entire HDD is 120GB. The / partition is about 5GB, and /home uses the rest. The problem is that my / partition has now filled up and I can't send e-mails from any of my workstations, well, because their is no more room on the server! I figure that I want to do this:

Shrink /home by 20GB
CREATE a /var partition and make it 15GB
CREATE a /etc partition around 5GB

I need to do all this without losing data from the / partition. I'd like to keep the data in /home, but if I lose it, it's no biggie. I can't, however, lose data from /. I have found examples of how to resize partitions, but nothing on how to do what I want to do. Is this possible? I really need to do this, but I have no idea how. Please, can anyone help?! Thanks a million!

Chris

Last edited by WorldBuilder; 05-07-2003 at 06:00 PM.
 
Old 05-07-2003, 06:21 PM   #2
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
what filesystems are you using on the drives?
if ext2, this will be easy, if not, harder.
 
Old 05-07-2003, 06:31 PM   #3
WorldBuilder
Member
 
Registered: Mar 2003
Location: Massachusetts, USA
Distribution: RH 8, Solaris, Windoze eXPunged
Posts: 520

Original Poster
Rep: Reputation: 30
I think it's ext2, but how can I check for sure. I'll try to find out definitively until your reply. If you think you can help me out, thank you very much!!!!!!!

Chris
 
Old 05-07-2003, 06:52 PM   #4
cuckoopint
Member
 
Registered: Feb 2003
Distribution: Debian
Posts: 797

Rep: Reputation: 30
Quote:
I think it's ext2, but how can I check for sure.
'cat /etc/fstab' should do the trick - just see how they are mounted.

As for /, you don't have to worry about it. You are not resizing /. What you are in essence going to do is resize /home (which should be ok, if you don't go *woops*) and then editing /etc/fstab to mount /var, /etc, etc. on seperate partitions. (you're most likely also copying stuff around, but that gives no reason for damage).

Figure out your fs type, and read up on how to use parted for it. Also since /home is the last partition, you're life is made a lot easier - parted requires that the beginning of th partition remains the same, which in your case means /var, /etc, etc. will simply be made hda4, 5, etc, at the end of the drive.
 
Old 05-07-2003, 07:07 PM   #5
WorldBuilder
Member
 
Registered: Mar 2003
Location: Massachusetts, USA
Distribution: RH 8, Solaris, Windoze eXPunged
Posts: 520

Original Poster
Rep: Reputation: 30
They are ext3. Is this going to be a problem? I really need help with parted in itself. I know nothing about it and cannot lose data.

Chris
 
Old 05-07-2003, 07:47 PM   #6
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
appartently ext3 and reiserfs are ok too.


Features

Supported disk labels: raw access (useful for RAID and LVM), MS-DOS partition tables, Intel GPT partition tables, MIPS partition tables, PC98 partition tables, Sun and BSD disk labels and Macintosh partition maps.

File system detect create resize copy check
ext2 * * *1 *2 *3
ext3 * *1 *2 *3
fat16 * * *4 *5 *
fat32 * * * * *
linux-swap * * * * *
HFS *
JFS *
NTFS *
ReiserFS * *6 *1, 6 *6 *6
UFS *
XFS *
Supported operations

Notes:

1. For ext2, ext3 and reiserfs: the start of the partition must stay fixed.
2. For ext2, ext3: the partition you copy to must be bigger or exactly the same size as the partition you copy from.
3. For ext2 and ext3: the checking is limited to ensuring the resize and copy commands will be ok.
4. For fat: the size of the new partition after resizing or copying is restricted by the cluster size. Parted can shrink the cluster size, so you can always shrink your partition. However, if you can't use FAT32 for some reason, you may not be able to grow your partition.
5. Parted supports both FAT16 and FAT32. Parted can convert file systems between FAT16 and FAT32, if necessary.
6. Reiserfs support is enabled if you install libreiserfs, available at http://reiserfs.osdn.org.ua. (It is likely to be availabe soon from http://www.namesys.com)

Downloading

GNU Parted can be found on http://ftp.gnu.org/gnu/parted/ or one of the mirrors.
 
Old 05-07-2003, 09:10 PM   #7
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
How much space do you have left on your /home partition? To find out:
df -h

As for using parted, what are you having problems with specifically? Is it the way the size is displayed? Is it how to shrink/grow a partition? Is it you just need reassurance it'll work?

If you are concerned about losing data, you could create a "mirror" backup partition first. From df -h you'll find out exactly how much all your partitions are using. You can then create a seperate partition at something like /mnt/data and back everything up there (however, I guess this really would be unnecessary since you'll be resizing to create this ).

Anyway, if you can let us know what part of parted is giving you the trouble it'll help us to give you better instructions on how to get it to work for you

Cool
 
Old 05-07-2003, 09:23 PM   #8
WorldBuilder
Member
 
Registered: Mar 2003
Location: Massachusetts, USA
Distribution: RH 8, Solaris, Windoze eXPunged
Posts: 520

Original Poster
Rep: Reputation: 30
MasterC,

Thank you so much for the help. I guess what I am having trouble with is the fact that I am in completely unknown territory with parted. I don't even know where to begin really. df -h shows:

Filesystem Size Used Avail Use% Mounted on
/dev/hda1 4.8G 4.6G 1.4M 100% /
/dev/hda3 107G 21G 80G 21% /home
none 377M 0 376M 0% /dev/shm

I would like to shrink /home by 20GB and CREATE /var and /etc partitions (should I also create a /boot?) in parted. I would like /var partition to be 15GB and /etc to be 5GB. I guess what I am looking for is a little step-by-step help. Will I need to reboot to a boot disk to do this? I don't think so since I will not be messing with /. Right? Can I just do this all in a command line while the system is running, then reboot? Thanks a million guys, I have no e-mail until I get this working. I'm gonna go to bed soon, but I'll check back here tomorrow!

Chris
 
Old 05-08-2003, 07:37 AM   #9
WorldBuilder
Member
 
Registered: Mar 2003
Location: Massachusetts, USA
Distribution: RH 8, Solaris, Windoze eXPunged
Posts: 520

Original Poster
Rep: Reputation: 30
More info

Ok guys,

Here you go, some more information. These are some things I have done, and what I have been able to get from the machine:

[root@goliath /]# parted /dev/hda1
Warning: Device /dev/hda1 is neither a SCSI nor IDE drive.
Ignore Cancel ? Cancel

[root@goliath /]# parted /dev/hda3
Warning: Device /dev/hda3 is neither a SCSI nor IDE drive.
Ignore Cancel ? Cancel

[root@goliath /]# parted
Using /dev/hda
Information: The operating system thinks the geometry on /dev/hda is 14946/255/63. Therefore, cylinder 1024 ends at 8032.499M.

(parted) print
Disk geometry for /dev/hda: 0.000-117246.937 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 4996.779 Primary ext3 boot
2 4996.780 6149.882 Primary linux-swap
3 6149.883 117239.985 Primary ext3

That's as much as I feel comfortable doing right now. What does it all mean, Basil?!?! Like I said, I want to shrink /home, which is on /dev/hda3 (Minor 3) by 20GB. Then, I want to create a new partition that is 15GB. Then, I want to create another new partition that is 5GB. The partitions will be /var and /etc. respectively. Can I do this in parted? Can I create those two partitions? How do I then mount /var and /etc to them permanently? Can I do all this while the machine is running, or do I need to boot from CD? Will I lose any data doing this? Is this safe? Please help, guys. Thank you very much!

Chris

A little more...

Ok, do I want to do this?

(parted) resize 3 6149.883 97239.985
(parted) mkpartfs primary ext3 97239.986 112239.986
(parted) mkpartfs primary ext3 112239.987 117239.985

I think this will resize the /home partition down by 20GB, then create the 2 new partitions at 15GB and 5GB, right? After that, how do I mount /var to the new 15GB partition, and mount /etc to the new 5GB partition? Am I getting this right so far? Thanks!

Chris

Even more!

Ok, I have resized my /home partition using parted by shrinking it by 20GB! df -h now reads:

Filesystem Size Used Avail Use% Mounted on
/dev/hda1 4.8G 4.6G 0 100% /
/dev/hda3 88G 21G 62G 26% /home
none 377M 0 376M 0% /dev/shm

I used parted from the "linux rescue" prompt off of my Install CD 1. I then attempted to create another partition with this:

(parted) mkpartfs primary ext3 97239.886 117239.985

I got some weird error message about ext3 and how I would need to boot from a disk or something. To be honest, I don't really know what the error message was all about, but I got out of there quick, rebooted, and that is where I am now. Is it ok if I make this new partition ext2, even though the others are ext3? When I finish creating this new partition, do I have to update the /etc/fstab file and that's it, just reboot? Please help! Thanks!

Chris

Last edited by WorldBuilder; 05-08-2003 at 11:27 AM.
 
Old 05-08-2003, 12:40 PM   #10
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Cool, so you've gotten finished with parted. Unless you want to use parted to create the 2 new partitions which I haven't ever done (I use cfdisk or fdisk).

Assuming you want to use fdisk, here's how:
First, look at it:
fdisk -l
Then:
fdisk /dev/hda

Now you are going to be creating new partiitions:
n
And it will ask you the size (this is all from memory at this point since I don't want to mess with my partitions now that I've got them exactly how I like them )
You should be able to suss it out at this point, if not read the help (m) to find out a little bit more info on it.

FYI, /etc having 5GB is a lot of overkill. I see that you have the extra space, so no biggie, just thought you might be thinking /etc is used for something else (or you might be using it for something else...).

Glad you've got it this far, good luck on the rest

After you get the partitions all figured out, you'll need to create filesystems on them, do that with:
mke2fs -j /dev/hdax
On each partition.
Then, to have them mount up at those specific locations, you first want to copy the data to the partition, so create a temporary mount point for each:
mkdir /mnt/var
mkdir /mnt/etc
(Do all of this in rescue mode or something similar so you don't have the filesystem's needing to be mounted this means you'll need to mount your / partition as well. Create a temp mount point for it as well:
mkdir /mnt/root
mount -t ext3 /dev/hda1 /mnt/root)
mount -t ext3 /dev/hdax /mnt/var (this is your 15GB partition, you can view the partitions with fdisk -l)
mount -t ext3 /dev/hdax /mnt/etc (this is your 5GB)
mv /mnt/root/var /mnt/var
mv /mnt/root/etc /mnt/etc
Once it's all done moving the data (Do all of this in rescue mode or something similar so you don't have the filesystem's needing to be mounted this means you'll need to mount your / partition as well. Create a temp mount point for it as well) you can create the entries in /etc/fstab like so:
/dev/hdax /etc ext3 defaults 1 1
/dev/hdax /var ext3 defaults 1 1

This might sound a little confusing, so check out Aussies article at:
http://www.p-two.net/modules.php?op=...article&sid=12

HTH

Cool
 
Old 05-08-2003, 01:35 PM   #11
WorldBuilder
Member
 
Registered: Mar 2003
Location: Massachusetts, USA
Distribution: RH 8, Solaris, Windoze eXPunged
Posts: 520

Original Poster
Rep: Reputation: 30
Wait a minute, wait a minute. None of that makes sense to me at all. Didn't I already create the new partition with parted? Why do I need create a new partition with fdisk?? I am missing something. Ok, here's what I have done so far... God, I hope this isn't effed up beyong repair, that would really ruin my day.

In parted:
Shrank the /home partition by 20GB by doing
(parted) resize 3 6149.883 97239.985
That shrunk it by 20GB.

Then:
(parted) mkpartfs primary ext2 97239.886 117239.985

That created a NEW partition that is around 20GB.

Then, df -h still gave me this:
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 4.8G 4.6G 0 100% /
/dev/hda3 88G 21G 62G 26% /home
none 377M 0 376M 0% /dev/shm

In other words, the partition I created with parted is NOT showing up in df -h. So, I did:

# vi /etc/fstab and added a line saying
/dev/hda4 /var /ext2 defaults 1 2

I rebooted. Upon reboot, everything came up fine until right after it said all the filesystems were clean. It gave me a whole bunch of error messages that were very similar to there:
"chgrp failed to get attributes of /var/log"
"chgrp failed to get attributes of /var/run/utmp"
"chmod failed to get attributes of /var/run/wtmp"

It also gave me errors about incorrect lines 596, 744, and 762 in /etc/rc.d/sysinit.

The it "freezed" on "bringing up logger" for about 5 minutes, finally getting through that. After that, the system continued to boot, but nearly EVERY service failed to start. Named, ssh, sendmail, everything: failed.

I only did what I mentioned above, and the strange thin is that I went back to /etc/fstab and REMOVED the line I put in above, rebooted, and everything is again working fine. Please, what am I missing here?

Chris

PS. Remember, I am still sort of a , so I really need directions put as simply as possible. Thank you so much for your continued help on this matter. I know it must be frustrating to deal with me!

PPS. I decided not to bother with expanding /etc. You're right, no point to it!
 
Old 05-08-2003, 01:50 PM   #12
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Well you don't have directory structure on that partition yet. You first need to copy everything from /var to the new partition first. I wasn't sure if parted created the new partitions or if it simply shrunk the exisiting one creating more, unpartition/unformatted space (that's what fdisk -l will tell you).

If you copy everything from /var to the new partition (by making the temp mount point and cp -a it) then you'll be set. The one thing that is confusing me in this whole process is how you are going to remove the existing files on /var when you mount your new partition there...

Ok, let's borrow from Aussie's how to:
First off, check to see if you've got the partitions:
fdisk -l
Now mount them up wherever you'd like:
mkdir /mnt/var
mount -t ext3 /dev/hdax /mnt/var
Now drop back to single user mode:
telinit 1
And now you will copy everything:
cp -a /var /mnt/var
And then remove everything
rm -rf /var
umount the disk:
umount /mnt/var
And edit fstab:
vim /etc/fstab

Save and remount:
mount -a
Move back to either mutli User or Multi User X:
telinit 3
OR
telinit 5 (depending on which runlevel you normally use, 3 if you usually boot up into a command line and type startx to get into X, 5 if you boot into a gui)

And you should be done.

HTH

Cool
 
Old 05-08-2003, 01:59 PM   #13
WorldBuilder
Member
 
Registered: Mar 2003
Location: Massachusetts, USA
Distribution: RH 8, Solaris, Windoze eXPunged
Posts: 520

Original Poster
Rep: Reputation: 30
Damn, you're a good man to continue to help me out. So, do I need to do all this in rescue mode, or can I do it all while the system is running in run level 3? Here's what I have figured so far!

fdisk -l does show me /dev/hda4, which is where /var will be mounted, so:

from rescue mode(any other way to get there, other than rebooting to a CD or floppy?)
# mkdir /mnt/var
# mount -t ext2 (it's an ext2 FS) /dev/hda4 /mnt/var
# telinit 1
#cp -a /var /mnt/var
# rm -rf /var
# umount /mnt/var
# vi /etc/fstab, creating a line that says "/dev/hda4 /var ext2 defaults 1 2

After I save fstab, why do I need to remount? Would rebooting the machine do the same thing, or should I just remount everything with mount -a? This is starting to make sense to me, Chad. Thank you!!!

Last edited by WorldBuilder; 05-08-2003 at 02:31 PM.
 
Old 05-08-2003, 03:06 PM   #14
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Remounting is a way to get all this to work without rebooting. If you are already in rescue mode though, you don't have to remount. If you are doing this from inside your normal boot (from a boot loader) then the remount will save you from a reboot

So it sounds like everything should work out just fine now. mount -a in rescue mode will at least tell you if there are problems mounting hda4 on /var

BTW, you can still change your ext2 partition to ext3:
tune2fs -j /dev/hda4
That way it will journal.
Then edit your fstab entry to ext3 (it will work ext2, however why not use the journal feature?)
HTH

Cool
 
Old 05-08-2003, 03:09 PM   #15
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Ohh! 1 thing...

You will be removing /var with the:
rm -rf /var part. You will either need to create that mount point again, or remove everything below var and keep the mount point:
rm -rf /var/*

Otherwise, mounting something at /var will be impossible (since that mount point won't exist). To recreate it:
mkdir /var

HTH

Cool
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't resize ext3 partition (using "parted"). Help or advise another app, plz kornerr Linux - General 2 04-28-2005 10:01 AM
Can you explain the difference between "Free Software (GNU)" and "Open Source"? vharishankar General 5 03-03-2005 09:40 AM
Two questions, 1 about "GOK" and the other about "Super Karamba" Matt.Ramos Linux - Software 0 07-14-2004 09:57 PM
Gnu Parted: "incompatible feature enabled" linux@coxville Linux - Newbie 2 01-10-2004 06:30 PM
how should I respond to "Encryption key for doc.gpg?" in GNU Emacs? Joseph Schiller Programming 1 10-24-2003 11:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:31 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