• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

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
0
fosiul01
Asked:
fosiul01
  • 15
  • 13
  • 3
1 Solution
 
chris_barryCommented:
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
 
fosiul01Author Commented:
hi thanks. My bind is in var/named/chroot... So if i take var to my new harddrive, wil my bind work?
0
 
fosiul01Author Commented:
hi thanks. My bind is in var/named/chroot... So if i take var to my new harddrive, wil my bind work?
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
chris_barryCommented:
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
 
joolsCommented:
do you have any space in your existing LVM config?

   vgdisplay -v
0
 
joolsCommented:
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
 
chris_barryCommented:
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
 
joolsCommented:
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
 
fosiul01Author Commented:
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
 
joolsCommented:
You could just add the new disk to the volume group and extend /var.

I still thing 70G for /var is overkill.

J
0
 
fosiul01Author Commented:
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
 
joolsCommented:
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
 
fosiul01Author Commented:
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
 
fosiul01Author Commented:
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
 
joolsCommented:
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
 
fosiul01Author Commented:
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
 
joolsCommented:
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
 
joolsCommented:
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
 
joolsCommented:
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
 
fosiul01Author Commented:
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
 
joolsCommented:
If you need any hints feel free to post back here
0
 
fosiul01Author Commented:
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
 
joolsCommented:
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
 
fosiul01Author Commented:
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
 
joolsCommented:
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
 
fosiul01Author Commented:
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
 
fosiul01Author Commented:
have a look at this question please
http://www.experts-exchange.com/OS/Linux/Q_23784717.html
0
 
joolsCommented:
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
 
joolsCommented:
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
 
joolsCommented:
I hope this is what you were after.
0
 
fosiul01Author Commented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 15
  • 13
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now