Note

Some items below are collapsed, just click on them to expand.

Talk: Introduction of the LKCAMP group

(1) Where/How to make questions: establishing communication channels

Mailing lists

Why Mailing lists?

Linux development is completely centered around Mailing lists, and this is completely unlikely to change any time soon. Hence, it is extremely important that each and everyone of us become fully capable of interacting and asynchronous discussing topics via email.

The quickest way to get screamed at in a kernel related mailing list is to ignore general mailing list etiquette. Email etiquette is all about being considerate of your reader so, before ever submitting a message to a mailing list, be it lkcamp, kml or any list, make sure you understand the rules of that community.

Common mistakes with dealing with Mailing lists

Beware

If you use gmail, remember to at least use "Plain text mode" when replying. Mailing lists usually blocks formatted emails. And remember to do bottom post.

Subscribing to Mailing lists

Subscribe in the following mailing lists, click to see instructions:

kernelnewbies@kernelnewbies.org

Use this list to post questions about kernel development.

Take a look at https://kernelnewbies.org

Subscribe to the list through http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Make sure you read the kernelnewbies mailing list guidelines before submitting any message.

https://kernelnewbies.org/mailinglistguidelines

~lkcamp/discussion@lists.sr.ht

Internal list for communication of this community.

Use this list for questions which don’t fit the kernelnewbies guidelines, for questions specific to this group or for discussions about this document.

Also, when submitting questions to kernelnewbies, add this mailing list in CC to request feedback from us.

Subscribe to this list through https://lists.sr.ht/~lkcamp/discussion/

IRC Channels

Sometimes email is just too formal for simple questions. IRC offers a live chat (similar to hangouts, whatsapp or telegram).

What is IRC?

IRC is an open chat protocol, anyone can run an IRC server and provide several chat channels, which means that you need to know in advance which server you need to connect and which channels you want to join.

An introduction tutorial on IRC usage can be found at:

https://fedoramagazine.org/beginners-guide-irc

We will join the following channels:

#kernelnewbies @ irc.oftc.net

