LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-07-2012, 10:24 AM   #1
mmorton89
LQ Newbie
 
Registered: Jul 2012
Location: Columbus, OH
Distribution: Centos 6.3
Posts: 20

Rep: Reputation: Disabled
How can I move my /var directory to my 2nd hard drive?


I have been searching around the past 2 days trying to figure out how to move my /var directory to my 2nd HDD.

I really can not figure this out and all the pages google brings me to are "How to move your /home directory to its own disk partition". Which is not what I am trying to accomplish here.

I'm not sure what kind of information you would need to help me out but I will post my disk partitions.

OS - Centos 6.3

Code:
[root@localhost ~]# fdisk -l

Disk /dev/sda: 128.0 GB, 128035676160 bytes
255 heads, 63 sectors/track, 15566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dce01

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       15567   124521472   8e  Linux LVM

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000bd256

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       60802   488385536   8e  Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_swap: 8422 MB, 8422162432 bytes
255 heads, 63 sectors/track, 1023 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_home: 565.5 GB, 565501231104 bytes
255 heads, 63 sectors/track, 68751 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Let me know if you need any other additional information and thank you.
 
Old 11-07-2012, 10:43 AM   #2
shahinism
LQ Newbie
 
Registered: Aug 2012
Distribution: Slackware
Posts: 15

Rep: Reputation: Disabled
If you want to install a Linux system in partitioning step just make a partition there and make a mount point for it like /var.

And if you have a installed Linux system, it's easy as make a partition in the second hard drive you want. then copy your exiting /var files into it and at last modify your /etc/fstab file to automatically mount your new partition as /var directory.
I didn't really test it. but it has to be easy like this ;-)
 
Old 11-07-2012, 10:48 AM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Following links may be helpful:
(1) http://www.linuxquestions.org/questi...d-disk-745489/
(2) http://how-to.linuxcareer.com/learni...ux-commands-dd

(Note: Before taking any actions, don't forget to take backup your important data.)
 
Old 11-07-2012, 11:04 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,929

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
It appears the entire drive is being used as a LV for /home.
Since the entire drive is an LVM partition it isn't as simple as just creating another partition or copy using the dd command.

If /home uses the entire disk space then you will need to:
Resize the filesystem
Resize the LV
Create a new LV
Format the new LV
copy data from the old /var to the new /var
Edit /etc/fstab to add /var LV.

Boot up using the installation disk to the rescue mode.

Last edited by michaelk; 11-07-2012 at 11:06 AM.
 
1 members found this post helpful.
Old 11-07-2012, 12:17 PM   #5
mmorton89
LQ Newbie
 
Registered: Jul 2012
Location: Columbus, OH
Distribution: Centos 6.3
Posts: 20

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
It appears the entire drive is being used as a LV for /home.
Since the entire drive is an LVM partition it isn't as simple as just creating another partition or copy using the dd command.

If /home uses the entire disk space then you will need to:
Resize the filesystem
Resize the LV
Create a new LV
Format the new LV
copy data from the old /var to the new /var
Edit /etc/fstab to add /var LV.

Boot up using the installation disk to the rescue mode.
Sorry, I forgot to mention this is a remote server I am renting, So I can not boot up with the installation disk.

Will I still be able to do this remotely?

Also what exactly is a LV? I think it stands for logical volume, but what exactly is it?
 
Old 11-07-2012, 03:59 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,929

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
You can find lots of info on the web about LVM
http://www.howtoforge.com/linux_lvm

You should be able to perform LVM operations and copy the files on a live system. Since /var contains lots of open files/variable data that are changed on a running system so it is safest to boot into a rescue mode. In addition since there are open files that can not be simply moved so at the moment I do not know of an easy method to delete the original files to free up space. Others might have a better idea.
 
Old 11-07-2012, 06:45 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
As per michaelk, I think you'd really want to go through rescue mode for the final re-naming.
I guess you'd do all the setup as specified, inc a new entry in fstab (which won't take effect until you reboot), then ask your Provider to do the final steps for you.
 
Old 11-07-2012, 11:07 PM   #8
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 979
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
http://www.reddit.com/r/linux/commen...m_to_a_second/
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I move my home directory to another hard drive? ratman1 Linux - Newbie 13 02-29-2012 11:59 AM
load Linux onto a hard drive on one computer then move the hard drive to another Ark9 Linux - Newbie 2 10-06-2008 07:56 PM
how can I move my /home directory to a brand new hard drive? toben Linux - Hardware 7 03-04-2008 04:13 PM
2nd hard drive for home directory? morghanphoenix Ubuntu 2 09-20-2006 10:37 PM
2nd hard drive neo.sarcastic Linux - Hardware 4 09-23-2003 12:22 AM


All times are GMT -5. The time now is 09:01 PM.

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