Move Linux partition to new disk

Hi Experts,

I'm running Redhat Linux AS V4 on a DELL 6850.  The server has 2 RAID arrays - a RAID1 with 70GB and a RAID5 with 145GB.  I've installed the OS onto the RAID1 array (/dev/sda) - sda1 is boot and sda2 is LVM - and the RAID5 is /dev/sdb (nothing devices defined yet).

What I'm trying to do is move /opt from /dev/sda2 to the /dev/sdb disk.  What's the easiest way to do this?
iqaustraliaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rindiCommented:
Partition sdb, format it to your preferred filessystem, then copy /opt to the new partition. Rename the original opt to something like optorig, and now create a symlink called opt in / that points to the new opt folder.

You could also, if the partition you will be using for opt will only host opt, after copying the opt folder to the new partition, make a folder opt in /, then mount the new opt folder to that folder (add the entry to /etc/fstab and make sure it automounts at bootup). If you do it that way, you'll have to make sure you first enter the old /opt folder and copy those contents to the new partition (there should be no opt folder on that partition, or you'll end up with /opt/opt when the partition is mounted to the /opt folder).
0
iqaustraliaAuthor Commented:
Hi there,
Thanks for your quick response.  

I want to move the current /opt on /dev/sda to /dev/sdb and it will be the only folder in /dev/sdb.  I won't have an /opt in /dev/sda.  So, I think this is your second option.

Can you give me the commands to create the new partition in /dev/sdb, how to copy the existing /opt correctly, how to edit fstab and setup the automount?  Sorry, this is all new to me.
0
rindiCommented:
As I hate typing and remembering commands, I always use the midnight commander to do such tasks. If it isn't already installed on your system, install it. Then open it with mc.

Now mount the newly created partition, then in one window pane of mc (you can move between panes with the tab key) navigate to the newly mounted partition (I usually create a mount point /mnt/sdb1, then us mount -t ext3 /dev/sdb1 /mnt/sdb1, if it is using the ext3 filesystem). Now use the tab key to make the other mc pane active. Select opt and press enter so you'll be inside /opt.

Now select all folders and files (select the first folder, press the ins key until all folders and files have been selected down to the bottom of the list, selected files and folders are usually marked yellow in a standard mc setup) and then press the F5 key to copy everything to /mnt/sdb1.

When that has finished, press enter at the top of the list so you'll be returned to the /folder. Move to the opt folder with the mc bar and press F6, then rename the folder to optorig.

Now create a new folder by pressing F7, and give it the name opt.

Now navigate to /etc/fstab, press F4 and you can edit the file. Add the following:

/dev/sdb1        /opt         ext3        defaults           0     0

and save the file by pressing F2

Then leave mc with F10 and unmount /mnt/sdb1, and mount it again using mount /dev/sdb1. If everything is OK it should now get mounted to /opt

Test it with rebooting, and after some testing and you know everything works, you can delete the /optorig folder.
0
iqaustraliaAuthor Commented:
Hi there,

I've got hold of MC, but how do I create the LVM partition and mount it?  Running the command fdisk -l shows the disk array with no partitions, so I first need to know how to create an LVM partition that occupies the entire disk array.
0
rindiCommented:
I haven't used LVM so for that you'd need to read the man pages and readme's on LVM.

To create partitions you can use fdisk,

fdisk /dev/sdb

then use "n" to create the partitions. When done use "w" to commit the changes. After that you have the unformatted partition which you can format using

mke2fs -j /dev/sdb1

if it is going to use ext3 as the filesystem. For further filesystems check the gentoo handbook, it has very good instructions.

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=4#doc_chap4

If you are using a GUI you could also partition and format the disk in one go using QtParted, which is included in most distro's.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.