2

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
Luke
  • 103
  • 7

2 Answers2

1

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.

carillonator
  • 805
  • 3
  • 12
  • 22
1

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.

becomingwisest
  • 3,278
  • 19
  • 17
Chakri
  • 1,070
  • 6
  • 8