Solved

Move Linux partition to new disk

Posted on 2007-04-03
7
398 Views
Last Modified: 2013-12-15
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?
0
Comment
Question by:iqaustralia
  • 3
  • 2
7 Comments
 
LVL 87

Expert Comment

by:rindi
Comment Utility
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
 

Author Comment

by:iqaustralia
Comment Utility
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
 
LVL 87

Expert Comment

by:rindi
Comment Utility
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
 

Author Comment

by:iqaustralia
Comment Utility
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
 
LVL 87

Accepted Solution

by:
rindi earned 500 total points
Comment Utility
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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now