How can I move my /var directory to my 2nd hard drive?
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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 ;-)
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.
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?
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.