J 창고

MacBook에서 Ubuntu 16.04 설치 without rEFInd rEFIt 본문

컴퓨터/Mac

MacBook에서 Ubuntu 16.04 설치 without rEFInd rEFIt

JSFamily 2017. 3. 5. 19:09




1. 개요

MacBook을 사용하는 중에 Ubuntu에서 개발하고자 성능을 위해 Native로 설치하고자 본 Post를 써본다.

다만 Bootloader가 rEFInd, rEFIt 을 사용하는 것이 아닌 MAC고유의 EFI64를 사용하여 설치 하였다.


MacBook 13" 2009 Late Unibody Write

CPU Core2Duo 2.26Ghz, RAM DDR3 8Gb, HDD 7200RPM 500Gb



2. 준비


2-1 Ubuntu 설치용 USB

설치용 USB 만드는 방법은 링크의 검색 결과에 여럿 존재하니 적당한 곳에서 참고하며 만들면 된다.



2-2 Ubuntu 설치용 파티션 준비

기존에 MacOS 가 설치되어 있던 Partition을 "디스크 유틸리티" 를 사용하여  repartition을 해 준다.

HDD에는 120GB를 적용하고 나머지 공간엔 Ubuntu를 설치 할 것이다.




3. Ubuntu 설치 및 Grub 설정


3-1 Ubuntu 설치

Ubuntu 설치 USB를 삽입하고 부팅 시 "option" 키를 누르고 있으면 아래와 같이 EFI Boot 미디어가 나타난다.




EFI Boot 를 선택하고 그 이후 절차는 일반 PC에서의 설정과 같이 진행하면 된다.

다만 Partition설정 시에는 조금 다르므로 Partition설정은 "Something else" 를 선택하여 Manual로 잡는다.



Ubuntu 를 다른 저장매체에 설치한다면 다르겠지만 이번 포스트에서는 같은 저장매체에 설치하는 경우를 기준으로 작성하였다.

sda라는 미디어에 MacOS와 Ubuntu가 설치되면 아래와 같이 Partition을 잡아준다

(sda3과 sda4는 생성 순서에 따라 번호가 바뀔 수도 있다)

/dev/sda1 => EFI Partition

/dev/ada2 => MacOS Partiton

/dev/sda4 => Ubuntu Partition

/dev/ada3 => Ubuntu용 Swap Partiton



3-2 Grub 설정 및 Ubuntu 부팅 

설치 후 재부팅 시 Ubuntu 설치 USB 를 빼지 말고 다시 "EFI Boot"를 선택하고

부팅 메뉴 설정 시 "esc" 를 선택하여 Grub shell 모드로 들어간다.


Grub Shell 접속 후 아래 커맨드를 통해 Grub의 기본 장치를 설정해 준다.


1) 설치 미디어 찾기 => Home Directory 검색을 통해 Ubuntu 설치 장치 찾기

grub> ls

(memdisk) (hd0) (hd0,msdos1) (hd1) (hd1,gpt4) (hd1,gpt3) (hd1,gpt2) (hd1,gpt1) (cd0)

grub> ls (hd1,gpt4)/home

dev/


2) grub 위치 찾기 => 현재 EFI Manager에서는 Ubuntu의 Grub을 연결하지 못하는 상태이기 때문에 Ubuntu설치용 USB를 통해 부팅함

grub> ls (hd1,gpt4)/boot/grub

x86_64-efi/ unicode.pf2 locale/ fonts/ grubenv grub.cfg


3) grub 기본 미디어 설정

grub> set root=(hd1,gpt4)

Partition hd1,gpt4: Filesystem type ext* - Last modification time 2017-02-26 13:31:24 Sunday, UUID 88791749-629c-4f56-9d4a-7f30cb1ab059 - Partition start at 117392384KiB - Total size 363097872KiB


2018.01.02 추가)

set root를 했을 때 UUID가 안나온다면 당황하지 말고 ls -l 을 통해 설정하고자 하는 Partition의 UUID를 획득할 수 있다.


4) linux 이미지에 Disk UUID 설정

grub> linux /boot/vmlinuz-4.4.0-31.generic.efi.signed root=UUID=88791749-629c-4f56-9d4a-7f30cb1ab059


5) initrd 설정

grub> initrd /boot/initrd.img-4.4.0-31-generic


6) Ubuntu 부팅

grub> boot



4. Ubuntu 설정


4-1 패키지 설치

dev@dev-MacBook:~$ sudo add-apt-repository ppa:detly/mactel-utils

dev@dev-MacBook:~$ sudo apt-get update

dev@dev-MacBook:~$ sudo apt-get install mactel-boot hfsprogs gdisk grub-efi-amd64


4-2 EFI 파티션 Reformatting

dev@dev-MacBook:~$ sudo umount /dev/sda1

dev@dev-MacBook:~$ sudo gdisk /dev/sda


disk 로 파티션 설정시 아래 빨간색 음영과 같이 입력해주면 된다.

