LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How can I move my /var directory to my 2nd hard drive? (https://www.linuxquestions.org/questions/linux-newbie-8/how-can-i-move-my-var-directory-to-my-2nd-hard-drive-4175436083/)

mmorton89 11-07-2012 09:24 AM

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.

shahinism 11-07-2012 09:43 AM

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

shivaa 11-07-2012 09:48 AM

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

michaelk 11-07-2012 10:04 AM

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.

mmorton89 11-07-2012 11:17 AM

Quote:

Originally Posted by michaelk (Post 4824228)
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?

michaelk 11-07-2012 02:59 PM

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.

chrism01 11-07-2012 05:45 PM

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.

linosaurusroot 11-07-2012 10:07 PM

http://www.reddit.com/r/linux/commen...m_to_a_second/


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