<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: juju89</title>
    <description>The latest articles on Forem by juju89 (@juju89).</description>
    <link>https://forem.com/juju89</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3497665%2F2200873a-5d7f-4983-a82f-207d755fe082.png</url>
      <title>Forem: juju89</title>
      <link>https://forem.com/juju89</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/juju89"/>
    <language>en</language>
    <item>
      <title>How to expand diskspace on a Debian VM hosted on Hetzner Cloud</title>
      <dc:creator>juju89</dc:creator>
      <pubDate>Mon, 15 Sep 2025 16:34:24 +0000</pubDate>
      <link>https://forem.com/juju89/how-to-expand-diskspace-on-a-debian-vm-hosted-on-hetzner-cloud-4c4p</link>
      <guid>https://forem.com/juju89/how-to-expand-diskspace-on-a-debian-vm-hosted-on-hetzner-cloud-4c4p</guid>
      <description>&lt;p&gt;This tutorial will give you a step-by-step guide to increase disk space on an existing Debian VM hosted on Hetzner Cloud by adding a new volume and creating a separate mount point. This allows you to store your data independently from the root partition, freeing up space and keeping your system organized.&lt;/p&gt;

&lt;p&gt;I ran into this problem while creating my own custom Debian package repository: I underestimated the disk space needed to host the repo and download all the required files. Rather than destroying and rebuilding my existing VM from scratch, I wanted to expand the disk and create a new partition for the repository data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Add a Volume &amp;amp; Attach it to your VM&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you realize your VM’s disk isn’t enough, the first step is to add extra storage. You'll have to create a volume and attach it to your VM. Hetzner Cloud makes this pretty simple through their web console. That's the method we'll use here.&lt;/p&gt;