Found valid GPT with hybrid MBR; using GPT.


Command (? for help): p

Disk /dev/sda: 976773168 sectors, 465.8 GiB

Logical sector size: 512 bytes

Disk identifier (GUID): D65CF3EA-FDE1-495E-9314-49250B9705A3

Partition table holds up to 128 entries

First usable sector is 34, last usable sector is 976773134

Partitions will be aligned on 8-sector boundaries

Total free space is 2197 sectors (1.1 MiB)


Number  Start (sector)    End (sector)  Size       Code  Name

   1              40          409639   200.0 MiB   EF00  EFI System Partition

   2          409640       234784639   111.8 GiB   AF00  HDD

   3       960960512       976771071   7.5 GiB     8200  

   4       234784768       960960511   346.3 GiB   8300  


Command (? for help): d

Partition number (1-4): 1


Command (? for help): n

Partition number (1-128, default 1): 1 

First sector (34-976773134, default = 40) or {+-}size{KMGTP}: AF00

First sector (34-976773134, default = 40) or {+-}size{KMGTP}: 

Last sector (40-409639, default = 409639) or {+-}size{KMGTP}: 

Current type is 'Linux filesystem'

Hex code or GUID (L to show codes, Enter = 8300): AF00

Changed type of partition to 'Apple HFS/HFS+'


Command (? for help): p

Disk /dev/sda: 976773168 sectors, 465.8 GiB

Logical sector size: 512 bytes

Disk identifier (GUID): D65CF3EA-FDE1-495E-9314-49250B9705A3

Partition table holds up to 128 entries

First usable sector is 34, last usable sector is 976773134

Partitions will be aligned on 8-sector boundaries

Total free space is 2197 sectors (1.1 MiB)


Number  Start (sector)    End (sector)  Size       Code  Name

   1              40          409639   200.0 MiB   AF00  Apple HFS/HFS+

   2          409640       234784639   111.8 GiB   AF00  HDD

   3       960960512       976771071   7.5 GiB     8200  

   4       234784768       960960511   346.3 GiB   8300  


Command (? for help): 


Command (? for help): w



Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING

PARTITIONS!!


Do you want to proceed? (Y/N): y

OK; writing new GUID partition table (GPT) to /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. 



4-3 Filesystem 업데이트

dev@dev-MacBook:~$ sudo vim /etc/fstab


/boot/efi에 대해 주석 처리

# /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>

# / was on /dev/sda4 during installation

UUID=88791749-629c-4f56-9d4a-7f30cb1ab059 /               ext4    errors=remount-ro 0       1


# /boot/efi was on /dev/sda1 during installation

#UUID=67E3-17ED  /boot/efi       vfat    umask=0077      0       1


# swap was on /dev/sda3 during installation

UUID=0c6511af-6e89-4378-9d2f-5da0975e680a none            swap    sw              0       0 


새로운 UUID 설정

dev@dev-MacBook:~$ sudo bash -c 'echo $(blkid -o export -s UUID /dev/sda1) /boot/efi auto defaults 0 0 >> /etc/fstab'

그러면 /etc/fstab의 맨 아랫줄에 아래와 같은 새로운 구문이 생성되는데

DEVNAME=/dev/sda1 UUID=c456f858-451a-3126-a3e8-b0f079dd79a0 /boot/efi auto defaults 0 0

이를 아래와 같이 /boot/efi 에 설정 해준다. (앞의 DEVNAME= 도 빼주고...)


새로운 UUID 설정

# /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>

# / was on /dev/sda4 during installation

UUID=88791749-629c-4f56-9d4a-7f30cb1ab059 /               ext4    errors=remount-ro 0       1


# /boot/efi was on /dev/sda1 during installation

#UUID=67E3-17ED  /boot/efi       vfat    umask=0077      0       1

UUID=c456f858-451a-3126-a3e8-b0f079dd79a0 /boot/efi auto defaults 0 0


# swap was on /dev/sda3 during installation

UUID=0c6511af-6e89-4378-9d2f-5da0975e680a none            swap    sw              0       0 


/boot/efi 마운트

dev@dev-MacBook:~$ sudo mount /boot/efi


4-4 hfs+ 파티션에 grub 설치

dev@dev-MacBook:~$ sudo bash -c 'echo "This file is required for booting" > /boot/efi/mach_kernel'

dev@dev-MacBook:~$ sudo bash -c 'echo "This file is required for booting" > /boot/efi/EFI/ubuntu/mach_kernel'


dev@dev-MacBook:~$ sudo grub-install --target x86_64-efi --boot-directory=/boot --efi-directory=/boot/efi

Installing for x86_64-efi platform.

Installation finished. No error reported.

dev@dev-MacBook:~$ sudo hfs-bless "/boot/efi/EFI/ubuntu/System/Library/CoreServices/boot.efi"






참조

http://askubuntu.com/questions/563401/efi-boot-ubuntu-14-04-on-a-mac-without-refind


Comments