Skip to content

Instantly share code, notes, and snippets.

@fragmede
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fragmede/589cf47a2a3380459266 to your computer and use it in GitHub Desktop.
Save fragmede/589cf47a2a3380459266 to your computer and use it in GitHub Desktop.
FROM ubuntu:15.04
MAINTAINER samson_gh@onepatchdown.net
# Hello,
# My goal for this was to build overlayfs for 3.10.82 so that overlayroot can
# be used for an Odroid with Ubuntu to have a read-only root. Unfortunately I
# ran out of time. This Dockerfile creates an overlayfs.ko that fails to load
# because the kernel also needs to be updated.
#
# You'll need to actually read this Dockerfile before being able to run it
# since it relies on files I haven't included.
#
# Once you have those files, you can do:
# docker build -t odroid-kernel-docker .
# which builds the module.
#
# In order to actually get the module out of the container, do:
# docker run --rm --volume `pwd`:/tmp -ti odroid-kernel-docker
# and the Dockerfile will make a subdirectory called overlayfs in your current
# dir. (Owned by root, unfortunately.)
#
# To setup cross-compiling, I'm follwing the guide at
# http://odroid.com/dokuwiki/doku.php?id=en:xu3_building_kernel since
# Hardkernel is sharing their binaries.
#
# The Dockerfile 'ADD' URL cache wasn't working, so I downloaded the files
# manually.
#
# The resulting overlayfs.ko file fails to
# load due to missing systems from the higher fs/ directory.
#
# [ 2867.680322] [c6] overlayfs: Unknown symbol clone_private_mount (err 0)
# [ 2867.680369] [c6] overlayfs: Unknown symbol __inode_permission (err 0)
# [ 2867.680419] [c6] overlayfs: Unknown symbol do_splice_direct (err 0)
# [ 2867.680506] [c6] overlayfs: Unknown symbol vfs_open (err 0)
# [ 2915.554977] [c6] overlayfs: Unknown symbol clone_private_mount (err 0)
# [ 2915.555024] [c6] overlayfs: Unknown symbol __inode_permission (err 0)
# [ 2915.555072] [c6] overlayfs: Unknown symbol do_splice_direct (err 0)
# [ 2915.555160] [c6] overlayfs: Unknown symbol vfs_open (err 0)
#
# The Odroid isn't mine so I have limited remote access to it. This script
# builds a patched kernel that should work with the built overlayfs module.
#
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get install -y build-essential
RUN apt-get install -y bc
RUN mkdir -p /opt/toolchains
# From http://dn.odroid.com/ODROID-XU/compiler/arm-eabi-4.6.tar.gz
#ADD http://dn.odroid.com/ODROID-XU/compiler/arm-eabi-4.6.tar.gz
COPY arm-eabi-4.6.tar.gz /opt/
RUN tar -xzf /opt/arm-eabi-4.6.tar.gz -C /opt/toolchains/
ENV ARCH=arm
ENV CROSS_COMPILE=arm-eabi-
ENV PATH=/opt/toolchains/arm-eabi-4.6/bin:$PATH
# Just a quick sanity test
#RUN arm-eabi-gcc -v
# Rather than download zipped kernel source from github, I created it locally
# since I already have the linux git tree set up localy.
# They should be equivalent at this point in time.
# The command I used locally to create the file was:
# git archive odroid/odroidxu3-3.10.y \
# --format tgz --prefix linux-2.6/ \
# -o ~/projects/odroid/linux-2.6-odroid-3.10.82-ee1b0014142a.tgz
#
#ADD https://github.com/hardkernel/linux/archive/odroidc-3.10.y.zip /opt/
#RUN apt-get install -y unzip
#RUN cd /opt; unzip odroid-3.10.y.zip
ADD linux-2.6-odroid-3.10.82-ee1b0014142a.tgz /opt/
# mszeredi has a version of overlayfs for 3.10 but it wasn't merged,
# git diff 9e895ace5d82df8929b16f58e9f515f6d54ab82d..mszeredi-vfs/overlayfs.v18 > overlayfs.v18.patch
ADD overlayfs.v18.patch /opt/linux-2.6/
WORKDIR /opt/linux-2.6
RUN patch -p0 < overlayfs.v18.patch
RUN make odroidxu3_defconfig
# Force overlayfs.ko to be made.
RUN echo CONFIG_OVERLAYFS_FS=m >> .config
RUN make prepare
RUN make scripts
#RUN make zImage
#RUN make modules
RUN make M=fs/overlayfs/
#RUN make M=fs/
RUN mkdir /tmp/overlayfs
CMD mkdir /tmp/overlayfs && cp fs/overlayfs/*.ko /tmp/overlayfs/
FROM ubuntu:15.04
MAINTAINER samson_gh@onepatchdown.net
LABEL Build overlayfs for 3.10.82 Odroid kernel.
# Hello,
# My goal for this was to build overlayfs for 3.10.82 so that overlayroot can
# be used for an Odroid with Ubuntu to have a read-only root. Unfortunately I
# ran out of time. This Dockerfile creates an overlayfs.ko that fails to load
# because the kernel also needs to be updated.
#
# You'll need to actually read this Dockerfile before being able to run it
# since it relies on files I haven't included.
#
# Once you have those files, you can do:
# docker build -t odroid-kernel-docker .
# which builds the module.
#
# In order to actually get the module out of the container, do:
# docker run --rm --volume `pwd`:/tmp -ti odroid-kernel-docker
# and the Dockerfile will make a subdirectory called overlayfs in your current
# dir. (Owned by root, unfortunately.)
#
# To setup cross-compiling, I'm follwing the guide at
# http://odroid.com/dokuwiki/doku.php?id=en:xu3_building_kernel since
# Hardkernel is sharing their binaries.
#
# The Dockerfile 'ADD' URL cache wasn't working, so I downloaded the files
# manually.
#
# The resulting overlayfs.ko file fails to
# load due to missing systems from the higher fs/ directory.
#
# [ 2867.680322] [c6] overlayfs: Unknown symbol clone_private_mount (err 0)
# [ 2867.680369] [c6] overlayfs: Unknown symbol __inode_permission (err 0)
# [ 2867.680419] [c6] overlayfs: Unknown symbol do_splice_direct (err 0)
# [ 2867.680506] [c6] overlayfs: Unknown symbol vfs_open (err 0)
# [ 2915.554977] [c6] overlayfs: Unknown symbol clone_private_mount (err 0)
# [ 2915.555024] [c6] overlayfs: Unknown symbol __inode_permission (err 0)
# [ 2915.555072] [c6] overlayfs: Unknown symbol do_splice_direct (err 0)
# [ 2915.555160] [c6] overlayfs: Unknown symbol vfs_open (err 0)
#
# The Odroid isn't mine so I have limited remote access to it. This script
# builds a patched kernel that should work with the built overlayfs module.
#
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get install -y build-essential
RUN apt-get install -y bc
RUN mkdir -p /opt/toolchains
# From http://dn.odroid.com/ODROID-XU/compiler/arm-eabi-4.6.tar.gz
#ADD http://dn.odroid.com/ODROID-XU/compiler/arm-eabi-4.6.tar.gz
COPY arm-eabi-4.6.tar.gz /opt/
RUN tar -xzf /opt/arm-eabi-4.6.tar.gz -C /opt/toolchains/
ENV ARCH=arm
ENV CROSS_COMPILE=arm-eabi-
ENV PATH=/opt/toolchains/arm-eabi-4.6/bin:$PATH
# Just a quick sanity test
#RUN arm-eabi-gcc -v
# Rather than download zipped kernel source from github, I created it locally
# since I already have the linux git tree set up localy.
# They should be equivalent at this point in time.
# The command I used locally to create the file was:
# git archive odroid/odroidxu3-3.10.y \
# --format tgz --prefix linux-2.6/ \
# -o ~/projects/odroid/linux-2.6-odroid-3.10.82-ee1b0014142a.tgz
#
#ADD https://github.com/hardkernel/linux/archive/odroidc-3.10.y.zip /opt/
#RUN apt-get install -y unzip
#RUN cd /opt; unzip odroid-3.10.y.zip
ADD linux-2.6-odroid-3.10.82-ee1b0014142a.tgz /opt/
# mszeredi has a version of overlayfs for 3.10 but it wasn't merged,
# git diff 9e895ace5d82df8929b16f58e9f515f6d54ab82d..mszeredi-vfs/overlayfs.v18 > overlayfs.v18.patch
ADD overlayfs.v18.patch /opt/linux-2.6/
WORKDIR /opt/linux-2.6
RUN patch -p0 < overlayfs.v18.patch
RUN make odroidxu3_defconfig
# Force overlayfs.ko to be made.
RUN echo CONFIG_OVERLAYFS_FS=m >> .config
RUN make prepare
RUN make scripts
#RUN make zImage
#RUN make modules
RUN make M=fs/overlayfs/
#RUN make M=fs/
RUN mkdir /tmp/overlayfs
CMD mkdir /tmp/overlayfs && cp fs/overlayfs/*.ko /tmp/overlayfs/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment