스왑/부팅 파티션

스왑/부팅 파티션

약 6개월 전에 저는 새 노트북과 쿠분투를 설치했습니다. 나는 이제 별도의 /boot를 선택했고(기본값을 수락했습니다) 다음 쿠분투 버전으로 업그레이드하는 동안 /boot에 공간이 부족합니다(정리되었으며 너무 작습니다)

부팅=sda5 루트=sda7

그래서 저는 별도의 /boot를 버리고 루트 파티션의 디렉토리로 /boot를 사용하기로 했습니다. 그래서:

  1. /newboot 생성(루트 파일 시스템에서)
  2. cp -a /boot/* /newboot (& rmdir /newboot/lost+found)
  3. 제거/시작
  4. mv /boot /oldboot, mv /newboot /boot
  5. /etc/fstab 편집(이전 /dev/sd5를 /oldboot로 마운트)
  6. systemctl 데몬 다시 로드
  7. 업데이트-initramfs -u

이제 /boot/grub/grub.cfg를 /oldboot/grub/grub.cfg와 비교합니다.

똑같습니다...글쎄요, 설정이 많이 있는 것 같아요"제안"grub은 실제로 파일을 찾습니다. 문제는 sda5(msdos5) 및 sda7(msdos7)에 "좋은" grub.cfg가 있고 그 중 하나를 찾을 수 있다는 것입니다. 그래서 grub.cfg에서 msdos5에 대한 모든 참조를 msdos7에 대해 수동으로 편집하고 update-initramfs -u를 다시 실행하고 재부팅했는데 모두 괜찮았습니다...

하지만 의심스럽습니다... "/boot"를 사용합니까, 아니면 여전히 "/oldboot"를 사용합니까... 그래서 oldboot에는 2개의 커널(및 initrd)이 있습니다(예: vmlinuz-6.2.0-36 -generic 및 vmlinuz -6.2) .0-35-generic 이름을 NOT-vmlinuz-6.2.0-36-generic으로 바꾸고 재부팅했습니다. ...실패했습니다. "35" 버전을 선택했는데 괜찮았습니다...그래서 여전히 /oldboot를 읽고 있습니다.

그렇다면 내가 놓친 단계는 무엇입니까?. UUID를 수동으로 편집해야 합니까? 실패하기 쉬운 것 같습니다... 간단한 "grub.cfg 재생성" 단계가 누락된 것 같습니다... grub을 다시 설치하시겠습니까?

답변1

좋아, 왜 아무도 뛰어내리지 않고 빠른 답변을 하지 않았는지 이해합니다. 훨씬 더 복잡합니다.

그래서 이 사소한 일은

grub-mkconfig -o /boot/grub/grub.cfg

그러나 그것은 전체 이야기와는 거리가 멀다. 먼저 더 많은 정보가 필요합니다.

  1. (레거시) BIOS를 사용하여 시스템 부팅
  2. 노트북에는 기존의 "잠자기" 설치가 있으며 초기 부트로더 + BCD를 사용합니다.

따라서 위의 모든 단계를 먼저 수행해야 합니다. 그럼 위에 있는 거요grub-mkconfig, 이는 다음과 같이 변경됩니다.

root@ThinkPad:/boot/grub# diff grub.cfg.5nov23 grub.cfg
173c173
<   set root='hd0,msdos5'
---
>   set root='hd0,msdos7'
175c175
<     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos5 --hint-efi=hd0,msdos5 --hint-baremetal=ahci0,msdos5  7094b250-3ccf-436e-af52-6c0d828cc15c
---
>     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos7 --hint-efi=hd0,msdos7 --hint-baremetal=ahci0,msdos7  e8128f48-1ef6-44e6-b95c-1595c6ddf05c
177c177
<     search --no-floppy --fs-uuid --set=root 7094b250-3ccf-436e-af52-6c0d828cc15c
---
>     search --no-floppy --fs-uuid --set=root e8128f48-1ef6-44e6-b95c-1595c6ddf05c
179,180c179,180
<   linux   /vmlinuz-6.2.0-36-generic root=UUID=e8128f48-1ef6-44e6-b95c-1595c6ddf05c ro  quiet splash $vt_handoff
<   initrd  /initrd.img-6.2.0-36-generic
---
>   linux   /boot/vmlinuz-6.2.0-36-generic root=UUID=e8128f48-1ef6-44e6-b95c-1595c6ddf05c ro  quiet splash $vt_handoff
>   initrd  /boot/initrd.img-6.2.0-36-generic
191c191
...

기본적으로 SDA5를 SDA7로 변경하고 경로를 /grub에서 /boot/grub 및 UUID로 변경합니다.

하지만 (내 경우에는) 필요한 마지막 단계는 다음과 같습니다.그럽 설치 /dev/sda7

그 이유는 약간 복잡합니다. 두 가지 경우를 다루겠습니다. 첫 번째는 내 것이고 두 번째는 초기 부트 로더가 grub(잠자기 파티션 유무에 관계없이)인 경우에 더 일반적입니다.

내 경우는 다음과 같습니다.

root@ThinkPad:/boot/grub# grub-mkconfig -o /boot/grub/grub.cfg
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.2.0-36-generic
Found initrd image: /boot/initrd.img-6.2.0-36-generic
Found linux image: /boot/vmlinuz-6.2.0-35-generic
Found initrd image: /boot/initrd.img-6.2.0-35-generic
Found memtest86+x64 image: /boot/memtest86+x64.bin
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows 10 on /dev/sda1
done

root@ThinkPad:/boot/grub# grub-install /dev/sda7
Installing for i386-pc platform.
grub-install: warning: Filesystem `ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.


root@ThinkPad:/boot/grub# grub-install --force /dev/sda7
Installing for i386-pc platform.
grub-install: warning: Filesystem `ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
Installation finished. No error reported.

제 경우 노트북은 Doze 부트로더를 이용해서 부팅한 뒤 BCD(Boot Utility)를 이용해서 부팅 파티션 선택을 허용하는데... 예전에는 1(Doze)이나 5(Kubuntu)를 허용했는데 7(SDA7= 루트) )

따라서 이는 grub 부트로더가 /dev/sda7에 있어야 하며 경고에 포함될 수 없다는 것을 의미하므로(core.img의 복사본은 디스크 부팅 간격 초기에 저장됨) 신뢰할 수 없는 방법을 사용해야 합니다( 한숨!) 그런데 이건 변경 전과 똑같네요.

다른 많은 사용자의 경우 초기 부트 로더로 grub을 설치합니다. 이 경우 다음을 수행할 수 있습니다.

# grub-install  /dev/sda

이것은 grub이 더 일반적이고 더 잘 작동하는 곳입니다.

그래서 이것을 부팅하고 부팅 옵션으로 kubuntu-SDA7을 선택했는데 정상적으로 부팅되었습니다. 위의 디버그 변경 사항을 적용했습니다(이름을 다음으로 변경했습니다).NOT-vmlinuz-6.2.0-36-일반) 그래도 여전히 잘 부팅됩니다. 따라서 더 이상 /oldboot를 사용하지 않습니다.

관련 정보