LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-03-2016, 12:14 PM   #1
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Rep: Reputation: Disabled
[SOLVED] How to increase size of my / root partition


Running CentOS 6.3 and need to expand the root partition into the unused space next to it?

Tried booting into single user mode but gparted still doesn't allow the (mounted) root partition to be expanded.

Can boot from CD to CentOS 7 systemrescue but from there how do I change the size of the partition.

Unfortunately this old server doesn't seem to like running from any of the live environments (Fedora Live locks-up) which rules out doing it from within any of the live linux distros.

Any suggestions?

Last edited by Nick_C; 04-08-2016 at 05:54 AM.
 
Old 04-03-2016, 03:39 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Need some additional information.

How is your drive currently partitioned? Post the output of the command (as root)
fdisk -l (that is a small L)

Are you using LVM?
 
Old 04-03-2016, 05:48 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
back up all your data
reinstall with 6.7
6.3 has not been supported for a few years


i am guessing you are not using a LVM ( the DEFAULT setting )
that you might be able to resize ? maybe ?

what is the output of
Code:
fdisk -l

Last edited by John VV; 04-03-2016 at 05:50 PM.
 
Old 04-03-2016, 08:08 PM   #4
X-LFS-2010
Member
 
Registered: Apr 2016
Posts: 510

Rep: Reputation: 58
carefully!

you can move files not needed to boot out of (p1) and make them mounts (there is a new option called "bind" too). there are partition moving programs (they are rhobust but you should back up). if you use raid (or which type of filesystem) is an issue. if you have ext2 its simple failsafe and fast - your probably ok. use some highly featured complex filesystem: it might buck and twist and loose something.

however: the BEST thing to do is

1) back up

2) make two partitions, #1 for rescue (a full but more minimal install), #2 the whole system

also important: your "/" keeps a record of all mounts of all kinds. if you change "/" and the mounts "aren't there yet" your system will no longer be coherent and no longer work.

finally, each chroot/ directory is it's own "/", and once (root user) is in it the (user) has the same full access to the kernel as "the real /", so security is out the window on most of todays systems (unless very carefully assembled).

if you can copy sys files into chroot then type "chroot chroot1/" then it's a chroot, just one of any number of "/" the kernel sees

good luck
 
Old 04-04-2016, 05:53 AM   #5
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Output from fdisk -l
Code:
[root@Storage1]# fdisk -l

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00056923

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1936    15549896   83  Linux
/dev/sda4            5585       38913   267715192+   f  W95 Ext'd (LBA)
/dev/sda5           38411       38913     4040316   82  Linux swap / Solaris
/dev/sda6            5585       38410   263674782   83  Linux

Partition table entries are not in disk order

Last edited by Nick_C; 04-04-2016 at 05:54 AM.
 
Old 04-04-2016, 06:45 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
gparted does have a live CD/USB image. Make sure you backup any and all important data just in case. Hopefully they are small enough to run on your system.

http://gparted.sourceforge.net/livecd.php
or
http://www.system-rescue-cd.org/SystemRescueCd_Homepage

Last edited by michaelk; 04-04-2016 at 06:48 AM.
 
Old 04-04-2016, 01:12 PM   #7
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Is there no way or resizing the partition from the command line?
 
Old 04-04-2016, 02:00 PM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Yes, but you have to get things exactly right or your machine won't boot and you'll need to boot from something like SystemRescueCD to recover. If you aren't already familiar with the command line partitioning tools, I don't recommend that you try. Just boot from the rescue CD that you're likely to need anyway and run gparted from that.

If you're really insistent on doing it from the command line on the running system, post the output from "fdisk -lu" so that I can see exactly how to proceed or whether you're going to run up against the limitations fdisk has about where the first partition can start. You're using an old version of fdisk that defaults to cylinder units, and that's not exact enough.
 
Old 04-04-2016, 03:55 PM   #9
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
fdisk -lu returns:

Code:
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00056923

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    31101839    15549896   83  Linux
/dev/sda4        89706960   625137344   267715192+   f  W95 Ext'd (LBA)
/dev/sda5       617056713   625137344     4040316   82  Linux swap / Solaris
/dev/sda6        89707086   617056649   263674782   83  Linux


Partition table entries are not in disk order
I don't need to do this from a running system as I can boot from CD to CentOS 7 SystemRescue. Just checked and I am actually running version 6.7.

Last edited by Nick_C; 04-04-2016 at 03:58 PM.
 
Old 04-04-2016, 05:34 PM   #10
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by Nick_C View Post
Is there no way or resizing the partition from the command line?
you got something against Gparted? that'd be the way I'd go, and have done so.
 
Old 04-04-2016, 06:48 PM   #11
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
The easiest command line tool to make this change is sfdisk. First, use sfdisk to dump the current partitioning onto a file:
Code:
sfdisk -d /dev/sda >parts.out
The contents of the file will look like this:
Code:
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=     2048, size= 31099792, Id=83
/dev/sda2 : start=        0, size=        0, Id= 0
/dev/sda3 : start=        0, size=        0, Id= 0
/dev/sda4 : start= 89706960, size=535430385, Id= f
/dev/sda5 : start=617056713, size=  8080632, Id=82
/dev/sda6 : start= 89707086, size=527349564, Id=83
Edit that file and make the size for partition 1 larger. The maximum that will fit in the available space is 89704912 sectors. That would increase the partition size from its current ~15GB to ~44GB.
Code:
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=     2048, size= 89704912, Id=83
/dev/sda2 : start=        0, size=        0, Id= 0
/dev/sda3 : start=        0, size=        0, Id= 0
/dev/sda4 : start= 89706960, size=535430385, Id= f
/dev/sda5 : start=617056713, size=  8080632, Id=82
/dev/sda6 : start= 89707086, size=527349564, Id=83
Now use sfdisk to repartition /dev/sda from that file and then enlarge the filesystem to fill its new partition:
Code:
sfdisk /dev/sda <parts.out
resize2fs /dev/sda1
Really, you can do all that from the running system. You will just have to include the "--force" option with sfdisk in the repartitioning step and then reboot before resizing the filesystem. The only issue with that is that "--force" will also override any other detectable problems.

(I'm really hesitating before hitting "Submit Reply" on this, but here goes ...)
 
1 members found this post helpful.
Old 04-04-2016, 07:17 PM   #12
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Easily the best thing to do is to convert the system to use LVM = Logical Volume Management. If this had already been in place, then you could have simply added another "physical volume" to the root "storage pool."
 
Old 04-04-2016, 09:51 PM   #13
CGIMan
LQ Newbie
 
Registered: Apr 2016
Posts: 2

Rep: Reputation: 0
Resizing volumes is a breeze with LVM and it can be done using the command line since Nick_C is interested in the CLI.

Plus, you can set a volume for doing snapshots for system restore and/or recovering deleted files depending on which volume you're snapshoting.
 
Old 04-05-2016, 12:11 PM   #14
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
The easiest command line tool to make this change is sfdisk...
Thanks rknichols, worked perfectly. What I actually did for safety was boot to the CentOS 7 SystemRescue prompt and did the resizing from there.

Job done partition is now 30Gb, many thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
increase size of root partition..... Ayas Kumar Linux - Newbie 8 04-15-2012 11:58 PM
increase size of /root partition slayerking Linux - Newbie 19 08-24-2011 01:07 PM
i want to increase my root partition size singhjc Linux - Newbie 3 05-19-2011 07:34 AM
Increase my root partition size? fintan.moloney Linux - Newbie 3 05-30-2006 01:01 AM
How to increase root partition size ? abhigo Fedora 2 01-29-2005 04:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration