0

This is the original output of fdisk -l:

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         268     2048287+  82  Linux swap / Solaris
/dev/sda3             269        2611    18818810   83  Linux

I've added another disk space and reboot, now it is:

Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         268     2048287+  82  Linux swap / Solaris
/dev/sda3             269        2611    18818810   83  Linux

This is the content of /etc/fstab:

LABEL=/  /  ext3  grpquota,usrquota,rw  0  1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda2         swap                    swap    defaults        0 0

This is the output of df -T:

Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/sda3     ext3    18231732  16718804    571992  97% /
/dev/sda1     ext3      101086     37191     58676  39% /boot
tmpfs        tmpfs      513040         0    513040   0% /dev/shm

And this is the output of mount:

/dev/sda3 on / type ext3 (rw,grpquota,usrquota)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

What are the steps to mount the additional space on the root partition / (in addition to the current /dev/sda3 space) ?

I'm on a VPS, no LVM, no physical access, just remote ssh.

My OS is CentOS 5.8 x86_64.

2 Answers 2

1

The steps generally are

  1. Boot from rescue media
  2. Re-partition the /dev/sda3 partition to extend to the new top-of-drive
  3. Use resize2fs to grow the root FS to the new top-of-partition
  4. Reboot, you're done.

There is some possibility that you can now use resize2fs to grow the root FS while the OS is running, but unless you have a very pressing need to avoid a reboot, and some excellent backups, I wouldn't do this. That said, I'd make sure I had backups before I did any of this, anyway; better safe than sorry.

You can find more detailed tutorials on this all over the web. This one looks OK, if a bit old; this one covers "live" resizing (ie, with the OS running); but you should google until you find one that suits you.

Edit: yes, the fact that this is a VPS does change things a bit. Looks like you'll be wanting to read a live resizing tutorial, but the upshot seems to be (assuming you're using ext3 FSes):

  1. Delete and recreate the sda3 partition so it reaches to the new top-of-disc. Make very sure you don't change the bottom of the partition; only the top.
  2. Reboot so the new partition table is cached
  3. Stop all the services except sshd
  4. Kick all the users off
  5. Do a resize2fs [-p] /dev/sda3. The -p gets you a progress bar so you've something to look at while wondering if you should be updating your CV ;-) .
  6. If df confirms you have a lot more space, reboot.
3
  • Question updated, I'm on a vps, I can only manipulate the server via ssh
    – User
    Jan 9, 2013 at 16:47
  • So I don't need to create a temporary filesystem which require 2GB of RAM (as noted in the mentioned tutorial)?
    – User
    Jan 9, 2013 at 17:12
  • I don't believe so, provided your root FS is suitable for online resizing (which I think means it's ext3). If you're going to do this, don't forget those backups. And test a restore first.
    – MadHatter
    Jan 9, 2013 at 17:50
1

So, if you are using LVM, you can grow the space while the disk is online. However, if this is ext4 (or 3) that is not a possibilitiy. In which case, you umount the disk and then use resize2fs.

While MadHatter's way is totally correct -- my favorite, favorite, favorite tool is GParted. Download it, make an .ISO, and boot into GParted. It's fairly self explanatory and does have a GUI, which can make it easier for some. You can use this guide here though if you need to, though.

5
  • I can only use ssh remote connection, does installing GParted from EPEL repo is relevant?
    – User
    Jan 9, 2013 at 17:05
  • Sorry, when I posted that I hadn't seen your update. GParted is the Gnome Partition Editor based on GNU Parted. It is NOT possible to extend an ext4 root partition while Linux is running. If you were using LVM, this would be possible. Extending a partition is 2 parts, part 1) Growing block size, part 2) extending filesystem. If it's the root partition, you can't do part 1 live. So, you'll have to wait until you can -- and I'd use GParted for that. :) And as always -- make sure you have a backup.
    – Ethabelle
    Jan 9, 2013 at 17:22
  • @Ethabelle I am a bit confused about what you are saying. man resize2fs has this statement (As of this writing, the Linux 2.6 kernel supports on-line resize for filesystems mounted using ext3 and ext4.)
    – Zoredache
    Jan 9, 2013 at 17:46
  • @Zoredache Correct. You can resize an ext4 filesystem while Linux is running (still not a good idea, should umount first), but not the root partition. He said he specifically wants to extend the root partition, it's not possible without taking the system offline.
    – Ethabelle
    Jan 9, 2013 at 17:50
  • @Zoredache Albeit, I am assuming that User 57 hasn't extended the partition yet. If he in fact, extended the root partition already (took it offline and grew the partition, or, dear god, deleted the partition and recreated it using fdisk -- which is possible to do while root partition is running, then reboot, and use resize2fs) then using, resize2fs will be able to extend the filesystem to the grown partition, even if it's root. I just assumed that he hadn't done step one yet based on the results of his df -T.
    – Ethabelle
    Jan 9, 2013 at 17:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .