LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Increase the size of the linux(CentOs) dual booted partition (https://www.linuxquestions.org/questions/linux-newbie-8/increase-the-size-of-the-linux-centos-dual-booted-partition-4175553027/)

PrazSam 09-09-2015 07:50 AM

Increase the size of the linux(CentOs) dual booted partition
 
Hi all,
I have dual booted CentOs with windows and now I want to increase the size of the linux partition. I don't want to loose the current linux installation with all it's data. There is a NTFS type partition (Other than Windows Os partition) that can be used here. I want to allocate few GBs from it to linux partition. Can it be possible without any loose of data and how can i do it?

suicidaleggroll 09-09-2015 10:23 AM

Are you using LVM on CentOS? If not, the safest bet would be to create a new Linux partition and migrate one or more of your large directories (/var, /usr, etc.) over to it, freeing up that space on the primary partition.

kilgoretrout 09-09-2015 10:40 AM

An alternative method to what suicidaleggroll suggested would be to shrink the space on a partition adjacent to your linux partition and then enlarge the linux partition using the adjacent unallocated space obtained from shrinking the foregoing adjacent partition. You can't do this with the system live and your partition structure must be such as to allow for the shrinking of an adjacent partition. You can do this using the gparted livecd and the gparted partitioning tool:

http://linux.softpedia.com/get/Syste...eCD-8864.shtml

A word of caution - backup your data first before doing any partitioning operations. Shrinking and enlarging partitions is generally considered among the most riskiest of partitioning operations. I've done it many times and the only time I've had an issue was when I had a power loss in the middle of enlarging a partition. If I didn't have a backup I would have been screwed!!

PrazSam 09-09-2015 11:23 PM

Thanks suicidaleggroll.
The space is filled up with some files of my works on oracle database. So I can't move them. The only way is enlarge the linux partition as I believe. How LVM can help if I use it? (I have no idea about it yet)

Thanks kilgoretrout for the answer some what like I'm looking for. Is there any good step by step tutorial that uses the Gparted for this. I'm afraid because this is the first time I'm going to make changes for a partition after the Os installation.

chrism01 09-10-2015 01:07 AM

LVM enables you to coalesce multiple partitions into one Logical (actually multiple physical aka 'pv's into a Vol Group aka VG then into an LV aka Logical Volume https://en.wikipedia.org/wiki/Logica...er_%28Linux%29
In this case, the partitions do not have be adjacent.

The other option (as kilgoretrout mentions) requires the partitions to be adjacent.

PrazSam 09-10-2015 06:54 AM

1 Attachment(s)
kilgoretrout and All,

I have attached the structure of the hard disk.

Now I'm going to use partedMagic live cd and, I'm going to delete the ntfs partition /dev/sda6 and increase the size of the ext4 formated /dev/sda9 (/). I think I have to delete the sda6 to make it unallocated and move the /boot partition and the swap partition to the right most of the disk. Then I can expand the size of the sda9. Am I correct or what is the correct way? Will it need to repair the boot configuration of linux afterwords.(Due to the movement of /boot) If so is this guidelines ok to follow? (http://gparted.org/display-doc.php?n...b-boot-problem)

yancek 09-10-2015 07:39 AM

I would not delete sda6 as it is a logical partition and it will then change the device numbers for higher numbered logical partition. You said you just wanted a few GB from that partition so you can either boot windows and shrink that partition or use GParted. Usually better off using windows to do that. The link you posted was to the GParted Manual and would be the best source of information available and if you move the boot partition you will need to repair Grub.

If you want to avoid moving boot, you could delete the swap which is nearly 5GB and if that is enough, you could expand the / to include it then shrink sda6 and create another swap.

syg00 09-10-2015 08:14 AM

Never as simple as that of course - reallocating swap will change its UUID. That means fstab and any resume parameters on the bootloader (and initrd) probably need to be amended. And messing with /boot usually means re-installing the bootloader.

suicidaleggroll 09-10-2015 10:04 AM

Quote:

Originally Posted by PrazSam (Post 5418342)
Thanks suicidaleggroll.
The space is filled up with some files of my works on oracle database. So I can't move them. The only way is enlarge the linux partition as I believe. How LVM can help if I use it? (I have no idea about it yet)

You're not using LVM (your screenshot confirms it), so you can ignore that comment.

When you said in the OP a "few GBs", I was under the impression you meant 3-4 GB. If that's the case, you should be able to find other directories on your Linux installation (not related to your database work) that can be moved to another partition, freeing up the few GB you need on your root filesystem. If you need significantly more than 3-4 GB then that probably won't work, however, the entire OS is probably only 8-9 GB so there's only so much you can move to its own partition.

In other words, you would simply reformat sda6 as ext4 instead of ntfs, rsync /usr, /var, and whatever other directories you want over to it, delete the originals, and then symlink or loop mount them back into place from their new home on sda6. The end result is your root filesystem is the same size, but no longer has to contain everything in /usr or /var, which probably adds up to ~6 GB or so (maybe more, you can check with "du -sh /usr /var" as root on your system) and leaves that space available for your database work or whatever else you need it for.

Quote:

Originally Posted by PrazSam (Post 5418342)
Thanks kilgoretrout for the answer some what like I'm looking for. Is there any good step by step tutorial that uses the Gparted for this. I'm afraid because this is the first time I'm going to make changes for a partition after the Os installation.

You should be afraid. Resizing and shuffling around your partitions like that is pretty risky. If you do decide to go that route, you should make a backup of EVERYTHING (including Windows), because there's a reasonable chance you could lose one or more (maybe even all) of your partitions and the data they contain. That's why I said moving some of your large directories to their own partition to free up space would be the "safest" bet. It's not the only option, but shuffling around partitions on the disk like this has a very real risk of partial or complete data loss. It should only be used as a last resort.

PrazSam 09-10-2015 11:38 PM

Thanks suicidaleggroll,yancek,syg00 for your valuable replies.
Got an good idea so far about how things going on.

I think It's better to increase the partition size at once, so I don't want to bother about it again since I'm planing to do lot of things on this linux partition. Changing things again and again is not that easy as I thought. So just ignore the "few GBs" story. Let's assume I want to allocate a big capacity ( assume 80GB). So I must allocate sda6 and the conclusion is I have to keep backups , get the risk of repair or re-installing the bootloader or reinstall everything!! Am I correct, If I can get the risk?

PrazSam 09-11-2015 01:41 AM

Thanks for all of you for your valuable tips. I'm going to take the risk and continue.

Can you all just say the exact procedure I must follow according to my storage layout. I feel I have to move the swap and the boot partitions for left most of sda6 after making it unallocated. Isn't it? Then I can expand the sda9.

yancek 09-11-2015 09:36 AM

Looking at your GParted output above, you have a number of ntfs partitions for windows and if this output is accurate, 213kb of data which would mean no operating system. Do you have windows installed or are you just using these as data partitions. Doesn't look right.

As far as the process, I would suggest reading the GParted Manual in the link you posted as that is going to be the best source of accurate informaiton. If something isn't clear, post back. If you delete a logical partition, other logical partitions with higher numbers will change. In your example, if you were to delete sda6 then your / system would change from sda9 to sda8. Shrink sda6 but don't delete it then go through the process of moving the boot and swap and you will need to re-configure Grub before re-booting. Are you using the current CentOS? I last installed CentOS 6.5 which still used Grub Legacy while 7.0 now uses Grub2.

kilgoretrout 09-11-2015 11:27 AM

As yancek said, I wouldn't completely delete sda6 without knowing a lot more about your present configuration. The basic procedure I would follow after doing a complete backup would be as follows:

1. Shrink sda6 down as much as you want leaving the space to the right of sda6 unallocated. Note, when shrinking sda6 with gparted, you will have the option to leave the unallocated space to either the left or right. This unallocated space is going to travel through your partitions and ultimately be available to your target partition on sda9.

2. Increase sda7 by adding the just created unallocated space on sda7's left. Then shrink sda7 back down leaving the unallocated space on the right of sda7.

3. Rinse and repeat for sda8 - i.e. enlarge sda8 by adding the unallocated space on its left and then shrink sda8 down leaving the unallocated space on the right of sda8.

4. You are now in a position to enlarge sda9. You have unallocated space on sda9's left which you add to sda9 when you enlarge the partition.

The process is like a snake eating an animal. The unallocated space will travel through your partition structure until it is finally available to sda9. You have to go through the successive shrinking and enlarging to move the unallocated space through the hard drive. The good news is shrinking and enlarging partitions will not change their UUID and the operations outlined above won't result in any partition having a different device file name. Accordingly, the system should still be bootable when you successfully complete this process. One potential problem - all your ntfs partitions have yellow triangles in front of them which indicates gparted is detecting some problem with them. That's why the "Used" "Unused" columns are blank. This may cause a problem when you try to resize sda6. Again, make full backups before attempting the above procedure.

PrazSam 09-14-2015 04:02 AM

1 Attachment(s)
Ok, I did the partition change. I want to get the file system back to normal. What can I do now? How can I mount the file system (/) and get the grub working. I have attached the current partition structure. (right hand side)

syg00 09-14-2015 04:33 AM

Better to keep to just one thread.
CentOS have a wiki that should cover most of what you need. The CentOS install DVD should have an option to boot into the disk system - this is called a chroot. It will allow you to refresh the boot-loader. Depending on what you did to the swap, you may need to run a mkswap command on it - hence my earlier warning.


All times are GMT -5. The time now is 12:46 PM.