
Toucan Linux Project
A Roll Your Own Distribution
Goal 1 – Base System
Stage 1 – Building the Tool Chain
Step 1 - Host OS Boot Device (ldd, mount, /dev/loop, dd)
The easiest way to start building from scratch is using an already built OS. That is a luxury most of us have always know because it allows us to use another OS to build ours instead of first building a boot loader to even boot our OS. Lucky us.We’ll use MX Linux with is a smaller light weight version of Linux. It’s small enough to be an easy download, but large enough to contain all the tools we need. Specifically we need a C tool chain using GCC. First you’ll need to make a bootable USB or SD of MX Linux. Download it at https://mxlinux.org/download-links/ and make sure you get a release of 18.3 or higher. While it isn’t essential that you use MX Linux for the host, it’ll be up to you to figure out how to accomplish the same thing.
Now make a bootable USB using another system. It’s very easy and if you don’t already know how to do this, then this project may not be for you. The file I downloaded was named: MX-18.3_x64.iso. If you want to first check the contents of this ISO, use a loop back mount on the command line like this (you’ll need to be the root user for most systems):
$ mkdir /mnt/iso && mount MX-18.3_x64.iso /mnt/iso
If you’re system doesn’t support auto-mounting a file you might need to do this:
$ mkdir /mnt/iso && mount -t iso MX-18.3_x64.iso -o loop
So, to our first question in our learning project: why? In the second version mount has not been linked against libblkid.so. This library is part of the util-linux package and it is used to identify a block device using various methods. When no type is specified for the mount command, mount will use /etc/fstab to try to determine the file system type. If that fails it will use libblkid to probe the device in an effort to determine what the file system is on that device contains. The newest version of mount will automatically use libblkid on a file to try to determine what it contains. You can see if your mount program supports libblkid using ldd (list dynamic dependencies):
$ ldd /bin/mount
linux-vdso.so.1 (0x00007ffeae7de000libmount.so.1 => /lib64/libmount.so.1 (0x00007f909c277000)libblkid.so.1 =>/lib64/libblkid.so.1 (0x00007f909c240000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f909c237000)
librt.so.1 => /lib64/librt.so.1 (0x00007f909c22d000)
libc.so.6 => /lib64/libc.so.6 (0x00007f909c061000)
/lib64/ld-linux-x86-64.so.2 (0x00007f909c2f9000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f909c03f000)
If libblkid.so.1 shows up in the list of required libraries, then your mount program is set to use it. You can use the command blkid to list all block devices as found and probed with libblkid but only as the root user.
Now once mounted you can browse through the /mnt/iso directory structure to view what is in the ISO file. Once you’ve satisfied your curiosity unmount it with:
$ umount /mnt/iso
and plugin the USB or SD drive you intend to use to install MX Linux. Most versions of Linux will auto-mount the device, but we can’t have it mounted. After it is plugged in and settled, unmount all partitions mounted and note the device. If nothing mounts (there is no file system on the drive) you can use dmesg to see where it mounted. Run dmesg with the -w switch which will print new lines as they are added to the system log:
$ dmesg -w [ 9881.049844] usb 1-1: new high-speed USB device number 6 using xhci_hcd
[ 9881.177809] usb 1-1: New USB device found, idVendor=154b, idProduct=007a, bcdDevice=11.00
[ 9881.177816] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 9881.177820] usb 1-1: Product: USB 2.0 FD
[ 9881.177823] usb 1-1: Manufacturer: PNY Technologies
[ 9881.177825] usb 1-1: SerialNumber: AEB05H12YE07001486
[ 9881.179448] usb-storage 1-1:1.0: USB Mass Storage device detected
[ 9881.180076] scsi host3: usb-storage 1-1:1.0
[ 9881.726618] usbcore: registered new interface driver uas
[ 9882.413526] scsi 3:0:0:0: Direct-Access PNY USB 2.0 FD 1100 PQ: 0 ANSI: 4
[ 9882.414194] sd 3:0:0:0: Attached scsi generic sg2 type 0
[ 9882.414715] sd 3:0:0:0: [sdc] 31405824 512-byte logical blocks: (16.1 GB/15.0 GiB)
[ 9882.415219] sd 3:0:0:0: [sdc] Write Protect is off
[ 9882.415223] sd 3:0:0:0: [sdc] Mode Sense: 43 00 00 00
[ 9882.415790] sd 3:0:0:0: [sdc] No Caching mode page found
[ 9882.415802] sd 3:0:0:0: [sdc] Assuming drive cache: write through
[ 9882.419279] sdc: sdc1 sdc2
[ 9882.421828] sd 3:0:0:0: [sdc] Attached SCSI removable disk
[ 9882.615922] ISO 9660 Extensions: Microsoft Joliet Level 3
[ 9882.618151] ISO 9660 Extensions: Microsoft Joliet Level 3
[ 9882.619293] ISO 9660 Extensions: RRIP_1991A
Here you can see /dev/sdc was used for the device. Since we are preparing to overwrite the contents of the device, we really need to get it right. Once you are absolutely sure, do the following to image the USB or SD drive with the MK Linux image:
$ dd if=MX-18.3_x64.iso of=/dev/sdX bs=4M status=progress && sync
being sure to replace /dev/sdX with the proper device (/dev/sdc for me). When it completes you are ready to boot MX from the device.
Step 2 – Boot into the Host and Set Display (xrandr)
Depending on your system, you might need to enter the BIOS setup screen, or hold down a certain key (ESC, F2, F12 are some) during system startup to bring up the boot selection. This is generally accomplished by inserting the boot media (USB or SD), booting, and bringing up the boot menu, then choosing the proper device. Skip this step if you are using a different host and don’t want to learn about controlling your display through the command line. You’ll see something like this:
Notice right away that everything is very small. The default resolution of my video card for the video screen on my laptop is 3840 x 2160. Maybe that would have worked for me when I was twenty-five, but, well...let’s just say not anymore. You can open the menu at the far bottom left, choose Settings and then Display to change the resolution. I went with 1920 x 1080 to get this display:

