Professional Documents
Culture Documents
All streams Development Administrating Design Management Marketing PopSci Log in Sign up
Tutorial
Intro
PXE is a great solution for booting a diskless computer (or a computer without an OS installed). This method is often used for terminal
stations and OS mass installation.
Stock ubuntu (16.04) in pxe-mode can mount rootfs only from NFS. But this is not a great idea: any difficulties with the network/NFS
server and the user gets problems.
In my opinion, it's best to use other protocols, such as http/ftp. Once booting, you will have an independent system
You should add information about the limits of applicability of the proposed solution and what are the dependencies and restrictions.
The dhcp server sends TFTP server address and the filename to upload
The computer downloads this file from the tftp server. Its size is limited so, often, it's a bootloader like pxeinux
pxelinux reads its own config and downloads Linux kernel using initramfs
Keep in mind that TFTP is a slow protocol. It works around UDP with a small block size (512K). Of course, you can increase this value, but
this is a way of unstable operation.
A better solution:
How i do it
Steps to solve the task:
https://habr.com/en/post/513568/ 1/6
8/15/2020 Boot Ubuntu via http/ftp server with pxe(diskless boot) / Habr
6. Run it
I used squashfs for rootfs (the simplest way is to create squashfs from installed ubuntu). Overlayfs is necessary to make rootfs writable.
Supported protocols are http/ftp, but you can try to add others via curl/other software.
Customize initramfs
There are 2 places where you can customize initramfs in ubuntu:
/etc/initramfs-tools
/usr/share/initramfs-tools/
# run udevadm
wait_for_udev 10
https://habr.com/en/post/513568/ 2/6
8/15/2020 Boot Ubuntu via http/ftp server with pxe(diskless boot) / Habr
while [ ! -f ${squashfsFile} ] && [ ${tryCount} -le ${maxTryCount} ]; do
wget ${rooturl} -O ${squashfsFile} || log_failure_msg "Can't download rootfs, count ${tryCount}"
tryCount=$(( ${tryCount} + 1 ))
sleep 0.5
done
if [ -f ${squashfsFile} ]
then
log_success_msg "Rootfs downloaded"
else
panic "Can't download rootfs"
fi
After the modules and script, add your need to generate new initramfs:
Creating squashfs
The simplest method:
I don't recommend this way for production since you'll have a very large squashfs (not the best idea for pxe)!
https://habr.com/en/post/513568/ 3/6
8/15/2020 Boot Ubuntu via http/ftp server with pxe(diskless boot) / Habr
vmlinuz is kernel
Bootloader config:
LABEL ubuntu_pxe
menu label Run ubuntu pxe
kernel vmlinuz
append initrd=initrd rooturl=http://192.168.56.2/ubuntu/firmware.sq boot=pxe maxTryCount=10
https://habr.com/en/post/513568/ 4/6
8/15/2020 Boot Ubuntu via http/ftp server with pxe(diskless boot) / Habr
# Important! Set bootloader file
filename "ubuntu/pxelinux.bin";
}
The extended variant (if the dhcp and tftp servers placed on different machines) requires the next-server option for dhcp.
Conclusion
This article shows you how to change the boot mode of ubuntu without any difficulties. Use it as information and write your solutions.
This can be a system in the form of firmware (with squashfs), pxe, or another solution.
Tags: linux, ubuntu, pxe, pxeboot, linux kernel, development, overlayfs, diskless, firmware
+6 9 726 3 Share
19.0 4.8
Karma Rating
@ Boozlachu
Пользователь
Medium
SIMILAR POSTS
Writing a laptop driver for fun and profit, or How to commit to kernel even if you're not that smart
+5 1k 0 0
Ads
Comments 3
I guess LTSP is a complete solution for network boot. But in my practice wa are don works without it.
My article is more than pxe tutorial. I tried to show how to customize ubuntu boot to use ubuntu as firmware from squashfs. PXE is only one
of variant
https://habr.com/en/post/513568/ 5/6
8/15/2020 Boot Ubuntu via http/ftp server with pxe(diskless boot) / Habr
In addition, LTSP uses the nfs / nbd protocol. I don't like when network connection dependencies work on my system.
HTTP and FTP allows booting ALL systems from rootfs to my client. Then my system will be offline.
Only users with full accounts can post comments. Log in, please.
TOP POSTS
Audio over Bluetooth: most detailed information about profiles, codecs, and devices
+22 112k 10 8
Terms of service
https://habr.com/en/post/513568/ 6/6