Solved

Move Linux partition to new disk

Posted on 2007-04-03
7
404 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 88

Expert Comment

by:rindi
ID: 18841715
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
ID: 18841732
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 88

Expert Comment

by:rindi
ID: 18841782
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
ID: 18847491
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 88

Accepted Solution

by:
rindi earned 500 total points
ID: 18848798
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

756 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