LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-17-2014, 08:08 PM   #1
cynicalpsycho
Member
 
Registered: Mar 2009
Location: America
Distribution: Debian/Arch
Posts: 134

Rep: Reputation: 16
Expanding the Root file system (Need help)


Hello All,
I have recently installed a debian based OS on my system, with 2 primary partitions SDA1 and SDA2 SDA1 has my boot partition and SDA2 has 2 logical partitions and the swap.

I've tried shrinking the sda2 filesystems in Gparted (while in a live cd so I could unmount them) and expanding the sda1 but I have no luck. I just get unallocated disk space for SDA2 and it still doesn't allow me to expand sda1 past its original 9.31 GB in size... any ideas?

I ran into this problem when installing some software. It seems that files are being saved into my SDA1 filesystem instead of my rather large sda2... an alternate solution could be figuring out how to make sure all of my files are just getting saved to sda2...

Thanks in advance for the help.
 
Old 08-17-2014, 08:15 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Subject says "Root", post says "SDA1 has my boot partition". We need valid data
Code:
df -hT
sudo parted /dev/sda "print free"

Last edited by syg00; 08-17-2014 at 08:25 PM. Reason: updated parted command
 
Old 08-17-2014, 10:06 PM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Perhaps you don't have to.

I am assuming your new software is installed in /usr. If it is not, substitute the name of the directory it is installed in.

In the free space on sda2 create a new partition. Mount this partition on an arbitrary place in you file system. For example (as root):
mkdir /mnt/usr
mount /dev/sda6 /mnt/usr (I assume the new partition is sda6, change as needed)
rsync -auv /usr/ /mnt/usr/

This copies everything to the new partion.
Now change your fstab and mount the new partition as /usr.
In Debian partitions are mounted by UUID. Find the UUID of your new partition with the blkid command.
Then reboot.

When you are done, check df -h to make sure you are using the right partition as /usr.
Finally when you are sure you are using the correct partition, mount the old partition below /mnt/usr and delete the files to free up the old space on sda1.

jlinkels
 
Old 08-18-2014, 12:11 AM   #4
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Post output of
Quote:
cat /etc/fstab
&
Quote:
fdisk -l
 
Old 08-19-2014, 02:11 PM   #5
cynicalpsycho
Member
 
Registered: Mar 2009
Location: America
Distribution: Debian/Arch
Posts: 134

Original Poster
Rep: Reputation: 16
I've since reimaged the machine thinking that putting it all on one partition would be better... but no luck...


Quote:
Originally Posted by EDDY1 View Post
Post output of
&
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=394c67f7-11b3-463c-ae27-89e3effa24de / ext4 errors=remount-ro 0 1
# /home was on /dev/sda6 during installation
UUID=9591bfe5-fa89-4fef-9fe5-655443e9369c /home ext4 defaults 0 2
# swap was on /dev/sda5 during installation
UUID=c34c2ae4-f86b-499a-b5a2-3dc4ed8d2cea none swap sw 0 0


and


Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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: 0x0004efe0

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 19531775 9764864 83 Linux
/dev/sda2 19533822 488396799 234431489 5 Extended
/dev/sda5 19533824 36304895 8385536 82 Linux swap / Solaris
/dev/sda6 36306944 488396799 226044928 83 Linux
 
Old 08-19-2014, 02:42 PM   #6
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Ok
Shrink /home sda6 from left
Move swap sda5 to right
Shrink Extended sda2 from left
Grow sda1 to right.
 
Old 08-19-2014, 10:38 PM   #7
cynicalpsycho
Member
 
Registered: Mar 2009
Location: America
Distribution: Debian/Arch
Posts: 134

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by EDDY1 View Post
Ok
Shrink /home sda6 from left
Move swap sda5 to right
Shrink Extended sda2 from left
Grow sda1 to right.
That's exactly what I tried to do.
But when I did that I was only able to get to step 3 in your list there. For some reason it wouldn't allow me to increase SDA1 past it's original size, regardless of how much unallocated space I had directly next to it. it was as if the two partitions were physically segregated.

Last edited by cynicalpsycho; 08-19-2014 at 10:46 PM.
 
Old 08-19-2014, 10:41 PM   #8
cynicalpsycho
Member
 
Registered: Mar 2009
Location: America
Distribution: Debian/Arch
Posts: 134

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by syg00 View Post
Subject says "Root", post says "SDA1 has my boot partition". We need valid data
Code:
df -hT
sudo parted /dev/sda "print free"
Filesystem Type Size Used Avail Use% Mounted on
rootfs rootfs 9.1G 8.6G 59M 100% /
udev devtmpfs 10M 0 10M 0% /dev
tmpfs tmpfs 397M 680K 396M 1% /run
/dev/disk/by-uuid/394c67f7-11b3-463c-ae27-89e3effa24de ext4 9.1G 8.6G 59M 100% /
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 794M 21M 773M 3% /run/shm
/dev/sda6 ext4 213G 127M 202G 1% /home

and

