Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RedHat, add partition

Status
Not open for further replies.

roeiboot

Technical User
Feb 10, 2002
241
US
oi,

i have a 4gig harddisk in my RedHat 7.1 & it's divided in two 2gig partitions. 1 i use for Linux, the second one is un-used @ the moment. since i'm running out of space on the /var (where my mail is :} i would like to format the un-used partition and use it, but i can't mount it. can i format it in DOS or something ? and is there an easy way to make the 2gig part my /var without losing date, by moving /var for example.. long story short: how would i go about it ?

thanks!
 
Use fdisk to create partitions.

fdisk /dev/hda (for example)

Pressing 'm' during the fdisk session will show you all of the options. Press 'n' to create a new partition, 'p' to print the partition table, and 'w' to write the partition table to disk when you are finished adding your partitions. After you create the new parition, format it using 'mkfs'. Here's an example.

mkfs -t ext3 /dev/hda7


What do you want to do from here? Use this new partition for /var? If so, you'll have to copy your old /var to this new partition, and then edit your /etc/fstab file to mount the new parition on /var on startup.

If you were running LVM, you would be able to dynamically resize your current /var to include the free space on your drive, all while the server is up and running. Check it out...


ChrisP
 
Chris,

this is my partion table (p in fdisk):

--
Command (m for help): p

Disk /dev/hde: 255 heads, 63 sectors, 2481 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hde1 * 1 7 56196 83 Linux
/dev/hde2 8 2481 19872405 5 Extended
/dev/hde5 8 1074 8570646 83 Linux
/dev/hde6 1075 2141 8570646 83 Linux
/dev/hde7 2142 2174 265041 83 Linux
/dev/hde8 2175 2207 265041 83 Linux
/dev/hde9 2208 2240 265041 82 Linux swap
--

would it be safe to say /dev/hd2 is the second partition ? obviosuly don't wanna risk losing all my stuff :}

thanks.!
 
What is your existing root partition? I would assume /dev/hde5. It looks like your second partition is /dev/hde6. hde7 and hde8 don't look like they are being used. Assuming that hde5 is the root partition, I would remove hde6,7 and 8 and recreate one partition hde6 from block 1075 to 2207.

You need to keep hde1 as your /boot partition, hde2 as your extended partition (not mountable), and hde9 as your swap partition.
 
Before we start guessing here, check 'mount' or the /etc/fstab file to see exactly which partition is mounted where.

ChrisP
 
this is the output of the "mount" command:

--
/dev/hde8 on / type ext2 (rw)
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
/dev/hde1 on /boot type ext2 (rw)
/dev/hde6 on /home type ext2 (rw)
/dev/hde5 on /usr type ext2 (rw)
/dev/hde7 on /var type ext2 (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
automount(pid599) on /misc type autofs (rw,fd=5,pgrp=599,minproto=2,maxproto=3)
--

appreciate you guys helping..
 
anyone please.. i receive my e-mail on /var/ & it looks like since it's full that i don't receive mail :{

thanks!
 
/dev/hde7 is your /var partition. Did you create the new 2Gb partition yet? Also, what is the size of /dev/hde7 right now? Lets see the output of "df -h".

If you haven't already, use fdisk to create the new 2Gb partition. After its created, format it using "mke2fs /dev/hde?", replacing ? with whatever partition you want to format.
Boot from the Red Hat CD and enter rescue mode by typing "linux rescue" at the boot: prompt. When it asks if you want to mount your root (/) filesystem, say yes. Then type "chroot /mnt/sysimage". Check to see if /var is mounted. If its not, then mount it using "mount /var". Next, mount the new partition using something like "mount /dev/hde? /mnt".

Run the following command to copy the contents of /dev/hde7 to your new partition.

find /var -depth -print | cpio -padumV /mnt

If all goes well, then edit your /etc/fstab file to mount the new partition at /var in place of the old one. Then type "sync" and "reboot".

After you reboot, run "mount" or "df" to check that the new partition is mounted on /var. Also, you can use "du -sh" to see how much free space is left in the new /var partition.

ChrisP



 
Chris; thanksfor the reply.. and no, didn't format the 2gb partition yet 'cuz i'm not sure how, i mean.. i don't wanna format the wrong disk & risk losing everything.
 
I'm not sure what else your looking for here that hasn't already been explained. To create a new partition, use "fdisk /dev/xxx", where xxx is the disk that you want to create a new partition on. A great way to test all of this stuff out is to install VMware on a test machine. VMware will let you install a separate, independant OS inside your host OS. You can add as many virtual hard disks as you want to each guest OS. This would be a great way for you to experiment with partitioning without having to worry about wiping out a production machine.

Chris
 
Chris; well.. i'm still not a 100% sure which one in the un-used 2g partition i wanna re-format for Linux and start using.
 
You don't want to use any of the used partitions. You want to create a new one out of the 2Gb's of free space.

fdisk /dev/xxx

Press 'n' to create a new partition.


ChrisP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top