LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Readjust disk space between /dev/sda2 and /dev/sda5 (https://www.linuxquestions.org/questions/linux-newbie-8/readjust-disk-space-between-dev-sda2-and-dev-sda5-851187/)

born2bdesi 12-19-2010 06:35 AM

Readjust disk space between /dev/sda2 and /dev/sda5
 
[CODE]Hi All-
I am new to Linux and I have it installed on VMWare Fusion.

All was happy until the Linux installation was succeeded and I am able to log in as root and created a user for myself.

However, when I installed Oracle Express Edition Database 10g, it complains that I have insufficient disk space on '/' directory.

Here is a snapshot of my system. Wondering if I would like to swap the free space from /dev/sda5 into /dev/sda2.

Code:

[root@localhost ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device      Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          6      48163+  83  Linux
/dev/sda2              7        515    4088542+  83  Linux
/dev/sda3            516        776    2096482+  82  Linux swap / Solaris
/dev/sda4            777        2610    14731605    5  Extended
/dev/sda5            777        2610    14731573+  83  Linux

Critically waiting for your inputs.

Appreciate it!!

smoker 12-19-2010 07:31 AM

What is the output of df ?
Please use the code tags when posting terminal output.

catkin 12-19-2010 07:41 AM

The partition information, here presented in CODE tags so it is easier to read, is not enough to answer the question without also knowing which partitions are used for what and whether the swap space is used.
Code:

Device      Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          6      48163+  83  Linux
/dev/sda2              7        515    4088542+  83  Linux
/dev/sda3            516        776    2096482+  82  Linux swap / Solaris
/dev/sda4            777        2610    14731605    5  Extended
/dev/sda5            777        2610    14731573+  83  Linux

What is the output of
Code:

df -hT
grep swap /etc/fstab


born2bdesi 12-19-2010 08:10 AM

Thanks for the replies!

Apologies, will use Code Tags from now on.. :)

Here is the output.

Code:

[root@localhost ~]# df -hT
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda2    ext3    3.8G  3.3G  372M  90% /
/dev/sda5    ext3    14G 1016M  12G  8% /home
/dev/sda1    ext3    46M  11M  33M  25% /boot
tmpfs        tmpfs    506M    0  506M  0% /dev/shm
.host:/    vmhgfs    56G  43G  14G  77% /mnt/hgfs

Code:

[root@localhost ~]# grep swap /etc/fstab
LABEL=SWAP-sda3        swap                    swap    defaults        0 0

Please reply.

smoker 12-19-2010 08:25 AM

Please clarify whether the Oracle Express Edition Database 10g is installed or fails to install.

If it is already installed then you need to find out which directory it expects to store the files that need this space. You could then either create a mount point to free space created by shrinking your home partition, or symlink the required directory to a directory on your existing home partition.

If it's not installing because of lack of free space, then you will have to shrink the home partition and create a new partition that you can mount in the required / directory.

Please note that XE 10G will create up to 4 GB of user files.

born2bdesi 12-19-2010 08:28 AM

Thanks for your reply smoker!

Oracle Installation failed with the following error.

Code:

installing package oracle-xe-univ-10.2.0.1-1.0.i386 needs 82MB on the / filesystem
Please reply.

smoker 12-19-2010 08:36 AM

Your df output shows 372MB available on the / partition. Maybe you could clear up any files in /tmp but you are looking at a fair amount of work if you decide to increase the partition size. The installed size of XE 10G is only supposed to be 150MB so I can't see why it would fail. Where did you download the rpm install package to ? Somewhere in home or direct to somewhere in / ?

born2bdesi 12-19-2010 08:42 AM

I have downloaded the RPM package into /home/<my login> and running the installation under 'root' login.

However, I would like to get your inputs on these.

Apart from Oracle10g installatiion, I would also like to install other software under /opt/software director which also has very low space at the moment.

Can I swap some space from /dev/sda5 to /dev/sda2; If so, please provide with instructions / steps to go ahead.

Appreciate your help!!

lazlow 12-19-2010 08:53 AM

You cannot directly move space from sda2 to sda5. You can only move space from one away(sda2 from sda3, sda3 from sda4, and sda4 from sda5), which is a major PITA. There are a couple of ways to get around this. You can add another drive, copy all the files from the sub directory you need more space in, and then mount the new drive to the sub directory in place. Once you are certain everything is working fine you can unmount the other drive, and THEN delete the contents of the orginal sub directory(to regain the space on the master drive). This is how I handle my /home directory. You could do something similar using another partition on the same drive.

smoker 12-19-2010 09:03 AM

Swapping space is not an easy process. Mounting free space is easier, depending on what is already in the required directory.

It would be easier to reinstall and specify a larger / partition during the install.

Failing that, you will have to use the install disk to boot from and use a partitioning tool such as parted to shrink your home partition, create a new partition in the empty space, then create a filesystem on that partition such as ext3 or what ever you choose. You could then edit your fstab file to point /opt/software at the new partition.

To actually move space to the / partition would entail shrinking home, then moving that partition to the end of the free space, then moving every other partition down until the free space was just after the / partition. You could then extend the / partition.

Initially I would try symlinking /opt/software to a directory on your home partition.
You must create the <directory> first.

In a terminal as root ...
Code:

cd /opt
ln -s /home/<user>/<directory> software

Replace <user> and <directory> with real ones on your system.

born2bdesi 12-19-2010 09:05 AM

Thanks for your reply, Lazlow!

Can you please take some time and walk me through the process (with commands), I am a newbie to Linux :(

This is what i understand. Please validate.

Code:

1. Add a new drive (e.g. /dev/sda6). How can I create this?
2. Copy all files from /opt/* to the newly created drive. I can do this step :)
3. Mount the new drive to the sub directory in place. Does this command work?

       
Code:

       
mount /dev/sda6 /opt


In my scenario, I want more space on root (/) partition. At the same time, I do not want to waste the space already available on my home partition; I am running on a 60GB HDD.

Appreciate it!!

lazlow 12-19-2010 09:20 AM

By new drive I meant a physical drive.

On the same drive you would shrink sda5, create a sda6 partition, and then format it.


I do not believe that you can handle the root(/) this way. No pun intended, but it is the root of everything. When I moved my /home directory(in 07?) all I did was to (in gui): format new drive,(temporarily mounted it in media) copy files over(just drug them over), and then (as root in cli) I mounted in (similar as you did above) /home. After I used it for a week and made sure everything was happy, I umounted it, deleted all the data from the orginal /home, and thus regained all the space used by /home(orignal) for root(/). Here is my fstab line I used to make it permament(on bootup). Remember mount points do not take up any(significant) space on the drive.

Quote:

/dev/sda2 /home ext3 defaults 1 2

My boot drive is hda and sda1 is my swap.

born2bdesi 12-19-2010 09:45 AM

Thanks for your replies, Smoker & Lazlow!

Responding to Smoker..
I have established a symbolic link and am able to install software successfully by pointing the install location to /opt/software. However, I still cannot install Oracle 10g XE due to the error it has been returning. Can I instruct Oracle to use /opt directory instead?

Code:

installing package oracle-xe-univ-10.2.0.1-1.0.i386 needs 82MB on the / filesystem
Please assist.

born2bdesi 12-19-2010 09:52 AM

I got a different warning this time when I tried to install Oracle 10g.

Code:

Software installed successfully.
Some warnings were given.

----WARNING---
You have insufficient diskspace in the destination directory (/usr/lib) to
install Oracle Database 10g Express Edition.  The installation requires at
least 1.5 GB free on this disk.

Any clues!

catkin 12-19-2010 09:59 AM

What about commenting swap out of fstab, deleting the swap partition sda3 and growing sda2 into the space formerly taken by sda3? sda5 could be shrunk to make space for a new swap partition.

born2bdesi 12-19-2010 10:01 AM

Thanks Catkin.

I would appreciate if you could throw some light on the commands to be run in order to increase the space in sda2.

smoker 12-19-2010 10:04 AM

Quote:

Originally Posted by catkin (Post 4196805)
What about commenting swap out of fstab, deleting the swap partition sda3 and growing sda2 into the space formerly taken by sda3? sda5 could be shrunk to make space for a new swap partition.

Good plan !

catkin 12-19-2010 10:04 AM

Quote:

Originally Posted by born2bdesi (Post 4196807)
Thanks Catkin.

I would appreciate if you could throw some light on the commands to be run in order to increase the space in sda2.

I'm busy right now; maybe somebody else can do that if there is consensus that it is a workable plan.

born2bdesi 12-19-2010 10:14 AM

Sure, I would wait for your inputs.

I am going to be online again in a couple of hours. Looking forward for your support!

smoker 12-19-2010 10:37 AM

I suggest getting the gparted livecd and using that. It will make things much simpler for you.

catkin 12-19-2010 08:35 PM

Quote:

Originally Posted by smoker (Post 4196833)
I suggest getting the gparted livecd and using that. It will make things much simpler for you.

+1 to that. I believe the native tools are more robust but with a new installation, having no data to back up -- and restore if necessary, gparted would be a good choice.

The swap partition can be commented out of /etc/fstab by a leading # and then edited to suit and uncommented when the partition name of the new swap is known.

born2bdesi 12-20-2010 04:40 PM

Thanks for all your replies!

Here is what has been done.

Code:

Pre: Commented SWAP Partition from /etc/fstab (As suggested by catkin)
Pre: Backed up my VMWare Disk Image

1. Boot using GParted Live CD
2. Deleted the SWAP Partition that was being shown as below.
    Partition                File System                Label                Size               
  /dev/sda3                linux-swap                SWAP-sda3        2.00 GiB
3. Resized /dev/sda2 (/home partition) to a bigger size.
4. Shrinked /dev/sda5 to a smaller size.
5. Created /dev/sda6 to hold SWAP Partition as shown below.
    Partition                File System                Label                Size               
  /dev/sda6                linux-swap                SWAP-sda6        4.00 GiB

Post: UnCommented SWAP Partition from /etc/fstab (As suggested by catkin)

All went good, I rebooted Linux with no issues at all! :)

Current configuration
Code:

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          6      48163+  83  Linux
/dev/sda2              7        776    6184893  83  Linux
Partition 2 does not end on cylinder boundary.
/dev/sda4            777        2610    14731605    5  Extended
/dev/sda5            777        2082    10486620+  83  Linux
/dev/sda6            2082        2610    4243456  82  Linux swap / Solaris

However, I see this warning during boot-up.

Code:

Unable to access resume device (LABEL=SWAP-sda3)
Also, I see a warning in the above fstab output.

Code:

Partition 2 does not end on cylinder boundary.
Do you guys foresee any issues with my current configuration?

Highly appreciate your inputs!

catkin 12-20-2010 10:15 PM

"Unable to access resume device" probably comes from GRUB and could be fixed by editing /boot/grub/menu.lst.

"Partition 2 does not end on cylinder boundary" is a warning, not an error. To adjust the partition table to suit fdisk you could boot gparted again and set it to use "Align to cylinder" instead of "Align to MiB" and then resize /dev/sda2. In retrospect that would have been a better choice the first time around (Sorry -- I do not use gparted and have only just learned of this setting by netsearching).

smoker 12-20-2010 11:40 PM

Unable to resume device is because you have not edited fstab to reflect that the swap partition is now on sda6. Change sda3 to sda6 in fstab and it should be fine.


All times are GMT -5. The time now is 02:54 AM.