Linuxãèµ·åããæ¹æ³ã¯ããããããã¾ãï¼æ¬ã¨ã³ããªã§ã¯
- MBR (Master Boot Record)ã«ã¤ã³ã¹ãã¼ã«ãã grub2 ã使ãæ¹æ³
- ESP(Efi System Partition)ã«ã¤ã³ã¹ãã¼ã«ãã grub2 ã使ãæ¹æ³
ã®ï¼ã¤ãå ±åããããã£ã¹ã¯ãä½æããæ¹æ³ã«ã¤ãã¦ã¾ã¨ãã¾ã
åè ã¯ï¼å¾æ¥ã®BIOSçµç±ã§ã®èµ·åæ¹æ³ã§ï¼å¤ããã¶ã¼ãã¼ãã ã¨å¿ é ã¨ãªãæ¹æ³ã§ãï¼å¾è ã¯ï¼EFIçµç±ã®èµ·åæ¹æ³ã§ï¼æè¿ã®ãã¼ã¶ã¼ãã¼ãã§ä½¿ãã"æ°ããã¦ä¾¿å©ãª"æ¹æ³ã¨ãªãã¾ãï¼
å ·ä½çãªæé ã«ã¤ãã¦
以ä¸ï¼å®ä¾ã¨ãã¦
- æ°åã®SSDãç¨æ
- æ¢åã®ã·ã¹ãã ãæ°åã®SSDã«ã³ãã¼
- OSã¯ãdebian ï¼ubuntu ã cent OS ãªã©ã§ãåãæé ã§ä½æ¥ã§ããã¯ãã§ãï¼
ã®å ´åã«ã¤ãã¦æé ã詳細ã«èª¬æãã¾ã
SSDã¯64GB ã§ã/dev/sdb ã«ç¹ãã§ãããã®ã¨ãã¾ã
ãªãæ¢åã®ãã£ã¹ã¯ã MBR/ESP両対å¿ã«å¤æããæé ã«ã¤ãã¦ã¯ï¼å¾æ¥å¥ã¨ã³ããªã«æ¸ãäºå®ã§ãï¼
äºåæºå
äºåç¥èã¨ãã¦
- MBRã使ãå ´åã¯ï¼ãã£ã¹ã¯ã®å é ã«1MBç¨åº¦ã®é åã確ä¿ãã¦ããã¦ï¼ããã« grub2ãå ¥ããäº
- ESPã使ãå ´åã¯ï¼ãã£ã¯ã¹ã®ãã¼ãã£ã·ã§ã³ãã¼ãã«ããGPT ã¨ããå½¢å¼ã§è¨å®ããäº
- ESP㯠FAT32 ã¾ã㯠FAT16ã§ãã©ã¼ãããããäº
ã¨ããæ¡ä»¶ãããã¾ã
ããã§ï¼äºã gptã使ãããã« gdiskï¼ fat ã§ãã©ã¼ãããããã®ã§ãdosfstoolsããã¤ã³ã¹ãã¼ã«ãã¦ããã¾ã
$ sudo apt-get install gdisk dosfstools
grub-efi ãã¤ã³ã¹ãã¼ã«ãã¦ããã¾ã
$ sudo apt-get install grub-efi
gdisk ã使ã£ããã¼ãã£ã·ã§ã³è¨å®
gdisk ã§
sudo /sbin/gdisk /dev/sdb
次ã®ããã«è¡¨ç¤ºããã¾ã
GPT fdisk (gdisk) version 1.0.1 Partition table scan: MBR: not present BSD: not present APM: not present GPT: not present Creating new GPT entries. Command (? for help):
æªåæåã®SSDãªã®ã§ãã¼ãã£ã·ã§ã³ãã¼ãã«ãããã¾ãã
ã¾ã expert ã¢ã¼ãã«é·ç§»ï¼sector alignment value ã 1ã«å¤æ´ãã¾ã
Command (? for help): x Expert command (? for help): l Enter the sector alignment value (1-65536, default = 2048): 1 Expert command (? for help): m Command (? for help):
åã³ãã³ãã説æããã¨ï¼
- ã¾ã"x"ã§expertã¢ã¼ãã«çªå ¥
- "l"ã§sector alignment value ã®å¤æ´
- å¤ã1 ã«è¨å®
- "m"ã§å ã®ã¢ã¼ãã«æ»ã
ã¨ãªãã¾ã
ç¶ãã¦ç¬¬ä¸ãã¼ãã£ã·ã§ã³ãä½æãã¾ãï¼ãã®ãã¼ãã£ã·ã§ã³ã¯ MBRç¨ grub ã使ãé åã«ãªãã¾ã
Command (? for help): n Partition number (1-128, default 1): 1 First sector (34-125045390, default = 34) or {+-}size{KMGTP}: 34 Last sector (34-125045390, default = 125045390) or {+-}size{KMGTP}: 2047 Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): EF02 Changed type of partition to 'BIOS boot partition'
åã³ãã³ãã説æããã¨ï¼
- "n" ã§æ°ãããã¼ãã£ã·ã§ã³ãä½æ
- 1ã§ç¬¬ä¸ãã¼ãã£ã·ã§ã³ãæå®
- å é ã»ã¯ã¿ã 34
- æ«å°¾ã»ã¯ã¿ã 2047
- ãã¼ãã£ã·ã§ã³ã®GUIDã EF02
ã¨è¨å®ãã¦ãã¾ãï¼ãã㧠"BIOS boot partition" ãä½æããã¾ã
念ã®çºï¼"p"ã³ãã³ãã§ãã¼ãã£ã·ã§ã³ãã¼ãã«ã表示ããã¦ï¼ç¶æ ã確èªãã¾ã
Command (? for help): p Disk /dev/sdb: 125045424 sectors, 59.6 GiB Logical sector size: 512 bytes Disk identifier (GUID):XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX Partition table holds up to 128 entries First usable sector is 34, last usable sector is 125045390 Partitions will be aligned on 1-sector boundaries Total free space is 125043343 sectors (59.6 GiB) Number Start (sector) End (sector) Size Code Name 1 34 2047 1007.0 KiB EF02 BIOS boot partition Command (? for help):
34ã»ã¯ã¿ãã2047ã»ã¯ã¿ã« EF02 㧠BIOS boot parttion ãä½æããã¦ãããã¨ã確èªã§ãã¾ã
ãã¾ãè¡ã£ãã sector alignment value ã 2048 ã«æ»ãã¾ã
Command (? for help): x Expert command (? for help): l Enter the sector alignment value (1-65536, default = 2048): 2048 Expert command (? for help): m Command (? for help):
- "x"ã§exportã¢ã¼ãã«çªå ¥
- "l"ã§sector alignment value ã®å¤æ´
- å¤ã 2048 ã«è¨å®
- "m"ã§å ã®ã¢ã¼ãã«æ»ã
ã¨ãªãã¾ã
次㫠EFI System ãã¼ãã£ã·ã§ã³ãä½æãã¾ã
Command (? for help): n Partition number (2-128, default 2): 2 First sector (2048-125045390, default = 2048) or {+-}size{KMGTP}: 2048 Last sector (2048-125045390, default = 125045390) or {+-}size{KMGTP}: 256M Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): EF00 Changed type of partition to 'EFI System'
- "n" ã§æ°ãããã¼ãã£ã·ã§ã³ãä½æ
- 2ã§ç¬¬ï¼ãã¼ãã£ã·ã§ã³ãæå®
- å é ã»ã¯ã¿ã 2048
- ãã¼ãã£ã·ã§ã³ãµã¤ãºã¯ 256MB
- ãã¼ãã£ã·ã§ã³ã®GUID㯠EF00
ã¨è¨å®ãã¾ãï¼ãã㧠"EFI System" ãã¼ãã£ã·ã§ã³ãä½æããã¾ãã
ç¶ã㦠Linuxãç¨ã®ãã¼ãã£ã·ã§ã³ãä½æãã¾ãï¼ä»åã¯ãã£ã¹ã¯ã®æ®ãã®é åããã¹ã¦ "/" ãã¼ãã£ã·ã§ã³ã«å²ãå½ã¦ããã¨ã«ãã¾ã
Command (? for help): n Partition number (3-128, default 3): First sector (524289-125045390, default = 526336) or {+-}size{KMGTP}: Last sector (526336-125045390, default = 125045390) or {+-}size{KMGTP}: Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem'
- "n" ã§æ°ãããã¼ãã£ã·ã§ã³ãä½æ
- ãã¨ã¯ããã©ã«ãå¤ããã®ã¾ã¾ä½¿ãã°ããã®ã§ï¼enter ãã¼ãæ¼ãã ãã§ã
- ãã¼ãã£ã·ã§ã³çªå·ã3
- å é ã»ã¯ã¿ã¯ 526336
- æ«å°¾ã»ã¯ã¿ã¯ 125045390
- ãã¼ãã£ã·ã§ã³ã®GUID 㯠8300
ã¨ãªã£ã¦ãã¾ã
æå¾ã« "p" ã§ãã¼ãã£ã·ã§ã³æ å ±ã表示ããã¾ã
Command (? for help): p Disk /dev/sdb: 125045424 sectors, 59.6 GiB Logical sector size: 512 bytes Disk identifier (GUID):XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX Partition table holds up to 128 entries First usable sector is 34, last usable sector is 125045390 Partitions will be aligned on 2048-sector boundaries Total free space is 2047 sectors (1023.5 KiB) Number Start (sector) End (sector) Size Code Name 1 34 2047 1007.0 KiB EF02 BIOS boot partition 2 2048 524288 255.0 MiB EF00 EFI System 3 526336 125045390 59.4 GiB 8300 Linux filesystem
åé¡ãªããã° "w" ã§ãã¼ãã£ã·ã§ã³æ å ±ããã£ã¹ã¯ã«æ¸ãè¾¼ã¿ã¾ã
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/sdb.
åé¡ãªããã° "Y" ãæ¼ãã¾ãï¼"Y"ãæ¼ãã¾ã§ã¯ãã£ã¹ã¯ã«ã¯ä½ãæ¸ãè¾¼ã¾ããªãã®ã§ï¼ä¸å®ã ã£ãã
Ctrk-C ã¨ã "N" ãæ¼ãã°å¤æ´ã¯ãã£ã³ã»ã«ã§ãã¾ã
åãã¼ãã£ã·ã§ã³ã®ãã©ã¼ããã
å度ãã¼ãã£ã·ã§ã³ã確èªãã¾ã
$ sudo /sbin/gdisk -l /dev/sdb
Number Start (sector) End (sector) Size Code Name 1 34 2047 1007.0 KiB EF02 BIOS boot partition 2 2048 526335 256.0 MiB EF00 EFI System 3 526336 125045390 59.4 GiB 8300 Linux filesystem
第1ãã¼ãã£ã·ã§ã³ã®ãã©ã¼ãããã¯ä¸è¦ã§ãï¼grubãç´æ¥ã»ã¯ã¿ãæ¸ãæããããã§ã
第ï¼ãã¼ãã£ã·ã§ã³ /dev/sdb2 㯠vfat 32 ã§ãã©ã¼ããããã¾ãï¼ããã¯EFIã®ã«ã¼ã«ã§ã
$ sudo /sbin/mkfs.vfat -F32 /dev/sdb2
第ï¼ãã¼ãã£ã·ã§ã³ /dev/sdb3 㯠ext4 ã§ãã©ã¼ããããã¾ãã
$ sudo /sbin/mkfs.ext4 /dev/sdb3
第ä¸ãã¼ãã£ã·ã§ã³ã¯ãã£ã¹ã¯ã©ãã«ãæå®ãã¦ããã¾ãï¼ã©ãã«ã¯"ROOT"ã«ãã¾ã
$ sudo /sbin/e2label /dev/sdb3 ROOT
ä»æã®Linuxã¯UUIDã§ãã¼ãã£ã·ã§ã³ãç¹å®ãã¾ããï¼ç§ã¯å¿
ãã©ãã«ãè¨å®ããããã«ãã¦ãã¾ãï¼
ãªããªãï¼ãµã¼ãé害æãªã©ã®ç·æ¥æã«ã¯ææªSSDãåãå¤ãã¦ï¼å¥ã®Linux BOXã«ç¹ãã§ãã¦ã³ãã¨ããæ段ãåããã¨ãããï¼ãã®éã¯ã©ãã«ãæå®ãã¦ããã¨ä½æ¥ãåæ»ã«ãããªããããã§ãï¼
ã·ã¹ãã ã®ã³ãã¼
é·ãã®ã§å¥ã¨ã³ããªã«ãã¦ãã¾ãï¼linux環境を複製する方法 - ぴょぴょぴょ? - Linuxとかプログラミングの覚え書き -ããã¡ããã覧ãã ãã
grubã®ã¤ã³ã¹ãã¼ã«
æ°ãããã£ã¹ã¯ä¸ã /mnt ã«ãã¦ã³ããã¦ï¼ããã« chroot ããç°å¢ã§ä½æ¥ãã¾ã
$ sudo mount /dev/sdb3 /mnt $ sudo mount --bind /dev /mnt/dev $ sudo mount --bind /proc /mnt/proc $ sudo chroot /mnt
MBRç¨grub2ã®ã¤ã³ã¹ãã¼ã«
å¾æ¥ã®BIOSãã¼ãã§ä½¿ç¨ãããã¼ããã¼ãã¨ã㦠grub2 ãã¤ã³ã¹ãã¼ã«ãã¾ã
# /usr/sbin/grub-install --target=i386-pc /dev/sdb
ã¨ã©ã¼ãåºãå ´åã¯ä»¥ä¸ã®ç¹ã確èªãã¾ã
- "BIOS boot partition"ãæ£ããä½æåºæ¥ã¦ãããï¼
ãã¼ãã£ã·ã§ã³ãã¼ãã«ã®å 容ãå度ãã§ãã¯ãã¾ããã
- "multiple partition labels" ã¨ããã¨ã©ã¼ãåºãå ´å
以ä¸ã®ã¨ã©ã¼ãåºãå ´åã¯
grub-install: warning: Attempting to install GRUB to a disk with multiple partition labels. This is not supported yet..
# dd if=/dev/zero of=/dev/sdb seek=1 count=2047
ãå®è¡ãã¦ãã¼ãã»ã¯ã¿ãã第ä¸ãã¼ãã·ã§ã³ã¾ã§ãä¸åº¦æ¶å»ãã¾ãï¼ãã¨ã¯å度
# /usr/sbin/grub-install --target=i386-pc /dev/sdb
ãå®è¡ããã°OK
EFIç¨grub2ã®ã¤ã³ã¹ãã¼ã«
ã¾ã"EFI System"ãã¼ãã£ã·ã§ã³ã /boot/efi ã«ãã¦ã³ããã¾ã
# mkdir -p /boot/efi # mount /dev/sdb2 /boot/efi
ç¶ãã¦grub2ãã¤ã³ã¹ãã¼ã«
# /usr/sbin/grub-install --target=x86_64-efi /dev/sdb
LinuxãEFIã§èµ·åãã¦ããªãå ´åã¯ï¼ããã§
efibootmgr: EFI variables are not supported on this system. efibootmgr: EFI variables are not supported on this system.
ã¨ããè¦åãã§ã¾ã
ãã®è¦åãåºãå ´åã¯åèµ·åæã«ãã¶ã¼ãã¼ãã®BIOS/EFIã®è¨å®ç»é¢ã«è¡ãï¼ãã¼ããã¼ãã¼ã¨ãã¦grubã使ãããã«è¨å®ããå¿ è¦ãããã¾ã