Use this channel for questions regarding kernel development (almos same rules from kernelnewbies mailing list guideline applies here. Don't be afraid to ask here, we will be monitoring this channel to help answering your questions.

#lkcamp @ irc.freenode.net

Use this channel when the question is something internal to our group or if you think that it is not fit for the #kernelnewbies

We will perform the follow 3 steps (click to expand):

Install an IRC client

Install any IRC client, there is a list here: https://kernelnewbies.org/IRC, we recommend hexchat for beginners.

Note

If you are not being able to connect due to some firewall, you can use a webclient.

Example: http://kiwiirc.com

  • Click at try me -> add network;
  • then fill just the server and the nickname (leave the rest empty);
  • then click on “Connect” at the top of the page.
  • Add a network for both server irc.freenode.net and irc.oftc.net
  • join the channels #lkcamp @ irc.freenode.net and #kernelnewbies @ irc.oftc.net.
Connect to the IRC servers irc.oftc.net and join #kernelnewbies

To connect to the irc.oftc.net server, type in the irc client:

```
/server irc.oftc.net
```

Then join the kernelnewbies channel by typing:

```
/join #kernelnewbies
```
Connect to the IRC servers irc.freenode.net and join #lkcamp

Now connect to the irc.freenode.server, type:

```
/server irc.freenode.net
```

Then join the channel:

```
/join #lkcamp
```

Then say hi in #lkcamp to complete this task ;)

Warning

Before making questions remember that people are volunteers. Being polite and showing that you did some research on the topic beforehand will help you with getting the attention from experts, for example: "I found the documentation X, but I couldn't understand Y, could someone help me by explaining what the command Z means please?"

(2) Compiling Kernel from source and running it in a virtual machine

If you are in IC labs running GNOME

Edit ~/.config/clipit/clipitrc and change history_timeout to false history_timeout = false This will enable copy and paste in your window manager.

Requirements

  • Bash
  • Python 3.3
  • Compiled kernel

When writting your own code, sometimes things goes bad and your entire system crashes, leaving you no option but to reboot your machine. To avoid messing up with your system, it is recommended to make tests in a virtual machine.

You can use virtme to achieve that.

Important

If you used a virtual machine for the previous step because and you didn't have sudo powers on your host machine, you can follow the tutorial below directly on your host machine (not in the VM) because the following instructions doesn't require root priviledges.

Install virtme as a normal user

$ pip3 install --user git+https://github.com/arighi/virtme.git
If pip3 fails...
$ cd ~/
$ git clone https://github.com/arighi/virtme.git
$ cd virtme
$ ./setup.py install --user

Getting dependencies to compile Linux Kernel

For Ubuntu 16.04, Ubuntu 18.x, Debian Jessie or Debian Stretch
apt-get -y -q install          \
  bc                           \
  flex                         \
  bison                        \
  build-essential              \
  git                          \
  libncurses-dev               \
  libssl-dev                   \
  libelf-dev                   \
  u-boot-tools                 \
  wget                         \
  xz-utils                     \
  qemu-kvm                     \
  iproute2                     \
  python3                      \
  python3-pip

The package list may be different on other Ubuntu versions, or other distributions.

For Arch Linux and derivatives (x86_64)
pacman -S base-devel git ncurses libelf uboot-tools qemu python-pip bc

Fetch the Linux Kernel repository

Note

If you are physically attending the meetings at the University of Campinas, use the /tmp folder, otherwise you probably won't have enough quota space.

$ cd /tmp
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git -b staging-testing --depth=1
$ cd staging

Tip

If the git clone is taking too long, and you are physically attending the meeting at IC, change the upstream URL to an IC mirror:

$ git clone https://gitlab.ic.unicamp.br/lkcamp/linux-staging --depth=1
$ cd linux-staging

Compile your Kernel with required modules for virtme

$ cd staging # the folder where you downloaded the kernel tree in step (2)
$ virtme-configkernel --defconfig
$ make -j$(nproc) # $(nproc) calls a command which returns an integer representing the number of cores in your machine. E.g: 8

Warning

If your terminal cannot find the virtme-configkernel, and you are in bash and have at least Python 3.3 installed, chances are that your $PATH is lacking the default python user installment location. To fix that you can run:

export PATH=${PATH}:${HOME}/.local/bin

If this solves your problem, remember to add this command to the ~/.bashrc in order to execute it every time you run bash.

echo 'export PATH=${PATH}:${HOME}/.local/bin' >> ~/.bashrc

Run your Kernel

$ virtme-run --kdir=.

Quit the virtualized environment

Type Ctrl-a followed by x.

Note

If you are using a terminal emulator which binds Ctrl-A to other command, this method will not work.

Customize your Kernel

Follow the steps from the screenshots to change the kernel version suffix!

# Change to the kernel source root directory
$ cd /tmp/staging
$ make menuconfig

Steps
  • Select General Setup Select General Setup
  • Enter into Local Version Enter into Local Version
  • Write down your kernel version suffix Write down your kernel version suffix Write down your kernel version suffix
  • Check that your suffix has been inserted into Local Version entry, then use the arrow keys to navigate to the "Save" button and type Return to save your .config Type ESC multiple times to exit
  • Type ESC multiple times to exit
$ make -j$(nproc)
$ virtme-run --kdir=.
$ uname -r

Quit the virtualized environment

Type Ctrl-a followed by x.

Done?

Congrats! You ran your own compiled kernel! \o/

Now go back to what you did and try to search more commands about your IRC client, the commands used to fetch the source code, the commands you typed, check the documentation and how it works. If you are completely done, ask on IRC if another person needs help before moving on in this guide.

Recommended reading: Chapter 1: An Introduction to Device Drivers of Linux Device Drivers 3rd, edition https://lwn.net/Kernel/LDD3/ .

Don’t forget to update the spreadsheet for tracking our progress.

(Extra) Booting the kernel on your own machine

Click here if you don't have sudo powers

Since there is no sudo power, we need to run a virtual machine. You can just install a distro inside a virtual machine and proceed with the tutorial. But to save some time, we prepared an image for you already:

Note

If you are physically attending the meetings at the University of Campinas, use the /tmp folder, otherwise you won't have enough quota space.

$ cd /tmp
$ wget https://gitlab.com/lkcamp/binaries/raw/master/virtual_machine/faime-L4PAWK44.qcow2
$ qemu-kvm -hda faime-L4PAWK44.qcow2 -m 4G -smp 4 -net nic -net user,hostfwd=tcp::5555-:22 # the password is debian

Warning

The root password of the virtual machine is debian

The hostfwd command is to allow you to access the virtual machine by ssh (to make it easier to copy & paste commands):

ssh -p 5555 debian@localhost # the password is debian

Now, proceed with the tutorial below as if the VM was your physical machine.

Click here if you use Arch Linux

Warning

Some people had issues when trying to boot the custom kernel in Arch Linux in encrypted disks.

Arch Linux users might have some problems following the steps described in the module. In summary to compile the kernel on Arch Linux you will need (assuming you have the kernel source and cd into that directory):

$ zcat /proc/config.gz > .config  # get the .config of your current installed kernel
$ make menuconfig                 # (or any alternative if you want to build a custom kernel)
$ make -jN                        # where N is the number of parallel jobs
$ make modules install

NAME is the name you will give to your kernel

$ cp -v arch/x86_64/boot/bzImage /boot/vmlinuz-NAME</code>

The kernelversion will be the same as the name of the custom kernel source directory (and the modules directory for it, located in /usr/lib/modules/).

$ mkinitcpio -k &lt;kernelversion&gt; -g /boot/initramfs-&lt;file name&gt;.img
$ grub-mkconfig -o /boot/grub/grub.cfg

For more information please check: https://wiki.archlinux.org/index.php/Kernel/Traditional_compilation

Warning

To issue sudo commands with the debian user, you must transform it into a sudoer:

su -c 'usermod -aG sudo debian'
exit # Logoff
And then logon again.

Next steps

Proceed with the tutorial in the kernelnewbies page below from session Install some packages to Running your kernel.

https://kernelnewbies.org/OutreachyfirstpatchSetup

Note

While you wait for the kernel to download and compile, start reading the book Linux Device Drivers at the link below:

http://lwn.net/Kernel/LDD3/

Don't be afraid to ask questions at #kernelnewbies or #lkcamp, we'll be there to help.