# How to resize the root partition after disk upgrade

**URL:** https://forum.yunohost.org/t/how-to-resize-the-root-partition-after-disk-upgrade/17131
**Category:** Advanced use case
**Tags:** english
**Created:** [September 11, 2021, 12:02pm UTC](https://forum.yunohost.org/t/how-to-resize-the-root-partition-after-disk-upgrade/17131 "2021-09-11T12:02:53Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![gittbuh](https://forum.yunohost.org/user_avatar/forum.yunohost.org/gittbuh/32/4950_2.png) [@gittbuh](https://forum.yunohost.org/u/gittbuh)
#### Post date: [September 11, 2021, 12:02pm UTC](https://forum.yunohost.org/t/how-to-resize-the-root-partition-after-disk-upgrade/17131/1 "2021-09-11T12:02:54Z")

</div>

### My YunoHost server

**Hardware:** VM running inside Proxmox  
**YunoHost version:** 4.2.8.3  
**I have access to my server :** Through SSH | through the webadmin |  
**Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?** : no

### Description of my issue

I would to like to resize the root partition after a disk upgrade (increased size from 30 to 40 GiB). I have ran out of space and cannot install new apps, do backups or even do updates.

I have found a very similar post in the forum, but the solution does not work for me: https://forum.yunohost.org/t/added-extra-diskspace-is-not-used/12537/9

```auto
ROOT_DEV=$(findmnt / -o source -n)
resize2fs $ROOT_DEV

```

Here the info from the command line:

root@yuno:/home/admin# fdisk -l  
Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 sectors  
Disk model: QEMU HARDDISK  
Units: sectors of 1 \* 512 = 512 bytes  
Sector size (logical/physical): 512 bytes / 512 bytes  
I/O size (minimum/optimal): 512 bytes / 512 bytes  
Disklabel type: dos  
Disk identifier: 0x4e9597bd

Device Boot Start End Sectors Size Id Type  
/dev/sda1 \* 2048 62916607 62914560 30G 83 Linux  
/dev/sda2 62918654 67106815 4188162 2G 5 Extended  
/dev/sda5 62918656 67106815 4188160 2G 82 Linux swap / Solaris  
root@yuno:/home/admin# df -h  
Filesystem Size Used Avail Use% Mounted on  
udev 2.9G 0 2.9G 0% /dev  
tmpfs 597M 16M 581M 3% /run  
/dev/sda1 30G 24G 4.2G 86% /  
tmpfs 3.0G 36K 3.0G 1% /dev/shm  
tmpfs 5.0M 0 5.0M 0% /run/lock  
tmpfs 3.0G 0 3.0G 0% /sys/fs/cgroup  
tmpfs 597M 0 597M 0% /run/user/1007

---

<div class="post-metadata">

### Author: ![ljf](https://forum.yunohost.org/user_avatar/forum.yunohost.org/ljf/32/58_2.png) [@ljf](https://forum.yunohost.org/u/ljf)
#### Post date: [September 11, 2021, 1:03pm UTC](https://forum.yunohost.org/t/how-to-resize-the-root-partition-after-disk-upgrade/17131/2 "2021-09-11T13:03:33Z")

</div>

## Identify the root partition

```auto
findmnt / -o source -n

```

You should get something like /dev/sda1 or /dev/vda2. If you receive /dev/mapper/something, you probably use lvm, and this tutorial won’t be enough.

## Display the partition table with some information

```auto
root@vps:~# parted /dev/vda
GNU Parted 3.2
Using /dev/vda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                         
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 6442MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
 1 1049kB 5369MB 5368MB primary ext4 boot

```

## Resize the partition

```auto
(parted) resizepart
Partition number? 1 << the number of the partition you want resize
Warning: Partition /dev/vda1 is being used. Are you sure you want to continue?
Yes/No? Yes
End? [5369MB]? 100% << 100% means we want use all the space available

```

## Check the change has been done correctly

```auto
(parted) print                      
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 6442MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number Start End Size Type File system Flags
 1 1049kB 6442MB 6441MB primary ext4 boot

(parted) q                
Information: You may need to update /etc/fstab.

```

## Resize the file system

```auto
root@vps:~# resize2fs /dev/vda1                        
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/vda1 is now 1572608 (4k) blocks long.

```

---

<div class="post-metadata">

### Author: ![gittbuh](https://forum.yunohost.org/user_avatar/forum.yunohost.org/gittbuh/32/4950_2.png) [@gittbuh](https://forum.yunohost.org/u/gittbuh)
#### Post date: [September 11, 2021, 1:49pm UTC](https://forum.yunohost.org/t/how-to-resize-the-root-partition-after-disk-upgrade/17131/3 "2021-09-11T13:49:52Z")

</div>

Thank you for the quick reply and this very detailed solution. I got stuck at the “resize” part of the instructions, see below the details, I do not know how to proceed… it seems there is an overlap… parted is not seeing the extra disk space over which extend the root partition or the extended partition/swap is getting on the way?

root@yuno:/home/admin# findmnt / -o source -n  
/dev/sda1  
root@yuno:/home/admin# parted /dev/sda  
GNU Parted 3.2  
Using /dev/sda  
Welcome to GNU Parted! Type ‘help’ to view a list of commands.  
(parted) print  
Model: QEMU QEMU HARDDISK (scsi)  
Disk /dev/sda: 64.4GB  
Sector size (logical/physical): 512B/512B  
Partition Table: msdos  
Disk Flags:

Number Start End Size Type File system Flags  
1 1049kB 32.2GB 32.2GB primary ext4 boot  
2 32.2GB 34.4GB 2144MB extended  
5 32.2GB 34.4GB 2144MB logical linux-swap(v1)

(parted) resizepart  
Partition number? 1  
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?  
Yes/No? yes  
End? [32.2GB]? 100%  
Error: Can’t have overlapping partitions.  
(parted)

---

<div class="post-metadata">

### Author: ![ljf](https://forum.yunohost.org/user_avatar/forum.yunohost.org/ljf/32/58_2.png) [@ljf](https://forum.yunohost.org/u/ljf)
#### Post date: [September 11, 2021, 2:01pm UTC](https://forum.yunohost.org/t/how-to-resize-the-root-partition-after-disk-upgrade/17131/4 "2021-09-11T14:01:15Z")

</div>

It’s because you have the swap partition in the middle of your disk (between 32.2GB and 34.4GB).

So you probably should turn off the swap with `swapoff --all` and delete this extended partition before.

---

<div class="post-metadata">

### Author: ![gittbuh](https://forum.yunohost.org/user_avatar/forum.yunohost.org/gittbuh/32/4950_2.png) [@gittbuh](https://forum.yunohost.org/u/gittbuh)
#### Post date: [September 11, 2021, 2:05pm UTC](https://forum.yunohost.org/t/how-to-resize-the-root-partition-after-disk-upgrade/17131/5 "2021-09-11T14:05:50Z")

</div>

I see, that is what I thought… is it not a bad idea to delete the swap partition? do I need it? can it be re-built later on? and how do I delete it anyway? with parted?

---

<div class="post-metadata">

### Author: ![ljf](https://forum.yunohost.org/user_avatar/forum.yunohost.org/ljf/32/58_2.png) [@ljf](https://forum.yunohost.org/u/ljf)
#### Post date: [September 11, 2021, 3:30pm UTC](https://forum.yunohost.org/t/how-to-resize-the-root-partition-after-disk-upgrade/17131/6 "2021-09-11T15:30:30Z")

</div>

> [@gittbuh](#):
>
> is it not a bad idea to delete the swap partition? do I need it?

The swap partition could be replace by a swapfile if you need it. [https://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/](https://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/)

I guess it’s possible to delete your swap patition with parted (see the help command when you are in parted).

---

<div class="post-metadata">

### Author: ![gittbuh](https://forum.yunohost.org/user_avatar/forum.yunohost.org/gittbuh/32/4950_2.png) [@gittbuh](https://forum.yunohost.org/u/gittbuh)
#### Post date: [September 11, 2021, 5:38pm UTC](https://forum.yunohost.org/t/how-to-resize-the-root-partition-after-disk-upgrade/17131/7 "2021-09-11T17:38:27Z")

</div>

thank you, i deleted the swap partition and your instructions solved my problem. cheers!

---

<div class="post-metadata">

### Author: ![system](https://forum.yunohost.org/uploads/default/original/2X/f/f59fe8e3ee6b100b4f574d30d6e30479c68b89f0.png) [@system](https://forum.yunohost.org/u/system)
#### Post date: [October 11, 2021, 5:38pm UTC](https://forum.yunohost.org/t/how-to-resize-the-root-partition-after-disk-upgrade/17131/8 "2021-10-11T17:38:48Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
