본문 바로가기
  • ^ __________ ^ ㄷ ㅜ ㄹ ㅜ ㅁ ㅜ ㄹ
Memo

[linux] 부트파티션 용량늘리기

by 두루물 2025. 7. 6.

gparted(UI용),parted,lvextend,resize2fs 아무리해도 안되면

cfdisk

GParted빼고,,또는 현 boot시스템이 사용중이라 usb부팅해서 하지않으면 어느 한가지로 해결안됨

[트릭] VM물리적용량늘리고서 디스크하나생성후 /dev/sda1에 있는(기존부트파티션)을 /dev/sda4로 copy

 

/dev/mapper/ubuntu--vg-root   31G   26G  4.2G  86% /
tmpfs                        493M   16K  493M   1% /dev/shm
tmpfs                        5.0M     0  5.0M   0% /run/lock
tmpfs                        493M     0  493M   0% /sys/fs/cgroup
/dev/sda1                    234M   65M  157M  30% /boot
tmpfs                         99M     0   99M   0% /run/user/0
root@ubuntu:~# sudo update-grub
Sourcing file `/etc/default/grub'
grub 설정 파일을 형성합니다 ...
리눅스 이미지를 찾았습니다: /boot/vmlinuz-4.15.0-213-generic
initrd 이미지를 찾았습니다: /boot/initrd.img-4.15.0-213-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
완료되었습니다
root@ubuntu:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/ubuntu--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=e070e668-4562-4d06-b9d2-50ec93efd430 /boot           ext2    defaults        0       2
/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
root@ubuntu:~# fdisk -l
Disk /dev/sda: 50.4 GiB, 54060285952 bytes, 105586496 sectors
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: dos
Disk identifier: 0x000d5f2d

Device     Boot    Start       End  Sectors  Size Id Type
/dev/sda1  *        2048    499711   497664  243M 83 Linux
/dev/sda2         501758  16775167 16273410  7.8G  5 Extended
/dev/sda3       16775168 100663295 83888128   40G 83 Linux
/dev/sda5         501760  16775167 16273408  7.8G 8e Linux LVM

Partition table entries are not in disk order.


Disk /dev/mapper/ubuntu--vg-root: 31.3 GiB, 33567014912 bytes, 65560576 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/ubuntu--vg-swap_1: 508 MiB, 532676608 bytes, 1040384 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@ubuntu:~# lvs
  LV     VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   ubuntu-vg -wi-ao----  31.26g                                                    
  swap_1 ubuntu-vg -wi-ao---- 508.00m                                                    
root@ubuntu:~# lvextend --size +800M /dev/sda1
  "/dev/sda1": Invalid path for Logical Volume.
  Run `lvextend --help' for more information.
root@ubuntu:~# growpart /dev/sda 1

Command 'growpart' not found, but can be installed with:

apt install cloud-guest-utils

root@ubuntu:~# apt install cloud-guest-utils
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다       
상태 정보를 읽는 중입니다... 완료
다음 새 패키지를 설치할 것입니다:
  cloud-guest-utils
