Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The genius that originally set up the web server at my company put the swap, /var, and / directories on different drive pairs. I need to some how consolidate all three into one drive for migration purposes. How do I even go about getting started on this?

Here's the fstab:

/dev/VolGroupROOT/LogVolROOT /                       ext3    defaults        1 1
/dev/VolGroupVAR/LogVolVAR /var                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroupSWAP/LogVolSWAP swap                    swap    defaults        0 0

as asked, vgdisplay on both: /dev/VolGroupROOT

/dev/hda: open failed: No medium found
--- Volume group ---
VG Name               VolGroupROOT
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  2
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                1
Open LV               1
Max PV                0
Cur PV                1
Act PV                1
VG Size               141.59 GB
PE Size               32.00 MB
Total PE              4531
Alloc PE / Size       4531 / 141.59 GB
Free  PE / Size       0 / 0
VG UUID               FyYBeE-ZPwK-Gaz0-yVEZ-wPEb-o8zH-zPCHES

/dev/VolGroupSWAP

/dev/hda: open failed: No medium found
--- Volume group ---
VG Name               VolGroupSWAP
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  2
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                1
Open LV               1
Max PV                0
Cur PV                1
Act PV                1
VG Size               2.91 GB
PE Size               32.00 MB
Total PE              93
Alloc PE / Size       93 / 2.91 GB
Free  PE / Size       0 / 0
VG UUID               LElLqf-VcS4-rv9T-9wQV-svWU-5AaY-CYIy08
share|improve this question
    
My sincere condolences –  Lucas Kauffman May 3 '12 at 19:08
    
Can you do a vgdisplay on /dev/VolGroupROOT & /dev/VolGroupVAR/LogVolVAR. Do they belong to say PV ? –  Chakri May 3 '12 at 19:10
    
I have no idea. I added them above though. –  Luke May 3 '12 at 20:05
    
can you also post the "df & pvdisplay" outputs please. I have an idea based on the results. –  Chakri May 3 '12 at 20:10
add comment

2 Answers 2

up vote 1 down vote accepted

Given that linux is mostly just a bunch of text files, you should be able to copy files around as needed. Boot your server to a rescue CD of some sort, mount /dev/VolGroupROOT/LogVolROOT and /dev/VolGroupVAR/LogVolVAR to separate directories, copy away, comment out the /var line from /etc/fstab (wherever it's mounted), reboot.

In your case, you'll want to copy the contents of /dev/VolGroupVAR/LogVolVAR to a directory var/ in wherever you mounted /dev/VolGroupROOT/LogVolROOT. See the man pages for cp or rsync for options -- you'll want to preserve permissions, follow symlinks, etc.

Don't worry about swap, you can run without it and re-add swap on the fly later, in a different location. Comment out any swap lines in fstab, see swapon.

Do a reality check to make sure you have enough space on the ROOT device for everything in VAR, and try it on another machine first if this server is important.

Also, there are perfectly good reasons for putting /var, swap, or any other directory on different filesystems, depending on what they're used for: Separate i/o across disk spindles, separate disk usage, have different tiers of storage performance, etc.

share|improve this answer
add comment

Here are the steps, depending on your conditions.

  • If you don't have enough space on your /. Expand your PV -> VG -> /dev/VolGroupROOT/LogVolROOT

  • Boot it to single user mode.

    • Comment out /var in your fstab
    • Create /var2 dir
    • ls -ld /var /var2
    • Ensure that /var2 has the same ownership and permissions as /var
    • sync your /var -> /var2
    • Umount /var
    • rm -r /var
    • mv /var2 /var
  • For swap you can create a new LogicalVol in the above VG. Delete the old and activate the new.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.