Link to home
Start Free TrialLog in
Avatar of fosiul01
fosiul01Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Mount a new hardrive with /var

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
Avatar of chris_barry
chris_barry

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.
Avatar of fosiul01

ASKER

hi thanks. My bind is in var/named/chroot... So if i take var to my new harddrive, wil my bind work?
hi thanks. My bind is in var/named/chroot... So if i take var to my new harddrive, wil my bind work?
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.
Avatar of Julian Parker
do you have any space in your existing LVM config?

   vgdisplay -v
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.

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.
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
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 ??
You could just add the new disk to the volume group and extend /var.

I still thing 70G for /var is overkill.

J
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,

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.
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 ??


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
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.
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
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.
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!



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.

:-)
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!!!

If you need any hints feel free to post back here
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!!!
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 /?

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) ??
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

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
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.

ASKER CERTIFIED SOLUTION
Avatar of Julian Parker
Julian Parker
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I hope this is what you were after.
yap thank you,
i will try the instruction after finishing my new installation

for time being , thank you for helping me out