Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Red Hat This forum is for the discussion of Red Hat Linux.


  Search this Thread
Old 08-22-2006, 05:21 AM   #1
LQ Newbie
Registered: Aug 2006
Posts: 2

Rep: Reputation: 0
Partitioning RAID Array. LVM? parted?


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.




Here are some config details:

[root@server ~]# cat /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details
/dev/md2 / ext3 defaults 1 1
/dev/md0 /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
/dev/md1 swap swap defaults 0 0

(parted) print
Disk geometry for /dev/sda: 0.000-152627.835 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 101.975 primary ext3 boot, raid
2 101.975 2149.321 primary linux-swap raid
3 2149.321 152625.344 primary ext3 raid
(parted) select /dev/sdb
Using /dev/sdb
(parted) print
Disk geometry for /dev/sdb: 0.000-152627.835 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 101.975 primary ext3 boot, raid
2 101.975 2149.321 primary linux-swap raid
3 2149.321 152625.344 primary ext3 raid

[root@server ~]# mdadm --misc --detail /dev/md0
Version : 00.90.01
Creation Time : Mon Aug 7 22:41:35 2006
Raid Level : raid1
Array Size : 104320 (101.88 MiB 106.82 MB)
Device Size : 104320 (101.88 MiB 106.82 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Tue Aug 8 03:00:22 2006
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
UUID : 62655ecf:e3ceaaf4:
Events : 0.23

[root@server ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb2[1] sda2[0]
2096384 blocks [2/2] [UU]

md2 : active raid1 sdb3[1] sda3[0]
154087360 blocks [2/2] [UU]

md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]

unused devices: <none>
Old 08-23-2006, 02:05 PM   #2
Registered: Jul 2003
Location: Miami, Florida, USA
Distribution: Debian
Posts: 848
Blog Entries: 1

Rep: Reputation: 47
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
-reformat it
-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.
Old 08-25-2006, 01:15 AM   #3
LQ Newbie
Registered: Aug 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks Ram,

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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Partitioning question - LVM satimis Fedora 1 08-14-2006 03:34 PM
partitioning advice with QT Parted aw76 Linux - General 6 01-10-2006 11:49 AM
LVM versus parted scott.anderson Linux - Software 0 07-19-2005 10:28 AM
Partitioning: GNU Parted Gerardoj Linux - General 1 06-01-2003 02:50 AM
Parted (and partitioning in general) Grim Reaper Linux - Software 35 11-06-2002 12:44 AM > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 01:11 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration