使用下载Ubuntu Desktop ISO镜像(32位64位都可以)。 用光驱启动,选择试用Ubuntu。
访问:http://cdimage.ubuntu.com/ubuntu-core/releases/找到所需要的镜像文件。
使用Ubuntu LiveCD,下载所需镜像到home目录
wget http://cdimage.ubuntu.com/ubuntu-core/releases/14.04.1/release/ubuntu-core-14.04.1-core-i386.tar.gz ~/
-
分区
这个基本上不用说。我这里用的是虚拟机,只有一个硬盘。 这里只演示将Ubuntu安装到一个分区
-
格式化分区
sudo mkfs -t ext4 /dev/sda -
创建挂在目录
sudo mkdir /mnt/root -
挂载分区
sudo mount /dev/sda /mnt/root -
解压ubuntu-core
cd /mnt/root sudo tar zxvf ~/ubuntu-core-14.04.1-core-i386.tar.gz -
挂载dev和proc目录
sudo mount --bind /dev /mnt/root/dev sudo mount --bind /proc /mnt/root/proc不挂载这两个,会无法安装引导和内核。
其实不挂载也可以。只要将
/proc/cpuinfo复制到/mnt/root/proc下,就可以安装内核,然后用live cd来修复引导。 -
添加 修改
/mnt/root/etc/resolv.conf文件,增加以下内容nameserver 223.5.5.5 nameserver 223.6.6.6不进行这一步,系统无法联网。
-
修改源(可选) 修改
/etc/apt/sources.list文件,替换为以下内容。这里是14.04的阿里云源。deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse -
修改hosts文件(可选)
修改
/etc/hosts增加以下内容127.0.0.1 localhost -
修改主机名(可选)
修改
/etc/hostname为你喜欢的内容 -
安装内核
用chroot进入新的系统
sudo chroot /mnt/root apt-get update apt-get install linux-generic这你会安装引导和内核。
-
安装SSH(可选)
apt-get install openssh-server默认情况下SSH Server不允许使用root登录,需要进行修改。
修改
/ect/ssh/ssd_config,大概在28行左右有PermitRootLogin without-password改成PermitRootLogin yes -
设置用户等信息
设置root密码
passwd root -
卸载分区,重启
然后喜欢怎么折腾就怎么折腾吧
如果新系统不能上网 运行 /usr/lib/klibc/bin/ipconfig eth0 就可以上网了。但是重启之后还是不能上网。
可以修改/etc/network/interfaces修复这个问题
向这个文件增加以下内容,这样第一张网卡可以从DHCP服务器中获取IP地址
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
这里以64位系统为例子,32位Docker需要自己编译源码
直接从Docker官网给出的Ubuntu安装方法安装
curl -sSL https://get.docker.com/ubuntu/ | sudo sh
但是这样安装完之后是不能启动Docker的守护程序。
-
增加内核对Docker的支持
Ubuntu默认是使用GRUB,这里我们就以GRUB为例子。
首先我们修改下
/etc/default/grub这个文件。找到GRUB_CMDLINE_LINUX=""这一行,然后修改为:
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"保存文件。然后执行
sudo update-grub,完成后重启系统sudo reboot -
解决 apparmor 的问题
sudo apt-get install apparmor -
重启
-
测试是否成功
sudo docker run -i -t ubuntu /bin/bash执行之后会自动下载
ubuntu镜像, 然后会在容器里开启一个bash
上面第七步给出的nameserver好像没有,改为下面的可以正常更新
第八步应该是
/mnt/root/etc/apt/sources.list