1

This sounds like a very basic question, but I have yet to find an answer for it.

I have a partition layout which looks like this:

NAME           MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
xvda           202:0    0  108G  0 disk
├─xvda1        202:1    0   46G  0 part  /
├─xvda2        202:2    0    1K  0 part
└─xvda5        202:5    0    2G  0 part
  └─cryptswap1 252:0    0    2G  0 crypt
xvde           202:64   0  1.5G  1 disk
└─xvde1        202:65   0  1.5G  1 part
xvdf           202:80   0    6G  1 disk

How can I grow the first partition xvda1 ? I only have remote command line only access to the server.

I tried using resize2fs but it seems to fail with a cryptic error

   $ sudo resize2fs /
   resize2fs 1.42.12 (29-Aug-2014)
   open: Is a directory while opening /

EDIT: This is the result from gparted. Rebooting is not a problem, and I do have a backup ready (but I would prefer not to need it of course).

Command (m for help): p
Disk /dev/xvda: 108 GiB, 115964116992 bytes, 226492416 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
Disklabel type: dos
Disk identifier: 0x000da796

Device     Boot    Start       End  Sectors Size Id Type
/dev/xvda1          2048  96452607 96450560  46G 83 Linux
/dev/xvda2      96454654 100661247  4206594   2G  5 Extended
/dev/xvda5      96454656 100661247  4206592   2G 82 Linux swap / Solaris

And the output of "sudo parted -l /dev/xvda"

bob@bob:~% sudo parted -l /dev/xvda
[sudo] password for bob:
Model: Linux device-mapper (crypt) (dm)
Disk /dev/mapper/cryptswap1: 2154MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system     Flags
 1      0.00B  2154MB  2154MB  linux-swap(v1)


Model: Xen Virtual Block Device (xvd)
Disk /dev/xvda: 116GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  49.4GB  49.4GB  primary   ext3
 2      49.4GB  51.5GB  2154MB  extended
 5      49.4GB  51.5GB  2154MB  logical


Model: Xen Virtual Block Device (xvd)
Disk /dev/xvde: 1611MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
 1      4000kB  1611MB  1607MB  primary  ext3


Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdf: 6442MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system  Flags
 1      0.00B  6442MB  6442MB  ext3
Byte Commander
  • 110,243
Markus
  • 111

1 Answers1

1

It won't be possible to extend /dev/xvda1 directly, but since your xvda volume only appears (according to your fdisk output) to have 46G+2G used, you should be able to create another partition on the disk and mount it over the area of the root filesystem where you need more space.

For example, if you needed more space for user101's home area, you could use one of 2 approaches:

1) Create /dev/xvda3 as a partition that uses up the rest of the disk, create an EXT4 filesystem on it, then mount that over /home/user101. The biggest disadvantage of this approach is that you would have to resort to things like symbolic links or bind mounts if you needed extra disk space in more than 1 area.

or,

2) Create /dev/xvda3 as a partition using the rest of the disk, make it a LVM physical volume, put that into a volume group, then create logical volumes out of that volume, mounting them as required. This approach lets you have as many different filesystems as you need (within reason), but the initial setup is more complex. On the flip side, these filesystems can be extended as required with lvextend (and with the -r option, the filesystem is automatically increased to match the volume size).