There was a problem loading the comments.

Enlarge a disk in Debian

Support Portal  »  Knowledgebase  »  Viewing Article

  Print
--- Important! Before you start, make a backup! ---

If there is the file partme in the root directory of your server, you can use it to make the disk larger, but only if the format is standard as below:
(parted) unit s
(parted) print
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 22.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number  Start    End        Size       Type      File system  Flags
 1      2048s    499711s    497664s    primary   ext2         boot
 2      501758s  42991615s  42489858s  extended
 5      501760s  42991615s  42489856s  logical                lvm
Using parted without rebooting:
  1. ./partme pertitiond> It tells you to reboot, but you don't have to.
  2. ./partme resizefs
  3. partprobe
    If you now give lsblk as a command you will see that the 5th partition is larger.


Enlarge manually:

First log in to your TCC console and expand the disk at the VPS.
Then log in as root on the VPS.
The steps below are the most common if you have done a standard installation.
Every system is different, so it is not a "turnkey" solution. You do this at your own risk!

Getting information

Give the command lsblk
The result may resemble the following. The data we need from this is the name of the volume group on sda5. In this case debian - vg-root

NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0 20.5G  0 disk
├─sda1                  8:1    0  243M  0 part /boot
└─sda5                  8:5    0 20.3G  0 part
  ├─debian--vg-root   254:0    0 19.3G  0 lvm  /
  └─debian--vg-swap_1 254:1    0  460M  0 lvm  [SWAP]
We see that there is 1 disk in it with 2 partitions namely "sda1" and sda5 "We can only make the last partition bigger.
To find out which one, give the command parted/dev/sda
The result is similar to the one below.
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
Enter the command unit s followed by print. Then you will see something like the below. There see the following:
Number 1 is the first partition and cannot be made bigger.
Number 2 is not the last, but we have to make it bigger because it contains number 5. That partition starts at 501758 in this case.
Number 5 is the last partition. So we can make it bigger. That partition starts at 501760 in this case.
(parted) unit s
(parted) print
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 22.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number  Start    End        Size       Type      File system  Flags
 1      2048s    499711s    497664s    primary   ext2         boot
 2      501758s  42991615s  42489858s  extended
 5      501760s  42991615s  42489856s  logical                lvm
Actually enlarge
You must perform the following steps without rebooting in between!
We are going to delete the logical partition (5) first
parted -s /dev/sda rm 5
Then delete the extended partition (2) containing the logical
parted -s /dev/sda rm 2
Then we will create the extended partitiin (2) again and give it the maximum size. That partition started at 501758
parted -s /dev/sda mkpart extended 501758s 100%
Then we will create the logical partition (5) again. That started at 501760.
parted -s /dev/sda mkpart logical 501760s 100%
The partition's settings should return to the way they were.
LVM was on for the logical partition. So we turn it back on.
parted -s /dev/sda set 5 lvm on
Flags did not say lba was on. We also need to disable that for both partitions.
parted -s /dev/sda set 2 lba off
parted -s /dev/sda set 5 lba off
After this you can reboot to read the new partition tables again or give the command partprobe.

In the case of LVM

When using LVM you still need to do the following for sda5 as used in this example.
Give the following command:

pvresize /dev/sda5
followed by:
lvextend -l +100%FREE /dev/mapper/debian--vg-root

In the case of EXT2, 3 or 4

If you use EXT2, EXT3 or EXT4 then you have to do the following replacing debian - vg-root for the name you got earlier
resize2fs /dev/mapper/debian--vg-root

Share via
Did you find this article useful?  

Related Articles

© Tuxis B.V.