Expand EXT4 Disk in Debian 10

Ответить
admin
Администратор
Сообщения: 198
Зарегистрирован: 05 янв 2011, 04:19

Expand EXT4 Disk in Debian 10

Сообщение admin »

Steps

Prepare the VM:
Expand the disk in your hypervisor
Take a snapshot of the VM or disk you are expanding
Repartition (fdisk - MBR disks only, for GPT see the next step)
sudo fdisk /dev/sdb
Command (m for help): p <- print the partition layout, take note of the start sector of the last partition. For me it was 2048 and I only had the one partition, so that was 1
Command (m for help): d 1 <- delete the last partition, replace 1 with the last partition number if it is not 1
Command (m for help): n <- create the new partition
Partition Number: 1 <- the number of the partition you just deleted
First sector (#-#): 2048 <- the start sector of the last partition. This is in the output of p from above
Last sector, +/-sectors or +/-size{K,M,G,T,P} (#-#, default #): <- just press enter here to use the entire disk.
Do you want to remove the signature? [Y]es/[N]o: N <- this was not in any guides I could find, since it sounded scary and a bad idea I chose No and it worked
Command (m for help): p <- verify the new partition table
Command (m for help): w <- write the new partition table
Command (m for help): q <- exit fdisk


Repartition (gdisk - GPT disks only)
sudo gdisk /dev/sdb
Command (? for help): x <- enter expert mode
Expert command (? for help): i <- display detailed information about the partition. Take note of the Partition GUID code, Partition unique GUID and First sector.
Expert command (? for help): m <- back to the regular menu
Command (? for help): b <- backup the partition table
Enter backup filename to save: <put a file path here> <- where to save the backup
Command (? for help): d 1 <- delete the partition
Command (? for help): n <- create a new partition
Partition number (1-128, default 1): <- the number of the partition you deleted, I just press enter here
First sector (34-4294967262, default = 2048) or {+-}size{KMGTP}: 2048 <- this should be set to the value of the First sector from when you displayed the detailed information. This is crucial, if it is not the same you will corrupt your disk
Last sector (2048-4294967262, default = 4294967262) or {+-}size{KMGTP}: <- just press enter here to use the entire disk
Hex code or GUID (L to show codes, Enter = 8300): <- put in the Partition GUID code from above.
Command (? for help): x
Expert command (? for help): c 1 <- change the partition guid
Enter the partition's new unique GUID ('R' to randomize): <- put in the Partition unique GUID from above
Expert command (? for help): m <- back to the regular menu
Command (? for help): w <- write the partition table
Do you want to proceed? (Y/N): y <- actually write the table
sudo partprobe <- reload the partition table


Expand the partition
sudo resize2fs /dev/sdb1
Check the available space
df -h
Remove the snapshot
Ответить