Resizing (enlarging) of a partition

Hi community!

I have very little experience in Linux, but unfortunately, use a system as a virtual appliance which has SLES 11 SP3 as an underlying core. The virtual HD of the appliance under SuSE was ~250GB at first and was partioned (I guess) as the appliance’s default requirements. The 250 GB ran out these days, so I was searching for a way to enlarge the disk. First, of course, I did resize the virtual hard drive to ~400GB, but now the task remains to enlarge the operating partition so that it will use the new available space. GUI is not present on the system (just command line and TUI - YaST2).

fdisk -l command output:

YaST 2 output:

So, I guess /dev/sda is the “hard-disk” while /dev/sda1 and /dev/sda2 are the partitions? Can you please help enlarge /dev/sda2 to use all available disk space of /dev/sda? Thank you in advance for your time and help!

Your best bet is probably to use Partitioner; it appears that the fdisk
output shows the resized disk, so if you use Partitioner (from Yast) it
should let you expand the partition, and the filesystem, so use that new
space, hopefully all “online” depending on the filesystem you are using
(apparently ‘ext3’, but it may still work… not totally sure with that one).

/sbin/yast disk

In the 'System V’ew (left-hand side) of the partitioner expand ‘Hard Disk’
(space bar will expand things) and then ‘sda’ and then choose ‘sda2’. Tab
over until you get to ‘Resize’ at the bottom of the Partition view on the
right-hand side and see if you can expand to use the full size there.

If that does not work, then you will probably need to boot from external
media and do it that way, but it should be possible offline if not online.

Sine you mention you have little experience with Linux (welcome, by the
way) you may, in the future, want to choose other filesystems for things
that will hold large amounts of data, assuming you are given the choice as
you probably were not with a software appliance. Something like XFS
behaves better in many cases, both in terms of runtime performance as well
as mount/startup performance, particularly when compared with ext3 when
you have larger filesystems. 'ext3 runs a filesystem check every so-many
days or so-many mounts which can cause a simple rebobt to change from a
thirty-second operation to a much longer one unexpectedly.

A common scenario with something like an appliance is to have a lot of
data somewhere under /var for an application in the appliance’s datastore,
or perhaps under /srv for a website. In either case, what may be better
than growing your disk is instead adding a bit more space either by
growing the disk or adding a new disk, creating a new partition (perhaps
for LVM rather than the current partitions you are using) so that you can
mount these data separately to /var/whatever or /srv/whatever and keep
them separate from the rest of the system. This can also be really nice,
in particular if you use a separate virtual “disk”, when upgrading the
base appliance bits. The OS changes, but your data may not, and now your
data are all stored separately which can be nice for the virtualization
software to manage/backup/etc.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below.

If you want to send me a private message, please let me know in the
forum as I do not use the web interface often.

Hi ab, big thanks for the help. I tried Partitioner (YaST) - it has the option to resize to Maximum Size, but you can not perform the operation on a mounted partition. I did unmount it, but then it hit me with “Partition cannot be resized because the filesystem seems to be inconsistent”.

You unmounted the root filesystem, meaning the filesystem from which you
were running the system? Maybe you booted from external media first…
maybe?

Another option may be to use parted:
https://www.gnu.org/software/parted/manual/html_chapter/parted_2.html

Maybe this would work, which I believe resize the second partition to
start 2000 MB from the start of the disk and now end 400000 (400 GB) from
the start of the disk, meaning take the rest of the disk:

parted resize 2 2000 400000

Hopefully it is understood that, before doing anything with the disk (or
anything at all as root) you should have a good backup, maybe of the disk
itself from the virtualization software.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below.

If you want to send me a private message, please let me know in the
forum as I do not use the web interface often.