Model: ATA ST9250827AS (scsi)
Disk /dev/sda: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 10.0GB 9999MB primary ext4 boot
10.0GB 10.0GB 1048kB Free Space
2 10.0GB 250GB 240GB extended
5 10.0GB 18.6GB 8587MB logical linux-swap(v1)
18.6GB 18.6GB 1026kB Free Space
6 18.6GB 250GB 231GB logical ext4
250GB 250GB 188kB Free Space
 
Old 08-19-2014, 10:58 PM   #9
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
You need to do in exactly the order suggested for it to work.
 
Old 08-19-2014, 11:01 PM   #10
cynicalpsycho
Member
 
Registered: Mar 2009
Location: America
Distribution: Debian/Arch
Posts: 134

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by EDDY1 View Post
You need to do in exactly the order suggested for it to work.
Out of curiosity, why would the order matter so long as the unallocated disk space is directly next to the proper partition?
 
Old 08-19-2014, 11:49 PM   #11
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Because you have to take the space from /home & it's at the end of the disk. That's why you start there resizing & creating free space before each partition until you've moved that space to where it can beused in /.
 
Old 08-20-2014, 03:01 AM   #12
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by cynicalpsycho View Post
But when I did that I was only able to get to step 3 in your list there. For some reason it wouldn't allow me to increase SDA1 past it's original size, regardless of how much unallocated space I had directly next to it. it was as if the two partitions were physically segregated.
Get to that point and make sure you "apply" the changes. Run the parted command again so we can see what's happening - I see no (insufficient) free space listed. Then try to expand sda1 - and don't forget to apply it again.

And use [code] tags so we can read the ouput.
 
Old 08-20-2014, 07:40 PM   #13
cynicalpsycho
Member
 
Registered: Mar 2009
Location: America
Distribution: Debian/Arch
Posts: 134

Original Poster
Rep: Reputation: 16
Sorry guys I took the cowards way out
Nuked my kali install and just did a reinstall with the whole thing on one partition.

Prior to that however I was able to follow eddys guidance... at least for the most part... I was allowed to expand my root partition in the GUI. But during the expansion process I kept getting errors from GParted which effectively prevented the completion of the process.

I genuinely appreciate the help you guys offered, sorry I couldn't implement it properly.
 
Old 08-20-2014, 08:34 PM   #14
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
FYI - there's always a way around this kind of problem. In this case, you could have used "du -shx /* | sort -h" to see which directories in your root filesystem were using the most space. Typical choices would be /usr or /var. Then you create a new partition, somewhere, anywhere, doesn't matter...just make a new partition that's at least as large as you need to hold your largest directory found above plus room for growth.

Then you boot up a live CD, mount all of your filesystems so you can work with them, "rsync -a" your /usr (or whatever it happened to be) (of course since you're in a live CD, it won't be /usr, it'll be /path/to/mount/point/usr, but I'm assuming you know that) directory to your new partition, move your /usr directory to, say, /usr.backup (again it on't be /usr or /usr.backup, it'll be /path/to/mount/point/usr, etc), edit your /etc/fstab (once again it won't be /etc/fstab, it'll be /path/to/mount/point/etc/fstab) to mount your new "/usr" partition to /usr, and then reboot.

If all goes well, /usr will transfer seamlessly onto your new partition, and once you verify everything is working correctly you can delete /usr.backup and clear out the space on your root filesystem.

Since you'll be working with root filesystems mounted in subdirectories of a different root filesystem (your live CD), you need to make absolutely sure you understand the steps I described above before you try this. If you understand the concept, then adapting the instructions to your specific case should be very simple, and you should be able to accomplish this without issue. I do this all the time on new server installations where /home needs to be located on a separate RAID array that isn't initialized/available during the OS installation process. It's simply a matter of:
1) install the OS
2) set up the partitions you want to transfer data onto
3) if the directory that you want to transfer to the new partition is critical to the operation of the OS, then reboot to a live CD, mount your partitions, and adapt all paths in the following steps as necessary
4) "rsync -a" the directory of interest onto its new home
5) move the old directory to a new name so it doesn't interfere, but is still available as a backup "just in case"
6) create the directory again (since you just renamed the old one, we need a blank copy in its place to serve as a mount point for your new partition)
7) mount the partition at its new home, verify all of the necessary files are available as before (no weird directory changes have taken place, /usr/lib/file is still /usr/lib/file, etc)
8) edit /etc/fstab appropriately (if you are in a live CD environment, adapt the path to the appropriate fstab accordingly)
9) reboot
10) if it all works correctly, delete the backup and move on with your life
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
after expanding filesystem, system reports correct filesize but only root can write jonas_berlin Linux - General 6 01-15-2012 02:36 PM
Expanding file-system to additional (externally mounted) HD pdown85 Linux - Hardware 2 09-16-2008 08:22 AM
RHEL 3: Steps of expanding file system (add new SCSI disks) to existing SW RAID & LVM atman1974 Linux - General 2 01-12-2006 09:49 PM
Boot Error: Root file system /dev/root adtomar Linux - Networking 0 12-27-2004 10:50 AM
Expanding root partition? biniar Linux - Newbie 1 04-07-2004 01:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:20 PM.

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