Want to resize a Linux partition via CLI

Discussion in '*nix Software' started by Jeff7181, Nov 23, 2012.

  1. Jeff7181

    Jeff7181 Lifer

    Joined:
    Aug 21, 2002
    Messages:
    18,322
    Likes Received:
    0
    I have Ubuntu Server 12.04 running in a VM. /dev/sda1 is mounted on / and is running out of free space. I've already resized the disk in VMware to a much larger size, but I'm having some trouble figuring out how to resize the partition. In Windows, I'd just go to disk management and extend the partition into the free space on the disk. I'm just not sure how to do that via command line in Linux. Can anyone help?
     
  2. lxskllr

    lxskllr Lifer

    Joined:
    Nov 30, 2004
    Messages:
    44,388
    Likes Received:
    33
    I can't help with the cli resize, but perhaps you can delete your apt cache to free up some space on /. All your downloaded packages get kept, and it can take a tremendous amount of room. sudo apt-get clean will delete those packages. apt-get autoclean is a bit more conservative, as it only removes packages that aren't available anymore. Your choice, but I always use clean.
     
  3. Red Squirrel

    Red Squirrel Lifer

    Joined:
    May 24, 2003
    Messages:
    36,510
    Likes Received:
    495
    Does it have to be CLI? There is a GUI boot CD tool you can use (gparted) that is like Partition Magic and works great. I think in the back end it does use CLI so there may be a way you can see the command it issued. You can probably open a console and do ps aux while it's running.
     
  4. Jeff7181

    Jeff7181 Lifer

    Joined:
    Aug 21, 2002
    Messages:
    18,322
    Likes Received:
    0
    I guess it doesn't have to be. But I figured there should be a way to do it at the command line rather than use a boot CD. If not, then I guess I'll use a boot CD... but even Windows is capable of the same task via command line. I'd be shocked if there wasn't a way to do it in Linux without a boot CD.
     
  5. Jeff7181

    Jeff7181 Lifer

    Joined:
    Aug 21, 2002
    Messages:
    18,322
    Likes Received:
    0
    I booted to the Ubuntu Live CD and was able to extend the partitions. Thanks for the suggestion.
     
  6. Nothinman

    Nothinman Elite Member

    Joined:
    Sep 14, 2001
    Messages:
    30,672
    Likes Received:
    0
    Either parted or a combination of fdisk and a filesystem resize tool should work from a live system as long as the filesystem supports online resizing.
     
  7. LumbergTech

    LumbergTech Diamond Member

    Joined:
    Sep 15, 2005
    Messages:
    3,624
    Likes Received:
    0
    #7 LumbergTech, Nov 24, 2012
    Last edited: Dec 5, 2012