0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【ゼロからのOS自作入門】Day00-Day01

Last updated at Posted at 2024-12-29

ゼロからのOS自作入門を、読み始めました。

Cは参考書を読んだ程度、C++は勉強も触ったこともなく、最後まで実施できる自信はないですが、なんとか頑張ってみます。

Day00とDay01はなんなく進められましたね。
私は、VirtualBoxで実行しました。
ChatGPTを使いながら、Rustでも書いてみましたが、うまくいきませんでした。
ビルドでは、エラーがでなかったのですが。。。
スクリーンショット 2024-12-29 140530.png

以下は、VirtualBoxの仮想マシンを作成から、起動までのコマンドになります。

# 仮想マシンを作成
VBoxManage createvm --name "HelloWorld" --register

VBoxManage createhd --filename "C:\Users\mniyk\VirtualBox\HelloWorld\HelloWorld.vdi" --size 1024

VBoxManage modifyvm "HelloWorld" --firmware efi

VBoxManage storagectl "HelloWorld" --name "SATA Controller" --add sata --controller IntelAhci

VBoxManage storageattach "HelloWorld" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "C:\Users\mniyk\VirtualBox\HelloWorld\HelloWorld.vdi"

# VDIにEFIをコピー
sudo modprobe nbd

sudo qemu-nbd --connect=/dev/nbd0 /mnt/c/Users/mniyk/VirtualBox/HelloWorld/HelloWorld.vdi

❯ sudo fdisk /dev/nbd0
Welcome to fdisk (util-linux 2.39.3).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS (MBR) disklabel with disk identifier 0x6ea7a64e.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-2097151, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-2097151, default 2097151):

Created a new partition 1 of type 'Linux' and of size 1023 MiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

❯ sudo fdisk -l /dev/nbd0
Disk /dev/nbd0: 1 GiB, 1073741824 bytes, 2097152 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: 0x6ea7a64e

Device      Boot Start     End Sectors  Size Id Type
/dev/nbd0p1       2048 2097151 2095104 1023M 83 Linux

sudo apt install dosfstools

sudo mkfs.vfat /dev/nbd0p1

❯ sudo fsck /dev/nbd0p1
fsck from util-linux 2.39.3
fsck.fat 4.2 (2021-01-31)
/dev/nbd0p1: 0 files, 1/261367 clusters

sudo mkdir -p /mnt/nbd

sudo mount /dev/nbd0p1 /mnt/nbd

sudo mkdir -p /mnt/nbd/EFI/Boot

sudo cp /mnt/c/Users/mniyk/VirtualBox/HelloWorld/BOOTX64.EFI /mnt/nbd/EFI/Boot/bootx64.efi

sudo umount /mnt/nbd

sudo qemu-nbd --disconnect /dev/nbd0

# 仮想マシンの起動
VBoxManage startvm "HelloWorld" --type gui
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?