Solved

Mount a new hardrive with /var

Posted on 2008-09-29
31
245 Views
Last Modified: 2013-12-06
Hi,
bellow this my existing partition :

[root@bkworkshop dev]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       19G  1.6G   16G   9% /
/dev/hda1              99M   13M   82M  14% /boot
none                   62M     0   62M   0% /dev/shm

what i want to do is : i want to add a new 80 GB hardrive, and want to add that that one with existing /var

how will i do that ??

What I have done is so far : i added the hardrive, i mounted that one under /mnt/hdc1 ( i was following a web site)
after doing this :

[root@bkworkshop dev]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       19G  1.6G   16G   9% /
/dev/hda1              99M   13M   82M  14% /boot
none                   62M     0   62M   0% /dev/shm
/dev/hdc               74G   85M   70G   1% /mnt/hdc1


now i want to add this new /mnt/hdc1 with /var

please give me advise
0
Comment
Question by:fosiul01
  • 15
  • 13
  • 3
31 Comments
 
LVL 1

Expert Comment

by:chris_barry
ID: 22595558
As I see it you have two options.
1. You can replace you entire /var with the new drive.
2. You can move some of the directories under var onto the new drive.

For option 1 you would do something like:
cp -a /var/* /mnt/hdc1
umount /mnt/hdc1
mv /var /oldvar
mkdir /var
mount /dev/hdc1 /var

For option 2, suppose you want to put /var/cache on the new drive:
mkdir /mnt/hdc1/cache
cp -a /var/cache/* /mnt/hdc1/cache
mv /var/cache /var/oldcache
ln -s /mnt/hdc1/cache /var/cache

In both cases, once you are happy that the new configuration is working you can remove the old directory.
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22595693
hi thanks. My bind is in var/named/chroot... So if i take var to my new harddrive, wil my bind work?
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22595943
hi thanks. My bind is in var/named/chroot... So if i take var to my new harddrive, wil my bind work?
0
 
LVL 1

Expert Comment

by:chris_barry
ID: 22597321
I can't think of a reason why it shouldn't, although it would probably be a good idea to stop bind while you make the change, particularly if it runs in a chroot directory.
0
 
LVL 19

Expert Comment

by:jools
ID: 22597450
do you have any space in your existing LVM config?

   vgdisplay -v
0
 
LVL 19

Expert Comment

by:jools
ID: 22597936
Any reason you want a 70G /var, it's a bit big IMHO.

If you are trying to increase the space of a directory under /var like /var/www you could just mount your new disk as that.

0
 
LVL 1

Expert Comment

by:chris_barry
ID: 22598496
I don't see that mounting as eg /var/www gives much advantage, if any, over just mounting as /var.

For myself I use my second option, leaving extra hard disks in /mnt and creting symbolic links as required. I find this gives me the greatest flexibility, and so far it has not caused me any problems.
0
 
LVL 19

Expert Comment

by:jools
ID: 22599552
Thats the beauty of *nix, you can do almost whatever you want, if it works great, if it doesnt, you get to keep all the pieces. From my own pov links are great to a degree but sometimes just doing a df and seeing where all the disk space is, is a lot easier, at least for me.

I still think it helps knowing what the user wants though
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22612549
Hi sorry yesterday was my holiday so i went out with family so didnot able to reply

if i go with chris_barry suggestiong

dont i need to unmount /var ?? then mount again with /mnt/hdc1 ??

if it true, then problme is , my one is LVM, i am not seeting any options to unmount my /var/

my confusion is, since i am use LVM, how will i unmount var and then mount it with the new partition ??
0
 
LVL 19

Expert Comment

by:jools
ID: 22612891
You could just add the new disk to the volume group and extend /var.

I still thing 70G for /var is overkill.

J
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22613149
haah Hi jool

no i dont have any intension to do that

i added 80Gb heardrive

and i want to extended everything like  /home, /var, /etc

but i dont k now how, so if any one tell me how to do one , then i could of do rest by myself

as you said : you could just add the new disk to the volume group and extend /var.

but how i will add new harddrive to the volume group ??
as chris_barry said, is that the way, but i have doubt,

0
 
LVL 19

Expert Comment

by:jools
ID: 22613648
All your partitions are under / so you only need to add the disk into the group and extend / but the system is likely to complain unless it's in rescue mode. Not tried it myself so cant really say.

To add the disk to the VG

Initialise the volume.
   pvcreate /dev/hdc1

Add the new disk to the VG
   vgextend VolGroup00 /dev/hdc1

Because your current /var is under root you can just create it.
   lvcreate -n var -L 30G VolGroup00

Probably best at this stage to shut the system down to run level 1.
   init 1

Now you need to mount it.
   mount /dev/LogVol00/var /mnt

Copy /var to /mnt
   cd /var
   find . -print | cpio -puvdm /mnt

Check the sizes, they should be the same.
   du -sk /var
   du -sk /mnt

Modify fstab to use the logical volume.
   vi /etc/fstab
   /dev/Volgroup00/var  /var   ext3    defaults        1 2

Unmount /mnt
   umount /mnt

Try mounting everything (at this stage we still have not lost the original /var.
   mount -a

See if the services are OK
   init 3

If it looks ok then you can bring the system back down and umount /var then cd / then mv /var /oldvar then mkdir /var or you can just leave it.
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22623604
hi jools

thanks , your soluiton perfect

but one questions,

if i use lvm, does not it assign space /home, /var/, /etc automatically ??

what i have meant is, if you dont use LVM, then you will have to define that, how big is your /var.,/home , /usr , it not it ??

and if one is full then either you will have to add a new harddrive and make the partition bigger or you will have to delete files

but with LVM , it configure whole harddrive automatically, does it mean,after a long time of use, if my /var need 50GB suppose, will it give that 50 GB to /var automatically ??

 i mean, supose , iniitally LVM gave /var, /home/usr same disk space of 10GB , and still 10GB left . so in future, if /var need another 5 GB , will it automatically assign this 5GB to var from 10GB ??


0
 
LVL 29

Author Comment

by:fosiul01
ID: 22623753
hahahahahahah
its messed up my linux server!!!!#


i just followed this :


Initialise the volume.
   pvcreate /dev/hdc1

Add the new disk to the VG
   vgextend VolGroup00 /dev/hdc1

then i restarted the server

now its kernel panic

anyway, its my practice box so i am not worring

any idea to fix this problem ??

you dont have to give me soluiton , i will go to another one for that,
just give me hints
0
 
LVL 19

Expert Comment

by:jools
ID: 22623886
Oops, Sorry, should have let you know it was a possibility.

Did the commands complete OK?

Can you post the error message you get on reboot, it may remind me.
Theres a chance I forgot something :-( I think I need to help you out of the problem, who knows, we may both learn something on the way!

Anyway, fact finding exercise;

Insert the Linux install media and boot rescue mode.
Run the following commands and post the output back here.
   pvs
   vgs
   vgdisplay -v

I'm out for a few hours now, I'll check out progress when I can.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 29

Author Comment

by:fosiul01
ID: 22623930
its allright, i am doing this for learning for RHCT

i dont have linux disk with me right now.

so tomorrow i would be able to work on that.

yes command completed succefully.

I will past all the error tomorrow
for time being,

main one is : could not find all physical volumes for volumegroups VolGroups00
0
 
LVL 19

Expert Comment

by:jools
ID: 22624842
RHCT... Cool...

I guess the physical volume missing would be the reason.

When you get the listings, include an `fdisk -l`

I'll run up a server on RHEL 5 (which is what you'll be using) and setup a test lab to see if I get the same error.
I'll post back later as well.
0
 
LVL 19

Expert Comment

by:jools
ID: 22625635
AHH HA!

Well mine booted with the vg extended but I have found a couple of typos :-)
... and I have omitted a couple of shall we say semi crucial bits (whatever semi crucial is!) to do with /var!

I've created the /var lv and copied the stuff over i then did the init 3, only it's barfed.
Anyway, just working on a fix.... it's a bit sick at the moment :-)

Seeing as you're doing the RHCT, see if you can find some of the typos, there is also a step missing. I won't post back until you've had a go at fixing yourself, where is the fun in that!



0
 
LVL 19

Expert Comment

by:jools
ID: 22625787
OK, My test box is all done let me know when you want to have a go.

This will be good practice for the problem solving bit in the RHCT.

:-)
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22632162
ok was doing some work in office,

Now free to play arround, let me try for a while, then i wil come back soon with good or bad result!!!

0
 
LVL 19

Expert Comment

by:jools
ID: 22632250
If you need any hints feel free to post back here
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22632545
haahha Done, did it!!

may be i am lucky,
when i boot as rescue mode, then when it was creating image ( i guess) it was saying , "hdc not found"!

after going rescue mode, i was trying to fllow this link :

http://www.redhat.com/docs/manuals/csgfs/browse/4.6/Cluster_Logical_Volume_Manager/mdatarecover.html

but none of the command would not work in rescue mode

then i thought well, hdc1 is the hardrive i wanted to mount with /var
why its saying unable to found hdc1

so , what i did is : fdisk /dev/hdc1 then create full hardrive as a primary partition

after that when i rebooted, everything fine!!!
0
 
LVL 19

Expert Comment

by:jools
ID: 22633031
I'll tell you what, do you want me to post the typescript of what I did so you can have a look?

Did you resize2fs /?

0
 
LVL 29

Author Comment

by:fosiul01
ID: 22633065
yes please, that woud be perfect

there was little problme, i will open another question soon

i am reinstaling my linux for proper LVM pertition.

i want to create /home /var/  /usr in sperate logical volume
Currently it was in One

the hardisk i am using it only 10 GB , so then after installation , i will add another 10GB manualy by using LVM

then i will come back to you with another new question, i will sent you the link
here .

I will close this question
but if you can send me what you did

and also : how much space actaully requered for  /root /var /usr for installation(LVM) ??
0
 
LVL 19

Expert Comment

by:jools
ID: 22633078
btw, you may or many not need to know this for the RHCT.

To use the lvm commands in rescue mode, just run lvm as the first command, for example;
   lvm vgdisplay -v

Alternatively, you can run lvm by itself like;
   lvm
   lvm> vgdisplay

0
 
LVL 29

Author Comment

by:fosiul01
ID: 22633124
i am studying for RHCE

i am not taking exam for RHCT as i have basic knowledge in linux

so i bought this book for RHCE ,micheal jang and trying everything in LAb
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22633158
have a look at this question please
http://www.experts-exchange.com/OS/Linux/Q_23784717.html
0
 
LVL 19

Expert Comment

by:jools
ID: 22633314
OK,
I thought you said RHCT, sorry! RHCE is much better!

I will attach the typescript for future reference and you can look at it if you like.

0
 
LVL 19

Accepted Solution

by:
jools earned 500 total points
ID: 22633346
Attached is the typescript for the above.

I think it's complete and it was tested on the following;
   1 x HP ML370 G5
   4096MB Memory
   2 x 146GB disks configured as JBOD on the Smartarray controller
   RedHat Enterprise Linux 5


23770823.txt
0
 
LVL 19

Expert Comment

by:jools
ID: 22633355
I hope this is what you were after.
0
 
LVL 29

Author Comment

by:fosiul01
ID: 22633375
yap thank you,
i will try the instruction after finishing my new installation

for time being , thank you for helping me out
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now