Difference between revisions of "Grow linux partitions on live system"

From Hawk Wiki
Jump to: navigation, search
Line 18: Line 18:
 
</pre>
 
</pre>
  
 +
== another method ==
 
follow
 
follow
 
https://askubuntu.com/questions/24027/how-can-i-resize-an-ext-root-partition-at-runtime
 
https://askubuntu.com/questions/24027/how-can-i-resize-an-ext-root-partition-at-runtime

Revision as of 06:46, 28 August 2021

grow xfs file system


sudo apt-get install -y gdisk cloud-guest-utils

DEVICE=sdd
MOUN=/mnt/ssd4
umount /dev/${DEVICE}1
echo 1>/sys/class/block/${DEVICE}/device/rescan

growpart /dev/${DEVICE} 1

fdisk -l

mount /dev/${DEVICE}1 ${MOUNT}

xfs_growfs ${MOUNT}

another method

follow https://askubuntu.com/questions/24027/how-can-i-resize-an-ext-root-partition-at-runtime

Step 1. The partition must first be resized. If you're using LVM, it's easy, and you presumably know how to proceed. If you're using classic partitions, it's a bit more complicated, and may require a reboot (though you never have to boot another system or live CD).

This is how I do it: Use fdisk to first delete the partition (the idea is that the data on disk will be preserved), then carefully recreate it with a larger size at the same position.

Example:

$ sudo fdisk /dev/sda

Command (m for help): p

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     9437183     4717568   83  Linux

Command (m for help): d
Selected partition 1

Command (m for help): p

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4, default 1): 1
First sector (2048-10485759, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759):
Using default value 10485759

Command (m for help): p

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    10485759     5241856   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

Step 2. As fdisk helpfully reminds you, you must reload the partition table before proceeding. The safest way is to simply reboot;

Step 3. Once the partition is resized and the partition table reloaded, it's a simple matter of running resize2fs on the file system, and you can do this even when it's mounted as the root partition.

Example:

$ sudo resize2fs /dev/sda1