0개 업그레이드, 1개 새로 설치, 0개 제거 및 0개 업그레이드 안 함.
15.3 k바이트 아카이브를 받아야 합니다.
이 작업 후 58.4 k바이트의 디스크 공간을 더 사용하게 됩니다.
받기:1 http://kr.archive.ubuntu.com/ubuntu bionic/main amd64 cloud-guest-utils all 0.30-0ubuntu5 [15.3 kB]
내려받기 15.3 k바이트, 소요시간 1초 (20.8 k바이트/초)
Selecting previously unselected package cloud-guest-utils.
(데이터베이스 읽는중 ...현재 129886개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack .../cloud-guest-utils_0.30-0ubuntu5_all.deb ...
Unpacking cloud-guest-utils (0.30-0ubuntu5) ...
cloud-guest-utils (0.30-0ubuntu5) 설정하는 중입니다 ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
root@ubuntu:~# growpart /dev/sda 1          
NOCHANGE: partition 1 could only be grown by 2046 [fudge=2048]
root@ubuntu:~# pvresize /dev/sda1
  Failed to find physical volume "/dev/sda1".
  0 physical volume(s) resized / 0 physical volume(s) not resized
root@ubuntu:~# pvresize /dev/sda3
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
root@ubuntu:~# pvresize /dev/sda1
  Failed to find physical volume "/dev/sda1".
  0 physical volume(s) resized / 0 physical volume(s) not resized
root@ubuntu:~# df -T /
Filesystem                  Type 1K-blocks     Used Available Use% Mounted on
/dev/mapper/ubuntu--vg-root ext4  32111892 26323564   4390516  86% /
root@ubuntu:~# fdisk -l
Disk /dev/sda: 50.4 GiB, 54060285952 bytes, 105586496 sectors
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: dos
Disk identifier: 0x000d5f2d

Device     Boot    Start       End  Sectors  Size Id Type
/dev/sda1  *        2048    499711   497664  243M 83 Linux
/dev/sda2         501758  16775167 16273410  7.8G  5 Extended
/dev/sda3       16775168 100663295 83888128   40G 83 Linux
/dev/sda5         501760  16775167 16273408  7.8G 8e Linux LVM

Partition table entries are not in disk order.


Disk /dev/mapper/ubuntu--vg-root: 31.3 GiB, 33567014912 bytes, 65560576 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/ubuntu--vg-swap_1: 508 MiB, 532676608 bytes, 1040384 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@ubuntu:~# resize2fs /dev/sda1
resize2fs 1.44.1 (24-Mar-2018)
The filesystem is already 248832 (1k) blocks long.  Nothing to do!

root@ubuntu:~# parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) q                                                                
root@ubuntu:~# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0 50.4G  0 disk 
├─sda1                  8:1    0  243M  0 part /boot
├─sda2                  8:2    0    1K  0 part 
├─sda3                  8:3    0   40G  0 part 
│ └─ubuntu--vg-root   253:0    0 31.3G  0 lvm  /
└─sda5                  8:5    0  7.8G  0 part 
  ├─ubuntu--vg-root   253:0    0 31.3G  0 lvm  /
  └─ubuntu--vg-swap_1 253:1    0  508M  0 lvm  [SWAP]
sr0                    11:0    1 1024M  0 rom  
root@ubuntu:~# parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 54.1GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  256MB   255MB   primary   ext2         boot
 2      257MB   8589MB  8332MB  extended
 5      257MB   8589MB  8332MB  logical                lvm
 3      8589MB  51.5GB  43.0GB  primary

(parted) resizepart                                                       
Partition number? 1                                                       
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?
Yes/No? y                                                                 
End?  [256MB]? 1000M
Error: Can't have overlapping partitions.
(parted) q                                                                
root@ubuntu:~# cfdisk
                                                    Disk: /dev/sda
                                 Size: 50.4 GiB, 54060285952 bytes, 105586496 sectors
                                          Label: dos, identifier: 0x000d5f2d

    Device            Boot                 Start             End        Sectors        Size       Id Type
    /dev/sda1         *                     2048          499711         497664        243M       83 Linux
    /dev/sda2                             501758        16775167       16273410        7.8G        5 Extended
    └─/dev/sda5                           501760        16775167       16273408        7.8G       8e Linux LVM
    /dev/sda3                           16775168       100663295       83888128         40G       83 Linux
>>  Free space                         100663296       105586495        4923200        2.4G                           

                        May be followed by M for MiB, G for GiB, T for TiB, or S for sectors.
                                       ┌ Select partition type ──────────────┐
                                       │  0 Empty                            │
                                       │  1 FAT12                            │
                                       │  2 XENIX root                       │
                                       │  3 XENIX usr                        │
                                       │  4 FAT16 <32M                       │
                                       │  5 Extended                         │
                                       │  6 FAT16                            │
                                       │  7 HPFS/NTFS/exFAT                  │
                                       │  8 AIX                              │
                                       │  9 AIX bootable                     │
                                       │  a OS/2 Boot Manager                │
                                       │  b W95 FAT32                        │
                                       │  c W95 FAT32 (LBA)                  │
                                       │  e W95 FAT16 (LBA)                  │
                                       │  f W95 Ext'd (LBA)                  │
                                       │ 10 OPUS                             │
                                       │ 11 Hidden FAT12                     │
                                       │ 12 Compaq diagnostics               │
                                       │ 14 Hidden FAT16 <32M                │
                                       │ 16 Hidden FAT16                     │
                                       │ 17 Hidden HPFS/NTFS                 │
                                       │ 18 AST SmartSleep                   │
                                       │ 1b Hidden W95 FAT32                 │
                                       │ 1c Hidden W95 FAT32 (LBA)           │
                                       │ 1e Hidden W95 FAT16 (LBA)           │
                                       │ 24 NEC DOS                          │
                                       │ 27 Hidden NTFS WinRE                │
                                       │ 39 Plan 9                           │
                                       │ 3c PartitionMagic recovery          │
                                       │ 40 Venix 80286                      │
                                       │ 41 PPC PReP Boot                    │
                                       │ 42 SFS                              │
                                       │ 4d QNX4.x                           │
                                       │ 4e QNX4.x 2nd part                  │
                                       │ 4f QNX4.x 3rd part                  │
                                       │ 50 OnTrack DM                       │
                                       │ 51 OnTrack DM6 Aux1                 │
                                       │ 52 CP/M                             │
                                       │ 53 OnTrack DM6 Aux3                 │
                                       │ 54 OnTrackDM6                       │
                                       │ 55 EZ-Drive                         │
                                       │ 56 Golden Bow                       │
                                       │ 5c Priam Edisk                      │
                                       │ 61 SpeedStor                        │
                                       │ 63 GNU HURD or SysV                 │
                                       │ 64 Novell Netware 286               │
                                       │ 65 Novell Netware 386               │
                                       │ 70 DiskSecure Multi-Boot            │
                                       │ 75 PC/IX                            │
                                       │ 80 Old Minix                        │
                                       │ 81 Minix / old Linux                │
                                       │ 82 Linux swap / Solaris             │
                                       │ 83 Linux                            │
                                       │ 84 OS/2 hidden or Intel hibernation │
                                       │ 85 Linux extended                   │
                                       │ 86 NTFS volume set                  │
                                       │ 87 NTFS volume set                  │
                                       │ 88 Linux plaintext                  │                                       
                                       │ 8e Linux LVM                        │                                       
                                       │ 93 Amoeba                           │                                       
                                       │ 94 Amoeba BBT                       │                                       
                                       │ 9f BSD/OS                           │                                       
                                       │ a0 IBM Thinkpad hibernation         │
                                       │ a5 FreeBSD                          │
                                       └───────────────────────────────────↓─┘
                                       ┌ Select partition type ──────────────┐
                                       │  0 Empty                            │
                                       │  1 FAT12                            │
                                       │  2 XENIX root                       │
                                       │  3 XENIX usr                        │
                                       │  4 FAT16 <32M                       │
                                       │  5 Extended                         │
                                       │  6 FAT16                            │
                                       │  7 HPFS/NTFS/exFAT                  │
                                       │  8 AIX                              │
                                       │  9 AIX bootable                     │
                                       │  a OS/2 Boot Manager                │
                                       │  b W95 FAT32                        │
                                       │  c W95 FAT32 (LBA)                  │
                                       │  e W95 FAT16 (LBA)                  │
                                       │  f W95 Ext'd (LBA)                  │
                                       │ 10 OPUS                             │
                                       │ 11 Hidden FAT12                     │
                                       │ 12 Compaq diagnostics               │
                                       │ 14 Hidden FAT16 <32M                │
                                       │ 16 Hidden FAT16                     │
                                       │ 17 Hidden HPFS/NTFS                 │
                                       │ 18 AST SmartSleep                   │
                                       │ 1b Hidden W95 FAT32                 │
                                       │ 1c Hidden W95 FAT32 (LBA)           │
                                       │ 1e Hidden W95 FAT16 (LBA)           │
                                       │ 24 NEC DOS                          │
                                       │ 27 Hidden NTFS WinRE                │
                                       │ 39 Plan 9                           │
                                       │ 3c PartitionMagic recovery          │
                                       │ 40 Venix 80286                      │
                                       │ 41 PPC PReP Boot                    │
                                       │ 42 SFS                              │
                                       │ 4d QNX4.x                           │
                                       │ 4e QNX4.x 2nd part                  │
                                       │ 4f QNX4.x 3rd part                  │
                                       │ 50 OnTrack DM                       │
                                       │ 51 OnTrack DM6 Aux1                 │
                                       │ 52 CP/M                             │
                                       │ 53 OnTrack DM6 Aux3                 │
                                       │ 54 OnTrackDM6                       │
                                       │ 55 EZ-Drive                         │
                                       │ 56 Golden Bow                       │
                                       │ 5c Priam Edisk                      │
                                       │ 61 SpeedStor                        │
                                       │ 63 GNU HURD or SysV                 │
                                       │ 64 Novell Netware 286               │
                                       │ 65 Novell Netware 386               │
                                       │ 70 DiskSecure Multi-Boot            │
                                       │ 75 PC/IX                            │
                                       │ 80 Old Minix                        │
                                       │ 81 Minix / old Linux                │
                                       │ 82 Linux swap / Solaris             │
                                       │ 83 Linux                            │
                                       │ 84 OS/2 hidden or Intel hibernation │
                                       │ 85 Linux extended                   │
                                       │ 86 NTFS volume set                  │
                                       │ 87 NTFS volume set                  │
                                       │ 88 Linux plaintext                  │
                                       │ 8e Linux LVM                        │
                                       │ 93 Amoeba                           │                                       
                                       │ 94 Amoeba BBT                       │                                       
                                       │ 9f BSD/OS                           │                                       
                                       │ a0 IBM Thinkpad hibernation         │
                                       │ a5 FreeBSD                          │
                                       └───────────────────────────────────↓─┘
                                       ┌ Select partition type ──────────────┐
                                       │  0 Empty                            │
                                       │  1 FAT12                            │
                                       │  2 XENIX root                       │
                                       │  3 XENIX usr                        │
                                       │  4 FAT16 <32M                       │
                                       │  5 Extended                         │
                                       │  6 FAT16                            │
                                       │  7 HPFS/NTFS/exFAT                  │
                                       │  8 AIX                              │
                                       │  9 AIX bootable                     │
                                       │  a OS/2 Boot Manager                │
                                       │  b W95 FAT32                        │
                                       │  c W95 FAT32 (LBA)                  │
                                       │  e W95 FAT16 (LBA)                  │
                                       │  f W95 Ext'd (LBA)                  │
                                       │ 10 OPUS                             │
                                       │ 11 Hidden FAT12                     │
                                       │ 12 Compaq diagnostics               │
                                       │ 14 Hidden FAT16 <32M                │
                                       │ 16 Hidden FAT16                     │
                                       │ 17 Hidden HPFS/NTFS                 │
                                       │ 18 AST SmartSleep                   │
                                       │ 1b Hidden W95 FAT32                 │
                                       │ 1c Hidden W95 FAT32 (LBA)           │
                                       │ 1e Hidden W95 FAT16 (LBA)           │
                                       │ 24 NEC DOS                          │
                                       │ 27 Hidden NTFS WinRE                │
                                       │ 39 Plan 9                           │
                                       │ 3c PartitionMagic recovery          │
                                       │ 40 Venix 80286                      │
                                       │ 41 PPC PReP Boot                    │
                                       │ 42 SFS                              │
                                       │ 4d QNX4.x                           │
                                       │ 4e QNX4.x 2nd part                  │
                                       │ 4f QNX4.x 3rd part                  │
                                       │ 50 OnTrack DM                       │
                                       │ 51 OnTrack DM6 Aux1                 │
                                       │ 52 CP/M                             │
                                       │ 53 OnTrack DM6 Aux3                 │
                                       │ 54 OnTrackDM6                       │
                                       │ 55 EZ-Drive                         │
                                       │ 56 Golden Bow                       │
                                       │ 5c Priam Edisk                      │
                                       │ 61 SpeedStor                        │
                                       │ 63 GNU HURD or SysV                 │
                                       │ 64 Novell Netware 286               │
                                       │ 65 Novell Netware 386               │
                                       │ 70 DiskSecure Multi-Boot            │
                                       │ 75 PC/IX                            │
                                       │ 80 Old Minix                        │
                                       │ 81 Minix / old Linux                │
                                       │ 82 Linux swap / Solaris             │
                                       │ 83 Linux                            │
                                       │ 84 OS/2 hidden or Intel hibernation │
                                       │ 85 Linux extended                   │
                                       │ 86 NTFS volume set                  │
                                       │ 87 NTFS volume set                  │
                                       │ 88 Linux plaintext                  │                                       
                                       │ 8e Linux LVM                        │                                       
                                       │ 93 Amoeba                           │                                       
                                       │ 94 Amoeba BBT                       │                                       
                                       │ 9f BSD/OS                           │                                       
                                       │ a0 IBM Thinkpad hibernation         │
                                       │ a5 FreeBSD                          │
                                       └───────────────────────────────────↓─┘
                                                    Disk: /dev/sda
                                 Size: 50.4 GiB, 54060285952 bytes, 105586496 sectors
                                          Label: dos, identifier: 0x000d5f2d

    Device            Boot                 Start             End        Sectors        Size       Id Type
>>  /dev/sda1         *                     2048          499711         497664        243M       83 Linux            
    /dev/sda2                             501758        16775167       16273410        7.8G        5 Extended
    └─/dev/sda5                           501760        16775167       16273408        7.8G       8e Linux LVM
    /dev/sda3                           16775168       100663295       83888128         40G       83 Linux
    /dev/sda4                          100663296       102760447        2097152          1G       83 Linux
    Free space                         102760448       105586495        2826048        1.4G

 ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 │ Partition type: Linux (83)                                                                                       │
 │     Attributes: 80                                                                                               │
 │Filesystem UUID: e070e668-4562-4d06-b9d2-50ec93efd430                                                             │
 │     Filesystem: ext2                                                                                             │
 │     Mountpoint: /boot (mounted)                                                                                  │
 └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
            [Bootable]  [ Delete ]  [ Resize ]  [  Quit  ]  [  Type  ]  [  Help  ]  [  Write ]  [  Dump  ]



root@ubuntu:~# parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) list                                                             
  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|NUMBER]     display the partition table, available devices, free space, all found
        partitions, or a particular partition
  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) 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|NUMBER]     display the partition table, available devices, free space, all found
        partitions, or a particular partition
  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: 54.1GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  256MB   255MB   primary   ext2         boot
 2      257MB   8589MB  8332MB  extended
 5      257MB   8589MB  8332MB  logical                lvm
 3      8589MB  51.5GB  43.0GB  primary

(parted) resizepart 1                                                     
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?
Yes/No? y                                                                 
End?  [256MB]? 800MB
Error: Can't have overlapping partitions.
(parted) q                                                                
root@ubuntu:~# 
root@ubuntu:~# 
root@ubuntu:~#