LINUX.ORG.RU

История изменений

Исправление Vsevolod-linuxoid, (текущая версия) :

Те утилиты, что я предложил использовать вслед за примером, лежат в пакетах parted и gdisk, их придется поставить.

Ситуация до:

root@debian12efi:~# lsblk -f /dev/sda
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                           
├─sda1 vfat   FAT32       9207-04B1                                72M     7% /boot/efi
├─sda2 swap   1           02cf42ed-5fe7-4911-85a5-6b4527513f18                [SWAP]
└─sda3 ext4   1.0         f4c94d93-513a-48d4-843c-024a3c861dc6   26.2G     6% /
root@debian12efi:~# fdisk -l /dev/sda
Disk /dev/sda: 32 GiB, 34359738368 bytes, 67108864 sectors
Disk model: VBOX 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: gpt
Disk identifier: 98EEA0A5-FF7F-4B00-8D79-15103DA710A8

Device       Start      End  Sectors  Size Type
/dev/sda1     2048   163839   161792   79M EFI System
/dev/sda2   163840  4069375  3905536  1.9G Linux swap
/dev/sda3  4069376 67106815 63037440 30.1G Linux filesystem

После увеличения диска и загрузки:

root@debian12efi:~# lsblk -f /dev/sda
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                           
├─sda1 vfat   FAT32       9207-04B1                                72M     7% /boot/efi
├─sda2 swap   1           02cf42ed-5fe7-4911-85a5-6b4527513f18                [SWAP]
└─sda3 ext4   1.0         f4c94d93-513a-48d4-843c-024a3c861dc6   26.2G     6% /
root@debian12efi:~# fdisk -l /dev/sda
GPT PMBR size mismatch (67108863 != 134217727) will be corrected by write.
The backup GPT table is not on the end of the device.
Disk /dev/sda: 64 GiB, 68719476736 bytes, 134217728 sectors
Disk model: VBOX 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: gpt
Disk identifier: 98EEA0A5-FF7F-4B00-8D79-15103DA710A8

Device       Start      End  Sectors  Size Type
/dev/sda1     2048   163839   161792   79M EFI System
/dev/sda2   163840  4069375  3905536  1.9G Linux swap
/dev/sda3  4069376 67106815 63037440 30.1G Linux filesystem

Применяем измения и проверяем результат:

root@debian12efi:~# sgdisk -e /dev/sda
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
root@debian12efi:~# partprobe /dev/sda
root@debian12efi:~# parted /dev/sda
GNU Parted 3.5
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help                                                             
  align-check TYPE N                       check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all]            display the partition table, or available devices, or free space, or all found partitions
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  resizepart NUMBER END                    resize partition NUMBER
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 68.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  83.9MB  82.8MB  fat32                 boot, esp
 2      83.9MB  2084MB  2000MB  linux-swap(v1)        swap
 3      2084MB  34.4GB  32.3GB  ext4

(parted) resizepart 3 100%
Warning: Partition /dev/sda3 is being used. Are you sure you want to continue?
Yes/No? Yes                                                               
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 68.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  83.9MB  82.8MB  fat32                 boot, esp
 2      83.9MB  2084MB  2000MB  linux-swap(v1)        swap
 3      2084MB  68.7GB  66.6GB  ext4

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

root@debian12efi:~# resize2fs /dev/sda3
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/sda3 is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 8
The filesystem on /dev/sda3 is now 16268539 (4k) blocks long.

root@debian12efi:~# lsblk -f /dev/sda
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                           
├─sda1 vfat   FAT32       9207-04B1                                72M     7% /boot/efi
├─sda2 swap   1           02cf42ed-5fe7-4911-85a5-6b4527513f18                [SWAP]
└─sda3 ext4   1.0         f4c94d93-513a-48d4-843c-024a3c861dc6   56.5G     3% /
root@debian12efi:~# fdisk -l /dev/sda
Disk /dev/sda: 64 GiB, 68719476736 bytes, 134217728 sectors
Disk model: VBOX 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: gpt
Disk identifier: 98EEA0A5-FF7F-4B00-8D79-15103DA710A8

Device       Start       End   Sectors  Size Type
/dev/sda1     2048    163839    161792   79M EFI System
/dev/sda2   163840   4069375   3905536  1.9G Linux swap
/dev/sda3  4069376 134217694 130148319 62.1G Linux filesystem

Я в примере расширял раздел через parted, мне так привычнее. Контрольная перезагрузка прошла нормально.

