Red HatThis forum is for the discussion of Red Hat Linux.
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.
I've just inherited a server which sits about 2000 miles away in a data centre. If I make any changes to it, therefore, I have to be really sure that its not going to mess up.
So, with that in mind, the server was set up with two 160Gb hard disks in a Software RAID 1 configuration. Within the RAID config there is a boot partition, a swap partition and the rest of the disk is dedicated to / . (config details attached below). I want to resize the main partition to 50GB, and move /home onto one partition of 50Gb and then set up another partition for /var. (As an additional wrinkle I want another partition which I intend to encrypt using Truecrypt but we can ignore that for now.)
I've been reading around the internet to see if I can resize the partitions on the disk and/or in the LVM. There seems to be conflicting advice on the subject and I don't want to make a move before I'm absolutely sure. My choices seem to be
a) resize physical disk partition using parted, then resize RAID partition using lvreduce etc. (ref article in gentoo documentation )
b) The converse of this: resize RAID partition first, then resize physical disk
(ref parted manual, specifically:
"You usually resize the file system at the same times as you resize your virtual device. If you are growing the file system and virtual device, you should grow the device first (with the RAID or LVM tools), and then grow the file system. If you are shrinking the file system and virtual device, you should shrink the file system first, and then the virtual device afterwards.
To resize the file system in Parted, use the resize command. For example:
(parted) select /dev/md0"
c) Forget about the physical disk: just do everything in RAID LVM
So, can anyone tell me the definitive way to do this? I guess I'm having a hard time working out the relationship between the LVM and the physical disk. If the server were in front of me, I'd just plough in there and try things out. However its not, and if I mess up, I mess up big.
You should not use LVM to reduce the size. LVM works very well when extending to a bigger size. But shrinking can wipe out data and is know for having unexpected results, especially with root partitions. If you have a data partition and want to shrink it that's ok because even if you loose some data you can always restore from backup, but if it's a root partition it is much more difficult to get it stable.
-I would recommend to force the second drive in your RAID as faulty
-create a new raid md1 with only this drive (you already have md0)
-create new vgm and lv (make sure they have different names)
-copy the root directory and data directory to the new vg/lv
-modify grub on second drive to make sure it'll boot to correct root directory
-create new entry in grub menu for the second drive
-reboot and have someone in front of the screen ready to select the new grub menu entry
-you can always reboot and go back to the first grub menu entry, modify your settings, rinse and repeat
-when you get it working then you'll need to do the same thing to disk one
This is a great task and not for the faint of heart. I've done it at the console but I dare not do it online, especially for a production server. In other words, you have to be an ultra-geek to accomplish this over a remote session.
This is great advice. I'm mulling over whether I'm brave enough to attempt it. Maybe not one for a Friday afternoon ...
Meanwhile I received some other input from the LVM forum. Apparently I'm not running LVM at all! I was assuming that because I had software RAID, then I have LVM, but that's not the case at all. The two are separate and complementary.