Original writeup here (with some bugs corrected):
http://bluequiet.blogspot.com/2017/09/building-ubuntu-rootfs-for-arm.html
But the steps is applicable to any hardware: i386, amd64, ppc, arm, mips etc.
First download the Ubuntu base from here (here we assumed for amd64, but you can always download images for other platform and :
http://cdimage.ubuntu.com/cdimage/ubuntu-base/releases//18.04/release/
Next is to create the rootfs image:
Some repetition may be needed here (until you get the size right). By that I mean the the “apt-get install” command below can be successfully executed – to include all the basic debian packages.
For Ubuntu 18.04 amd64, the estimated required size is about 1G.
So create a 1G rootfs empty image:
sudo dd if=/dev/zero of=rootfs.img bs=1024 count=1M
sudo mkfs.ext4 -F -L linuxroot rootfs.img
sudo mkdir /mnt/tmpdir
sudo mount -o loop rootfs.img /mnt/tmpdir
sudo tar zxvf ubuntu-*.tar.gz -C /mnt/tmpdir #### (unpacking the tar.gz file downloaded from cdimage.ubuntu.com above).
sudo cp /etc/resolv.conf /mnt/tmpdir/etc/
sudo mount -t proc /proc /mnt/tmpdir/proc
sudo mount -t sysfs /sys /mnt/tmpdir/sys
sudo mount -o bind /dev /mnt/tmpdir/dev
sudo mount -o bind /dev/pts /mnt/tmpdir/dev/pts
sudo chroot /mnt/tmpdir
Inside the chroot environment (“sudo” does not exists in ubuntu base):
apt-get update
apt-get install \
language-pack-en-base \
sudo \
ssh \
net-tools \
ethtool \
wireless-tools \
ifupdown \
network-manager \
iputils-ping \
rsyslog \
htop \
vim \
xinit xorg \
alsa-utils \
--no-install-recommends
Inside the rootfs:
useradd username ###and remember to set the password as well
You may want to setup root password as well, just in case you may be interested in going as root, as “sudo” is not configured by default.
Set up hostname:
echo "myhost" > /etc/hostname
Inside /etc/hosts:
127.0.0.1 localhost
127.0.0.1 myhost
##//Make X used by ‘anyuser’: /etc/X11/Xwrapper.config
allowed_users=anybody
##//set up timezone
dpkg-reconfigure tzdata
##//set up group for alsa : /etc/group
audio:x:29:pulse,username
##// Set up group for fbterm: /etc/group
video:x:44:username
sudo umount /mnt/tmpdir/proc
sudo umount /mnt/tmpdir/sys
sudo umount /mnt/tmpdir/dev/pts
sudo umount /mnt/tmpdir/dev
Assuming the present rootfs image is named as “rootfs.img”:
rootfs=rootfs.img
append="root=/dev/sda console=ttyS0"
Booting up in the latest kernel I have compiled:
kernel=vmlinuz-5.5.0-rc7+
initrd=initrd.img-5.5.0-rc7+
qemu-system-x86_64 -m 1024M -nographic -kernel $kernel -append "$append" -hda $rootfs -net nic
The output of the bootup is as follows:
You must be logged in to post a comment.