Исходная версия Vsevolod-linuxoid, :

Те утилиты, что я предложил использовать вслед за примером, лежат в пакетах parted и gdisk, их придется поставить.

Ситуация до:

root@debian12efi:~# lsblk -f /dev/sda
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                           
├─sda1 vfat   FAT32       9207-04B1                                72M     7% /boot/efi
├─sda2 swap   1           02cf42ed-5fe7-4911-85a5-6b4527513f18                [SWAP]
└─sda3 ext4   1.0         f4c94d93-513a-48d4-843c-024a3c861dc6   26.2G     6% /
root@debian12efi:~# fdisk -l /dev/sda
Disk /dev/sda: 32 GiB, 34359738368 bytes, 67108864 sectors
Disk model: VBOX 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: gpt
Disk identifier: 98EEA0A5-FF7F-4B00-8D79-15103DA710A8

Device       Start      End  Sectors  Size Type
/dev/sda1     2048   163839   161792   79M EFI System
/dev/sda2   163840  4069375  3905536  1.9G Linux swap
/dev/sda3  4069376 67106815 63037440 30.1G Linux filesystem

После увеличения диска и загрузки:

root@debian12efi:~# lsblk -f /dev/sda
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                           
├─sda1 vfat   FAT32       9207-04B1                                72M     7% /boot/efi
├─sda2 swap   1           02cf42ed-5fe7-4911-85a5-6b4527513f18                [SWAP]
└─sda3 ext4   1.0         f4c94d93-513a-48d4-843c-024a3c861dc6   26.2G     6% /
root@debian12efi:~# fdisk -l /dev/sda
GPT PMBR size mismatch (67108863 != 134217727) will be corrected by write.
The backup GPT table is not on the end of the device.
Disk /dev/sda: 64 GiB, 68719476736 bytes, 134217728 sectors
Disk model: VBOX 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: gpt
Disk identifier: 98EEA0A5-FF7F-4B00-8D79-15103DA710A8

Device       Start      End  Sectors  Size Type
/dev/sda1     2048   163839   161792   79M EFI System
/dev/sda2   163840  4069375  3905536  1.9G Linux swap
/dev/sda3  4069376 67106815 63037440 30.1G Linux filesystem

Применяем измения и проверяем результат:

root@debian12efi:~# sgdisk -e /dev/sda
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
root@debian12efi:~# partprobe /dev/sda
root@debian12efi:~# parted /dev/sda
GNU Parted 3.5
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help                                                             
  align-check TYPE N                       check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all]            display the partition table, or available devices, or free space, or all found partitions
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  resizepart NUMBER END                    resize partition NUMBER
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 68.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  83.9MB  82.8MB  fat32                 boot, esp
 2      83.9MB  2084MB  2000MB  linux-swap(v1)        swap
 3      2084MB  34.4GB  32.3GB  ext4

(parted) resizepart 3 100%
Warning: Partition /dev/sda3 is being used. Are you sure you want to continue?
Yes/No? Yes                                                               
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 68.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  83.9MB  82.8MB  fat32                 boot, esp
 2      83.9MB  2084MB  2000MB  linux-swap(v1)        swap
 3      2084MB  68.7GB  66.6GB  ext4

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

root@debian12efi:~# resize2fs /dev/sda3
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/sda3 is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 8
The filesystem on /dev/sda3 is now 16268539 (4k) blocks long.

root@debian12efi:~# lsblk -f /dev/sda
NAME   FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                           
├─sda1 vfat   FAT32       9207-04B1                                72M     7% /boot/efi
├─sda2 swap   1           02cf42ed-5fe7-4911-85a5-6b4527513f18                [SWAP]
└─sda3 ext4   1.0         f4c94d93-513a-48d4-843c-024a3c861dc6   56.5G     3% /
root@debian12efi:~# fdisk -l /dev/sda
Disk /dev/sda: 64 GiB, 68719476736 bytes, 134217728 sectors
Disk model: VBOX 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: gpt
Disk identifier: 98EEA0A5-FF7F-4B00-8D79-15103DA710A8

Device       Start       End   Sectors  Size Type
/dev/sda1     2048    163839    161792   79M EFI System
/dev/sda2   163840   4069375   3905536  1.9G Linux swap
/dev/sda3  4069376 134217694 130148319 62.1G Linux filesystem

Я в примере расширял раздел через parted, мне так привычнее.