<Linux> 制作minimal amd64 Linux OS

本文详细介绍了如何在VirtualBox中使用Ubuntu 16.04 Server环境,从搭建虚拟机、磁盘挂载、分区、安装GRUB到复制内核文件、创建文件系统,以及测试和验证自制作的最小Linux操作系统的过程。
摘要由CSDN通过智能技术生成
选择步骤1(ubuntu B)创建的磁盘;

1,搭建环境

在virtualbox创建一个Ubuntu 64的虚拟机,磁盘2G即可,其它参数默认,后称Ubuntu B;

2,挂在磁盘

在virtualbox已安装Ubuntu 16.04 server的虚拟机中(后称Ubuntu A)挂载步骤1的磁盘,步骤如下:

设置-->Storage --> Controller: SATA --> Adds Hard disk -->选择步骤1(ubuntu B)创建的磁盘;

3,磁盘分区

启动Ubuntu A,查看磁盘情况:

phoebus@ubuntu:~$ ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5  /dev/sdb

可以看到,我们添加的Ubuntu B的磁盘在这里是/dev/sdb,我们对它进行分区(1个区):

phoebus@ubuntu:~$ sudo fdisk /dev/sdb
[sudo] password for phoebus:

Welcome to fdisk (util-linux 2.27.1).
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 disklabel with disk identifier 0x9dea8caa.

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-4194303, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-4194303, default 4194303):

Created a new partition 1 of type 'Linux' and of size 2 GiB.

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

phoebus@ubuntu:~$

4,安装grub

a,把/dev/sdb1格式化为ext4

phoebus@ubuntu:~$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 524032 4k blocks and 131072 inodes
Filesystem UUID: e5b6c7af-d316-4082-99a4-7f322363c0e6
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

phoebus@ubuntu:~$

b,挂载/dev/sdb1到/mnt

sudo mount /dev/sdb1 /mnt/

c,安装grub

phoebus@ubuntu:~$ sudo grub-install --root-directory=/mnt /dev/sdb
Installing for i386-pc platform.
Installation finished. No error reported.
phoebus@ubuntu:~$

5,添加grub.cfg

a,复制ubuntu的grub.cfg

sudo cp /boot/grub/grub.cfg /mnt/boot/grub/

b,修改uuid

查看uuid

phoebus@ubuntu:~$ ll /dev/disk/by-uuid/
total 0
drwxr-xr-x 2 root root 100 Jun 24 11:35 ./
drwxr-xr-x 5 root root 100 Jun 24 11:27 ../
lrwxrwxrwx 1 root root  10 Jun 24 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值