LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 02-02-2006, 05:53 PM   #1
bret
Member
 
Registered: Apr 2005
Location: SLC, Utah
Distribution: RHEL 4, RHEL 5
Posts: 59

Rep: Reputation: 16
How do I move /var to a logical volume?


After installing SuSE 9.1 SP2 Ent. Server, I decided that /var, /usr, /home and /opt would be better suited on logical volumes. The problem is that the server is already built, and the above directories already exist at /.

Here is what I am thinking:

1) My volume group already exists --> Dell01
2) create logical volume
lvcreate -L 2G -n lvol4 /dev/Dell01
3) make filesystem
mkfs -t reiserfs /dev/Dell01/lvol4
4) modify fstab with the following entry:
/dev/Dell01/lvol4 /varNEW reiserfs acl,user_xattr 1 2
5) create mount point
mkdir /varNEW
6) mount varNEW
7) copy -R /var /varNEW

Okay. Now I've got the data copied to /varNEW. How do I rename /varNEW to /var? I'm stumped.
 
Old 02-02-2006, 06:27 PM   #2
patrokov
Member
 
Registered: Jan 2006
Location: Riviera Beach
Distribution: Slackware -current, ArchLinux
Posts: 59

Rep: Reputation: 15
In order to change the location of a system dir, once you've copied over the files, change your fstab to point /var to the new partition and then remount the partition.

# mount -o remount /device/partion
 
Old 02-02-2006, 06:52 PM   #3
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,004

Rep: Reputation: 304Reputation: 304Reputation: 304Reputation: 304
First, I would name your volume group starting with the text "vg" to make it obvious what it is, for easy identification when you're scanning through the large /dev directory. Second, I would name the individual logical volumes in some way that indicates there eventual mountpoints. [edit]"there", "their", "they're" ... ahhh, who cares! ;-)[/edit] These are my personal preferences only, you may want to do things differently. The final "telinit 2" in my example below should be replaced with whatever your default multiuser runlevel is. On my Debian system it's 2, your SuSE system may be different.
Code:
$ su
# telinit 1
# lvcreate -L 2G -n suse_var /dev/vg_Dell01
# mkfs -t reiserfs /dev/vg_Dell01/suse_var
# mkdir /mnt/tmp
# mount -t resierfs /dev/vg_Dell01/suse_var /mnt/tmp
# cp -R /var /mnt/tmp
# mv /var /var.old
# umount /mnt/tmp
# rmdir /mnt/tmp
# mount -t resierfs /dev/vg_Dell01/suse_var /var
# vi /etc/fstab .....
# telinit 2
Test, and if all looks good, you can delete /var.old

Last edited by haertig; 02-02-2006 at 07:14 PM.
 
Old 02-03-2006, 11:25 AM   #4
bret
Member
 
Registered: Apr 2005
Location: SLC, Utah
Distribution: RHEL 4, RHEL 5
Posts: 59

Original Poster
Rep: Reputation: 16
one minor issue

Thanks for the info, Haertig! Everything worked pretty well until I issued the mount command:

mount -t resierfs /dev/vg_Dell01/suse_var /var

The directory (mount point) /var did not exist. I then created the mount point:

mkdir /var

I then edited /etc/fstab with the appropriate entry. I then rebooted. This is when the problem occurred. The boot log said that it couldn't write to /var/.. whatever. The problem was that var was in the directory var --> /var/var

I was able to fix this but am not sure how /var.old was copied to /var/var. hmmmm. Anyway, you got me on my way. Thanks alot.
 
Old 02-03-2006, 11:40 AM   #5
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,004

Rep: Reputation: 304Reputation: 304Reputation: 304Reputation: 304
Quote:
Originally Posted by bret
The directory (mount point) /var did not exist.
Oops. I forgot to put in an example command to create the new mountpoint. Drats! Obviously you have the smarts to figure this out, as you so quickly noticed and correct my omission. Sorry about that.
Quote:
I was able to fix this but am not sure how /var.old was copied to /var/var.
Yeah, who knows. Probably just some typo somewhere on the commandline. Better clean it all up now though, because when you come back to /var in six months you'll be scratching your head ... "What the heck is /var.old and /var/var???!!!"
 
Old 02-03-2006, 11:59 AM   #6
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,004

Rep: Reputation: 304Reputation: 304Reputation: 304Reputation: 304
One other thing I learned (from experience) about naming volume groups, generic names are not so good always. I had two volume groups on my system, named "vg0" and "vg1". There are probably tons of systems out there with these exact volume group names. Then I plugged in another harddisk that coincidently happened to have a volume group on it also named "vg0". Well, I can't tell you who was more confused on initial boot after this new harddisk was added - me or the OS. That first boot attempt was good for learning and troubleshooting, but not much else!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
cloning logical volume with dd astrowill Linux - General 3 07-13-2005 09:59 AM
swapping on a logical volume garba Linux - General 1 06-28-2005 06:36 PM
resizing a logical volume nicentral AIX 2 06-11-2005 04:03 PM
logical volume manager plythgam Linux - Software 1 11-08-2004 10:47 AM
Logical Volume Management jatimon Linux - General 0 04-17-2002 02:57 PM


All times are GMT -5. The time now is 09:21 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration