<p>What I do (and that's not exactly answering your question) is as follow:</p>

<ol>
<li>Create an EBS volume and attach it to the instance <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumes.html" rel="nofollow noreferrer">doc is here</a></li>
<li>Rescan the scsi buses <code>echo '- - -' &gt; /sys/bus/scsi/devices/host1/scsi_host/host1/scan</code> (you may have to adapt the host number)</li>
<li>Create a physical volume  with <code>pvcreate</code> on the new disk found (<code>fdisk -l</code> to list all disk)</li>
<li>Create a volume group and then logical volume on it (<code>vgcreate</code> and <code>lvcreate</code>)</li>
<li>Format the logical volume with your desired filesystem</li>
<li><code>tar</code> the target mountpoint to restore it.</li>
<li>Mount this volume where you need new space.</li>
<li>Restore the tar into this newly mounted space.</li>
</ol>

<p>Steps 6 and 8 are optional if you use a new space before installing something. If you want to replace an existing directory you obvisouly have to avoid something writing there between the end of the archive and the restoration.</p>

<p>You can repeat the steps 4 to 8 for different mountpoints, this allow to extend the space needed and then to resize those volumes on line without interruption.</p>

CC BY-SA 3.0
2017-03-01T09:12:34.503Z
2017-03-01T09:12:34.503Z
Tensibai
<h1>ZFS Zero Downtime filesystem storage scaling on AWS (or elsewhere)</h1>

<h2>upsize</h2>

<ol>
<li><p>Install ZFS on EC2.</p>

<p><a href="http://serverascode.com/2016/09/05/aws-zfs-user-data.html" rel="nofollow noreferrer">http://serverascode.com/2016/09/05/aws-zfs-user-data.html</a></p></li>
<li>Make a zpool for your bulk data using an EBS volume.</li>
<li>Add another EBS to get more block storage. (or set the pool autoexpand=true and just grow your EBS)</li>
<li>Add the new EBS to your zpool to make the space available. (unless you used autoexpand and increased the EBS size)</li>
</ol>

<h2>Downsize</h2>

<ol>
<li>Make a new zpool on new EBS big enough to hold the shrunken data. (doesn't need to be mounted yet, or even on the same EC2)</li>
<li>snapshot the old too-big zpool</li>
<li>zfs-send the snapshot to the new zpool</li>
<li>promote the received snapshot on the new pool and mount it</li>
<li>destroy the old pool</li>
<li>destroy the old pool's EBS</li>
</ol>

CC BY-SA 3.0
2017-10-24T03:46:23.490Z
2017-10-24T03:46:23.490Z
Jeremy
<p>After resizing the EBS volume, here is what I just executed when I needed to expand a ZFS pool:</p>

<pre><code>parted -l # Get the list of partitions 
parted /dev/xvdf rm 9 # Remove the buffer partition
parted /dev/xvdf resizepart 1 100% # Resize the partition
zpool online -e &lt;zfs partition name&gt; /dev/xvdf # Expand the zpool and the filesystem it holds
</code></pre>

CC BY-SA 3.0
2018-04-23T14:41:24.443Z
2018-04-23T16:27:04.913Z
2018-04-23T16:27:04.913Z
Michael Pereira
<p>Amazon AWS just released (on 13th February 2017) a new feature that allows to change a size of an EBS volume.</p>

<p><sup>source: <a href="https://aws.amazon.com/blogs/aws/amazon-ebs-update-new-elastic-volumes-change-everything/" rel="noreferrer">https://aws.amazon.com/blogs/aws/amazon-ebs-update-new-elastic-volumes-change-everything/</a></sup></p>

<p>This allows to increase the size of an EBS volume on an existing instance, while it is running.</p>

<p>It is important to note that changing the volume size, does not change the size of the filesystem on the volume (for most filesystems). Additional steps might be required (depending on filesystem) in the operating system itself. For example a <code>resizefs</code> on <code>ext4</code> filesystem used by most Linux OS today.</p>

<p>Full documentation from AWS describing the process can be found at <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-expand-volume.html" rel="noreferrer">http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-expand-volume.html</a></p>

<p>In some cases the block device has mapped partitions, and only then one (or more) of the partitions include a filesystem. In this case the partition will need to be resized first, and only then the filesystem. This process is <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/storage_expand_partition.html" rel="noreferrer">described in the documentation</a> as well.</p>

<p>The new "online" resize feature described in the blog only applies to current generation instances, and there are some other <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/considerations.html" rel="noreferrer">considerations and limitations</a> that need to be checked before attempting a volume resize.</p>

CC BY-SA 3.0
2017-07-21T12:35:16.113Z
The question mentioned without downtime. However to resize a root volume it seems you would need to take the instance down to perform this step?
Chris Stryczynski
CC BY-SA 3.0
2018-02-11T16:17:01.390Z
With new generations of instances, the root volume can be modified without restarting the instance. This is explained in the documentation https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/stop-start.html
Evgeny Zislis
CC BY-SA 3.0
2017-03-01T09:03:38.867Z
Before resizing the filesystem you'll have to resize the underlying partition also, which is really blocking on physical partitions for a hot resize.
Tensibai
CC BY-SA 3.0
2017-03-01T09:05:24.417Z
@Tensibai sorry I don't understand what "blocking on physical partitions for a hot resize" means. Do you mean that modifying the volume size using AWS APIs will block writes/reads to the volume?
Evgeny Zislis
CC BY-SA 3.0
2017-03-01T09:08:11.040Z
No, I mean that the disk will be larger, but the partition on it will remain the same, you have to use `fdisk` to resize it, concerning the root partition, you usually can't write the disk partition table while it is mounted, and you can't unmount it. You'll have to reboot at one point :)
Tensibai
CC BY-SA 3.0
2017-03-01T09:09:18.027Z
Right, if you use multiple partitions before adding the filesystem layer - then partitions will need to be resized first. Thanks, I'll try and add that into the answer quoting some guide on how its done.
Evgeny Zislis
CC BY-SA 3.0
2017-03-01T09:01:51.573Z
2017-03-01T09:11:16.753Z
2017-03-01T09:11:16.753Z
Evgeny Zislis
<p>I got a running instance of a EC 2 server setup with Ubunto. What's the best way to increase the disk size without any downtime and minimal risk?</p>

<p>Reading through the guides, one way would be to create a new disk, migrate data, turn off the instance swap disk and turn it back on. This approach sounds a bit risk will require some downtime. I wonder if there is a better approach?</p>

<amazon-ec2><amazon-ebs>
How to increase the size of a disk on a running instance on Amazon EC2
googletorp
# How to increase the size of a disk on a running instance on Amazon EC2

(Asked by: username_0 on 2017-03-01)

I got a running instance of a EC 2 server setup with Ubunto. What's the best way to increase the disk size without any downtime and minimal risk?

Reading through the guides, one way would be to create a new disk, migrate data, turn off the instance swap disk and turn it back on. This approach sounds a bit risk will require some downtime. I wonder if there is a better approach?

**Tags:** amazon-ec2, amazon-ebs


---

## 4 answers

### Answer by username_4 on 2017-03-01. Score: 14 | Accepted answer

Amazon AWS just released (on 13th February 2017) a new feature that allows to change a size of an EBS volume.

source: <https://aws.amazon.com/blogs/aws/amazon-ebs-update-new-elastic-volumes-change-everything/>

This allows to increase the size of an EBS volume on an existing instance, while it is running.

It is important to note that changing the volume size, does not change the size of the filesystem on the volume (for most filesystems). Additional steps might be required (depending on filesystem) in the operating system itself. For example a `resizefs` on `ext4` filesystem used by most Linux OS today.

Full documentation from AWS describing the process can be found at <http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-expand-volume.html>

In some cases the block device has mapped partitions, and only then one (or more) of the partitions include a filesystem. In this case the partition will need to be resized first, and only then the filesystem. This process is [described in the documentation](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/storage_expand_partition.html) as well.

The new "online" resize feature described in the blog only applies to current generation instances, and there are some other [considerations and limitations](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/considerations.html) that need to be checked before attempting a volume resize.

> **Comments:**
> **username_1**: Before resizing the filesystem you'll have to resize the underlying partition also, which is really blocking on physical partitions for a hot resize.  
> **username_4**: @username_1 sorry I don't understand what "blocking on physical partitions for a hot resize" means. Do you mean that modifying the volume size using AWS APIs will block writes/reads to the volume?  
> **username_1**: No, I mean that the disk will be larger, but the partition on it will remain the same, you have to use `fdisk` to resize it, concerning the root partition, you usually can't write the disk partition table while it is mounted, and you can't unmount it. You'll have to reboot at one point :)  
> **username_4**: Right, if you use multiple partitions before adding the filesystem layer - then partitions will need to be resized first. Thanks, I'll try and add that into the answer quoting some guide on how its done.  
> **username_5**: The question mentioned without downtime. However to resize a root volume it seems you would need to take the instance down to perform this step?  
> **username_4**: With new generations of instances, the root volume can be modified without restarting the instance. This is explained in the documentation https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/stop-start.html  

---

### Answer by username_1 on 2017-03-01. Score: 2

What I do (and that's not exactly answering your question) is as follow:

1. Create an EBS volume and attach it to the instance [doc is here](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumes.html)
2. Rescan the scsi buses `echo '- - -' > /sys/bus/scsi/devices/host1/scsi_host/host1/scan` (you may have to adapt the host number)
3. Create a physical volume with `pvcreate` on the new disk found (`fdisk -l` to list all disk)
4. Create a volume group and then logical volume on it (`vgcreate` and `lvcreate`)
5. Format the logical volume with your desired filesystem
6. `tar` the target mountpoint to restore it.
7. Mount this volume where you need new space.
8. Restore the tar into this newly mounted space.

Steps 6 and 8 are optional if you use a new space before installing something. If you want to replace an existing directory you obvisouly have to avoid something writing there between the end of the archive and the restoration.

You can repeat the steps 4 to 8 for different mountpoints, this allow to extend the space needed and then to resize those volumes on line without interruption.


---

### Answer by username_2 on 2017-10-24. Score: 1

# ZFS Zero Downtime filesystem storage scaling on AWS (or elsewhere)

## upsize

1. Install ZFS on EC2.

   <http://serverascode.com/2016/09/05/aws-zfs-user-data.html>
2. Make a zpool for your bulk data using an EBS volume.
3. Add another EBS to get more block storage. (or set the pool autoexpand=true and just grow your EBS)
4. Add the new EBS to your zpool to make the space available. (unless you used autoexpand and increased the EBS size)

## Downsize

1. Make a new zpool on new EBS big enough to hold the shrunken data. (doesn't need to be mounted yet, or even on the same EC2)
2. snapshot the old too-big zpool
3. zfs-send the snapshot to the new zpool
4. promote the received snapshot on the new pool and mount it
5. destroy the old pool
6. destroy the old pool's EBS


---

### Answer by username_3 on 2018-04-23. Score: 0

After resizing the EBS volume, here is what I just executed when I needed to expand a ZFS pool:
parted -l # Get the list of partitions 
parted /dev/xvdf rm 9 # Remove the buffer partition
parted /dev/xvdf resizepart 1 100% # Resize the partition
zpool online -e  /dev/xvdf # Expand the zpool and the filesystem it holds


---

