Resize Storage on the fly – without rebooting your server

Im Durchschnitt wird dieses Tutorial Resize Storage on the fly – without rebooting your server mit 5 bewertet, wobei 1.0 die schlechteste und 5.0 die beste Bewertung ist. Es haben insgesamt 559 Besucher eine Bewertung abgegeben.
559 0

Resize Storage on the fly – without rebooting your server

gridscale Linux Basics

gridscale allows you to resize your storage without rebooting your server, but the new Capacity is not immediately available for your system

Firstly you have to resize the partition and the filesystem of your storage. Both are easy to do with a few simple steps.
In this example a Server with Debian 8 and a single Storage is used.


At first the initial state with 10 GB of Storage:

root@resizeme:~# parted /dev/sda print
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number  Start   End 	Size    File system  Name	Flags
 1  	1049kB  10.7GB  10.7GB  ext4         rootfs
root@resizeme:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             10M 	0   10M   0% /dev
tmpfs           400M  5.3M  395M   2% /run
/dev/sda1       9.9G  798M  8.8G   9% /
tmpfs           999M 	0  999M   0% /dev/shm
tmpfs           5.0M 	0  5.0M   0% /run/lock
tmpfs           999M 	0  999M   0% /sys/fs/cgroup

In this example the partition you need to resize is /dev/sda1. If you use another template, it can be /dev/sda2 too. You can recognize it by taking a look at the Mount-Point in the last column of the table. For comparison, here is the output of a system on which the partition /dev/sda2/ would be enlarged.

root@resizeme:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             10M 	0   10M   0% /dev
tmpfs           387M  388K  386M   1% /run
/dev/sda2       9.8G  2.3G  7.0G  25% /
tmpfs           966M 	0  966M   0% /dev/shm
tmpfs           5.0M 	0  5.0M   0% /run/lock
tmpfs           966M 	0  966M   0% /sys/fs/cgroup

Now you can resize the Storage via API or via GUI. As soon as you save the change, you should see something like this in your system logs:

root@resizeme:~# journalctl -f
[...]
Mar 18 16:18:30 resizeme kernel: sd 0:0:0:0: Capacity data has changed
Mar 18 16:18:30 resizeme kernel: sd 0:0:0:0: [sda] 41943040 512-byte logical blocks: (21.4 GB/20.0 GiB)
Mar 18 16:18:30 resizeme kernel: sda: detected capacity change from 10737418240 to 21474836480

Now change the system’s partition while the server is still running:

root@resizeme:~# parted /dev/sda
Fix/Ignore? Fix
(parted) resizepart 1
Yes/No? Yes
End?  [10.7GB]? 100%
(parted) print                                                           
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
 
Number  Start   End 	Size    File system  Name	Flags
 1  	1049kB  21.5GB  21.5GB  ext4         rootfs

The last step is to resize the filesystem:

root@resizeme:~# resize2fs /dev/sda1

With the following command you can see that the new size is now available:

root@resizeme:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             10M 	0   10M   0% /dev
tmpfs           400M  5.3M  395M   2% /run
/dev/sda1        20G  798M   19G   5% /
tmpfs           999M 	0  999M   0% /dev/shm
tmpfs           5.0M 	0  5.0M   0% /run/lock
tmpfs           999M 	0  999M   0% /sys/fs/cgroup

gridscale allows you to resize your storage without rebooting your server, but the new Capacity is not immediately available for your system Firstly you have to resize the partition and the filesystem of your storage. Both are easy to do with a few simple steps. In this example a Server with Debian 8 and a […]

Schade, dass dir der Artikel nicht gefallen hat.
Was sollten wir deiner Meinung nach besser machen?

Thank you for your feedback!
We will get back to you as soon as the article is finished.

Übrigens: kennst du schon unser Tutorial zum Thema Create SSH-Keys for Ubuntu 16.04?

×

Developer?

Get the latest gridscale developer tutorials here.
And don’t worry - we won’t spam you