✓ Solved

How Small Can I Shrink My Linode's Disk?

Linode Staff

How do I determine the smallest size to which I can shrink my Linode's disk?

1 Reply

✓ Best Answer

Minimum Disk Size

The following command will give you an estimate of the minimum number of blocks an ext3/4 disk can fit into:

resize2fs -P /dev/sda

To get the block size of a particular disk, you can use:

tune2fs -l /dev/sda | grep -i 'block size'

The block size will likely be 4096.

You can estimate the smallest number of MiB into which your disk's contents fit with the following formula:

         blocks * block_size
MiBs = ------------------------- + 1
            1024 * 1024

The tools used here can be found in the e2fsprogs package which are installed by default on most distributions. If you do not have them installed or available for your distribution, you can also boot into Rescue Mode and run them from there.

If you would like to try a perl one-liner to just calculate the value in MiB, here you go:

perl -le '`resize2fs -P /dev/sda 2>/dev/null`=~/system:\s+(\d+)$/s;$min=$1;`tune2fs -l /dev/sda 2>/dev/null|grep -i "block size"`=~/\s+(\d+)$/s;$bs=$1;$out=int(($min*$bs)/(1024**2))+1;print $out'

An interesting observation from my experience is that once you have shrunk a disk to the estimated minimum, it sometimes becomes possible to shrink it a little further to sizes that previously were not allowed.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct