Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm experiencing the all-too-common "root partition full" situation. 100% of my hard drive is allocated. My home (ext4) partition has plenty of space to give up for my full root partition (rootfs).

Is there an amazing step by step tutorial out there for this type of a scenario where the root partition (rootfs) needs to be expanded after shrinking an ext4 partition (my home partition)?

share|improve this question
    
How large is your root partition? –  jippie Nov 3 '12 at 21:38
    
And do you really require an 'excellent' tutorial? Or are you able to follow some man pages if you are pointed to some tools? –  vgoff Nov 3 '12 at 21:48
    
@jippie ~9.7 GB. –  trusktr Nov 3 '12 at 22:16
    
@vgoff Some man pages might do. Personally, I dislike the unstructured and sometimes detail lacking format of man pages. info pages other other hand are great (easily navigable, structured, menus), but hardly anyone makes info pages for their apps. I'm sure I can man gparted but that doesn't beat a good tutorial. –  trusktr Nov 3 '12 at 22:18
1  
1. Go back in time. 2. Do your installation on LVM. That makes resizing filesystems considerably easier. –  Gilles Nov 3 '12 at 23:30

2 Answers 2

Depends a lot on how you want to resize it and how your partitions are organized. Growing a partition (moving its end further down the disk) is easy, while shrinking a filesystem, especially by moving its partition start closer to its end, is virtually impossible if you want to do it in-place. You'd have to:

  1. backup the partition to be shrunk to another drive (or - if you are brave enough - at least to a partition that you are not going to touch at all)
  2. run partitioning sw (fdisk/gdisk/parted/...):
    • remove partition that follows the one you need to grow
    • move end of the previous partition - either your program can do that in one step, or you have to note it's start position, delete it and recreate it with exactly the same start. Also note, that some programs might have the tendency to format the newly created partition, in which case you'd end up doing fresh reinstall.
    • create the next partition in the smaller space that is left
  3. grow the filesystem on the grown partition.
  4. create a new filesystem on the new smaller partition and copy your data from the backup.

That said, I would propose something else (apart from a reinstall, which doesn't have to be that messy, provided you save your system configuration properly):

  1. check whether the space problem isn't caused by overflowing /tmp or /var directories and possibly do some cleanup;
  2. check whether you don't have some dead packages, that you no longer use - those would be just possible security risks;
  3. after that, check whether there are some substantial parts of the rootfs that could be moved to a separate partition - likely candidates are: /tmp, /var, /opt, /usr/local. If that turns out to be the case, create a separate filesystem, create a directory in /, mount the filesystem there, move there the subdirectories in question, and bind-mount them to their previous locations (e.g. mount --bind /new_partition/var /var). Remember to add all the needed mounts to /etc/fstab. If you are moving only one subtree, you can plainly mount it to it's original place and not mess with bind-mounting.

edit:

  1. You can also move the contents of the root partition to another bigger one - the only things that should be necessary to change are references to the root partition (as a device) in:

    • /etc/fstab (or any other files used for mounting filesystems)

    • bootloader configuration

      a) what partition to load the kernel and initrd from (unless you have a separate /boot filesystem that you are not going to touch)

      b) the root= kernel option which tells kerenl wha to mount as / (not sure whether that would be the case with initrd, but it's going to have to be changed somewhere).

  2. All of these operations should not be done from the system you are intending to change (especially the move of /tmp and/or /var to a different filesystem - daemons may keep their files there and it could damage the running system) - a live CD or another minimal installation should do the trick.

share|improve this answer
    
Thanks, I removed some unused programs to free some space, but no doubt I will have to return to this soon. –  trusktr Nov 10 '12 at 4:44

Tutorial:

  • Download Parted Magic

  • Burn it, boot it

  • Use the simple Gparted GUI to resize partitions any way you'd like

Should be a breeze. Shrinking, expanding, moving.

share|improve this answer
    
Thanks. i'll take a look at that. –  trusktr Nov 10 '12 at 4:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.