&lt;p&gt;In the Hetzner web console, just look at the left menu — there’s a “Volumes” section waiting for you : &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb552tczckzql6zjc3nlk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb552tczckzql6zjc3nlk.png" alt=" " width="331" height="555"&gt;&lt;/a&gt;&lt;br&gt;
Then, you click on the red button "Create Volume" on the right and you'll see this window:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkb9g6x00qee5yzf2k5jw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkb9g6x00qee5yzf2k5jw.png" alt=" " width="800" height="862"&gt;&lt;/a&gt;&lt;br&gt;
Here you'll have to choose:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The diskspace you need (GB)&lt;/li&gt;
&lt;li&gt;The name of the volume&lt;/li&gt;
&lt;li&gt;The server to which you want to attach it&lt;/li&gt;
&lt;li&gt;The mount option&lt;/li&gt;
&lt;li&gt;The filesystem if you chose 'automatic' for the mount option&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My initial VM only contained 40Go of disk space, and I needed to add a volume of 60Go to my VM. So here's what it looked like for me :&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fepsqhaim0fhdncysaklj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fepsqhaim0fhdncysaklj.png" alt=" " width="609" height="835"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Adapt it to your own needs and click "Create &amp;amp; Buy Now" : your volume is now created and attached to you VM ! &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Change the mount point &amp;amp; Make it permanent on your VM&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, log on your VM and do the following command to see the new volume attached to your VM :&lt;br&gt;
&lt;code&gt;lsblk -f&lt;/code&gt; (consider using sudo if needed)&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpw4xme9dae26n7nvpim6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpw4xme9dae26n7nvpim6.png" alt=" " width="800" height="123"&gt;&lt;/a&gt;&lt;br&gt;
As you can see, the volume I added is here, under the name "sdb". We also see that the volume has the right filesystem, which is 'ext4' (that's the usual filesystem on Debian, Ubuntu, CentOs...).&lt;br&gt;
Finally, we see that it already has a mount point : &lt;em&gt;'/mnt/HC_Volume_103410845'&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;I needed that diskspace to be available for my own custom Debian package repository under &lt;em&gt;/var/local/my-debian-repo&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;So first, I unmounted the disk with : &lt;br&gt;
&lt;code&gt;sudo umount /mnt/HC_Volume_103410845&lt;/code&gt; &lt;br&gt;
--&amp;gt; Just change the mount point path with the one you see on your VM.&lt;/p&gt;

&lt;p&gt;If you get an error at this point, it might be because your &lt;br&gt;
mount point still has processes running on it. &lt;br&gt;
You can check if there's any process accessing it with &lt;br&gt;
&lt;code&gt;sudo lsof &amp;lt;your_mount_point_path&amp;gt;&lt;/code&gt; &lt;br&gt;
With my example, I would do &lt;br&gt;
&lt;code&gt;sudo lsof /mnt/HC_Volume_103410845&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then, I created the directory for my repo with: &lt;br&gt;
&lt;code&gt;sudo mkdir -p /var/local/my-debian-repo&lt;/code&gt;&lt;br&gt;
--&amp;gt; Just change the directory path with yours.&lt;/p&gt;

&lt;p&gt;Then, mount the volume to this directory: &lt;br&gt;
&lt;code&gt;sudo mount /dev/sdb /var/local/my-debian-repo&lt;/code&gt;&lt;br&gt;
--&amp;gt; Just change &lt;em&gt;/dev/sdb&lt;/em&gt; with your volume's path and &lt;em&gt;var/local/my-debian-repo&lt;/em&gt; with your own directory path.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: If the directory already contains files, mounting the new volume will temporarily hide them. Make sure to back up any important data in /var/local/my-debian-repo before mounting, so it isn’t lost or hidden unintentionally.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Then, check it worked with &lt;code&gt;df -h&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1gggaz5ovsyxl51bl4wp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1gggaz5ovsyxl51bl4wp.png" alt=" " width="800" height="252"&gt;&lt;/a&gt;&lt;br&gt;
Here you see that it worked for me, &lt;em&gt;/var/local/my-debian-repo&lt;/em&gt; is mounted on the volume. &lt;/p&gt;

&lt;p&gt;But that is not permanent. That means if you reboot your VM, the partition /dev/sdb won’t be mounted automatically. So, to make it permanent, you have to add it to &lt;em&gt;/etc/fstab&lt;/em&gt; file.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Before editing, back up your fstab file because it’s sensitive and a mistake can prevent your system from booting:&lt;br&gt;&lt;br&gt;
&lt;code&gt;sudo cp /etc/fstab /etc/fstab.bak&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then, you can add your new partition to fstab to mount it permanently:&lt;br&gt;
&lt;code&gt;sudo echo '/dev/sdb /var/local/my-debian-repo ext4 defaults 0 2' | sudo tee -a /etc/fstab&lt;/code&gt;&lt;br&gt;
--&amp;gt; Change the volume path and mount point to match your setup.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: &lt;code&gt;-a&lt;/code&gt; appends the line instead of overwriting the file.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;If you feel more comfortable using a text editor to add the line, you can use nano or vim and insert the following line at the end of the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;your_volume_path&amp;gt; &amp;lt;your_mount_point&amp;gt; ext4 defaults 0 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, you can check it worked with &lt;code&gt;cat /etc/fstab&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5lj9h98q0hjxqk5v91g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5lj9h98q0hjxqk5v91g.png" alt=" " width="800" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bonus&lt;/strong&gt; :  if you find out later that you need to change the size of your volume, just use the web console, click on the "..." next to your volume and select 'Resize'.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note : You can expand a volume but you can't shrink one.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvqdry8nkmc6lz46bdxnu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvqdry8nkmc6lz46bdxnu.png" alt=" " width="800" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbre566q55i6qtdjcer08.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbre566q55i6qtdjcer08.png" alt=" " width="199" height="414"&gt;&lt;/a&gt;&lt;br&gt;
Resize your volume according to your needs.&lt;br&gt;
Don't forget to resize the filesystem on your VM with &lt;br&gt;
&lt;code&gt;sudo resize2fs /dev/sdb&lt;/code&gt;&lt;br&gt;
--&amp;gt; Change &lt;em&gt;/dev/sdb&lt;/em&gt; with the path to your volume.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: This only adjusts the filesystem to use the new space: the volume must already have been expanded in Hetzner’s console.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This tutorial is over, I hope it was helpful :)&lt;/p&gt;

</description>
      <category>hetznercloud</category>
      <category>debian</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