Like all things, you can use the command line as well, and since we are here to learn we might as well know how to do it. Choose Terminal from the menu to launch the most powerful tool available, a command shell. Now we can use a tool called xrandr which is a command line tool to control the X Rotation and Resize extension (RandR). With xrandr you can resize, rotate, and reflect screens, control two video cards, send the output of one video device to be render with another (source->sink), modify the gamma level, and even setup panning. The simplest way to change the display resolution to something you can see is using the dpi switch. The fonts set in the user interface for most tool kits is designed to be viewed at 96 DPI (dots per inch). You can easily change that using the following command:
$ xrandr --dpi 96
But like most systems designed to be open not all video drivers will support that. One such notable driver is nVidia’s proprietary graphics driver (currently Intel, too). For these drivers you must choose a resolution and refresh rate. To do this, run xrandr with no command line options:
$ xrandr
Screen 0: minimum 320 x 200, current 2880 x 1620, maximum 8192 x 8192
eDP-1 connected primary 2880x1620+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
3840x2160 60.00 + 59.98 59.97
3200x1800 59.96 59.94
2880x1620 59.96* 59.97
2560x1600 59.99 59.97
2560x1440 59.99 59.99 59.96 59.95
2048x1536 60.00
1920x1440 60.00
1856x1392 60.01
1792x1344 60.01
2048x1152 59.99 59.98 59.90 59.91
1920x1200 59.88 59.95
1920x1080 60.01 59.97 59.96 59.93
1600x1200 60.00
1680x1050 59.95 59.88
1400x1050 59.98
1600x900 59.99 59.94 59.95 59.82
1280x1024 60.02
1400x900 59.96 59.88
1280x960 60.00
1440x810 60.00 59.97
1368x768 59.88 59.85
1280x800 59.99 59.97 59.81 59.91
1280x720 60.00 59.99 59.86 59.74
1024x768 60.04 60.00
960x720 60.00
928x696 60.05
896x672 60.01
1024x576 59.95 59.96 59.90 59.82
960x600 59.93 60.00
960x540 59.96 59.99 59.63 59.82
800x600 60.00 60.32 56.25
840x525 60.01 59.88
864x486 59.92 59.57
700x525 59.98
800x450 59.95 59.82
640x512 60.02
700x450 59.96 59.88
640x480 60.00 59.94
720x405 59.51 58.99
684x384 59.88 59.85
640x400 59.88 59.98 640x360 59.86 59.83 59.84 59.32
512x384 60.00
512x288 60.00 59.92
480x270 59.63 59.82
400x300 60.32 56.34
432x243 59.92 59.57
320x240 60.05
360x202 59.51 59.13
320x180 59.84 59.32
HDMI-1 disconnected (normal left inverted right x axis y axis)
This shows the available options for resolution and refresh for each of the interfaces on my system. I have one called eDP-1 which is my laptop screen. Following it are all the modes supported by my driver (far left column) and all the possible refresh rates for each resolution (listed in columns to the right of the resolution). Finally it shows the HDMI-1 interface also but has no options since it is disconnected.
When I first started using Linux my available resolution was 640x480 with only sixteen colors (good old VGA) but I think I’d much rather have a bit more resolution. To set it for 1920 x 1080 with a fresh rate of 60.01 I use the following
xrandr -s 1920x1080 -r 60
which uses the size switch (-s or --size) to select one of the available modes and the refresh (-r or –rate) to 60 for the primary display. If for some reason you have two displays, you might need to specify which one using the --output option which is followed by the name of the display:
xrandr –output eDP-1 -s 1920x1080 -r 60
Now I have something workable. Whether or not this step is necessary depends on your hardware. If everything is very small, this is the answer.
Next in Stage 1, Step 3 we’ll identify and partition the disk.
Copyright (C) 2019 by Michael R Stute
No comments:
Post a Comment