How to resizing the Linux Root Partition

In this example i use the Ubuntu Linux on Hyper-V VM Gen2 and default LVM partitioning.


Check your partitioning with lsblk.


Now check the mount point with df -h.


Resize disk on Hyper-V and if you cannot view the total size you need reboot or rescan disk.


# echo 1 > /sys/block/sda/device/rescan


# parted

GNU Parted 3.1

Using /dev/sda

Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) p

Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating

system believes the disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?

Fix/Ignore/Cancel? Fix

Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space

(an extra 20971520 blocks) or continue with the current setting?

Fix/Ignore? Fix

Model: Msft Virtual Disk (scsi)

Disk /dev/sda: 31.5GB

Sector size (logical/physical): 512B/4096B

Partition Table: gpt

Disk Flags:

Number  Start   End     Size    File system  Name                  Flags

 1      1049kB  211MB   210MB   fat16        EFI System Partition  boot

 2      211MB   1285MB  1074MB  xfs

 3      1285MB  10.7GB  9453MB                                     lvm

(parted) resizepart

Partition number? 3

End?  [20.5GB]? 31.5GB

(parted) p

Model: Msft Virtual Disk (scsi)

Disk /dev/sda: 31.5GB

Sector size (logical/physical): 512B/4096B

Partition Table: gpt

Disk Flags:

Number  Start   End     Size    File system  Name                  Flags

 1      1049kB  211MB   210MB   fat16        EFI System Partition  boot

 2      211MB   1285MB  1074MB  xfs

 3      1285MB  31.5GB  30.2GB                                     lvm

(parted) quit

 

# pvresize /dev/sda3

  Physical volume "/dev/sda3" changed

  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

# lvextend -l +100%FREE -r /dev/mapper/centos-root


Check new size with df -h

That's it

Comentários

Postagens mais visitadas deste blog

Cisco router password recovery