A Quantum Engineering Focused Linux Distro From Scratch — Day 2

Marcus Edwards
9 min readJan 9, 2023

--

I am diving back into setting up my host system for developing a LFS distro for quantum engineering. That means I need to get the packages listed here installed on my Lubuntu host machine.

The first issue was resolved by a little reading. In version 6.10, Ubuntu swapped out bash for dash, which is smaller but more efficient. Think of it like nano is to vim. You can swap the /bin/sh link to dash for a link to bash, but I opted not to do that.

ERROR: /bin/sh does not point to bash

I ran into an issue with dpkg when I tried to install bison. What?

marcuse@redblue:~$ sudo apt-get install bison

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

dpkg is the Debian package manager that underlies apt-get, not unlike I suppose Debian underlies Ubuntu. You might be familiar with other Debian-based Linux distros like Raspbian.

I was able to solve my issue with the help of an Ask Ubuntu thread which allowed dpkg to finishing setting up and processing triggers for all of my packages. It had been interrupted by who knows what. However, I was warned of possible missing gpu-related firmware in /lib/firmware/amdgpu. My monitor works fine so I am continuing on, but this could be our first amd related hiccup?

W: Possible missing firmware /lib/firmware/amdgpu/yellow_carp_gpu_info.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/vangogh_gpu_info.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_rlc.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_mec2.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_mec.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_me.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_pfp.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_ce.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_sdma1.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_sdma.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/sienna_cichlid_mes.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/navi10_mes.bin for module amdgpu
update-initramfs: Generating /boot/initrd.img-5.15.0-52-generic
W: Possible missing firmware /lib/firmware/amdgpu/yellow_carp_gpu_info.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/vangogh_gpu_info.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_rlc.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_mec2.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_mec.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_me.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_pfp.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_ce.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_sdma1.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/cyan_skillfish_sdma.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/sienna_cichlid_mes.bin for module amdgpu
W: Possible missing firmware /lib/firmware/amdgpu/navi10_mes.bin for module amdgpu

The next time I ran the install command for bison I saw the expected prompt.

marcuse@redblue:~$ sudo apt-get install bison

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
cmake-data dh-elpa-helper libflashrom1 libftdi1-2 libjsoncpp25 librhash0
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libsigsegv2 m4
Suggested packages:
bison-doc m4-doc
The following NEW packages will be installed:
bison libsigsegv2 m4
0 upgraded, 3 newly installed, 0 to remove and 36 not upgraded.
Need to get 962 kB of archives.
After this operation, 2,924 kB of additional disk space will be used.
Do you want to continue? [Y/n]

Next, I setup yacc to point to bison per the host machine instructions.

marcuse@redblue:~$ which bison
/usr/bin/bison
marcuse@redblue:~$ sudo ln -s /usr/bin/bison /usr/bin/yacc
marcuse@redblue:~$ which yacc
/usr/bin/yacc
marcuse@redblue:~$ readlink -f /usr/bin/yacc
/usr/bin/bison

I made sure the rest of the packages were installed and/or simlinks setup to similar packages.

sudo apt-get install texinfo
sudo ln -s /usr/bin/awk /usr/bin/gawk
which m4

Section 2.3 of the LFS book is like the label on a prescription drug. There are multiple ways you can render your host machine totally unusable or botch the process of setting up an LFS machine, including by just turning of your computer at any point during the process to - you know - get some sleep at night. But that’s alright since as a grad student I didn’t get any sleep anyways, so I am used to it.

Let’s go!

Section 2.4 outlines disk space requirements. We will need to create a >30 GB partition for our LFS system if it is to be a standalone Linux OS. That leads me to my next problem — hard drives.

I have three 1 TB drives in RAID so that they form a striped backup of 1 TB of actual data. Think of this as like interleaving the data through the hard drives. these “stripes” of the actual data are of a particular length and are stored — distributed — across each of the three drives. Therefore if a single drive fails, there will be a backup of its data elsewhere. What’s more, if it fails in particular sectors, chances are those particular sectors are backed up in a particular “stripe”.

I suppose it’s kind of like blockchain.

However, like blockchain, it isn’t always sustainable. When I booted up my machine today, I encountered the following error.

ata5: SRST failed (errno=-16)

I did not encounter the final giving-up message, so I assume this worked itself out. However, this is not ideal. I wanted to track down the particular drive that was being problematic.

ata5: reset failed, giving up

ata5 is a SATA channel. On my host machine, all of the SATA channels are in use and I have a PCI SATA extension board installed on the motherboard as well. I used ll to find out what device was on channel ata5. It was sr0.

marcuse@redblue:~$ ll /sys/block
total 0
drwxr-xr-x 2 root root 0 Jan 9 09:56 ./
dr-xr-xr-x 13 root root 0 Jan 9 09:53 ../
lrwxrwxrwx 1 root root 0 Jan 9 09:56 loop0 -> ../devices/virtual/block/loop0/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 loop1 -> ../devices/virtual/block/loop1/
lrwxrwxrwx 1 root root 0 Jan 9 12:13 loop10 -> ../devices/virtual/block/loop10/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 loop2 -> ../devices/virtual/block/loop2/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 loop3 -> ../devices/virtual/block/loop3/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 loop4 -> ../devices/virtual/block/loop4/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 loop5 -> ../devices/virtual/block/loop5/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 loop6 -> ../devices/virtual/block/loop6/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 loop7 -> ../devices/virtual/block/loop7/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 loop8 -> ../devices/virtual/block/loop8/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 loop9 -> ../devices/virtual/block/loop9/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 sda -> ../devices/pci0000:00/0000:00:11.0/ata7/host2/target2:0:0/2:0:0:0/block/sda/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 sdb -> ../devices/pci0000:00/0000:00:11.0/ata8/host3/target3:0:0/3:0:0:0/block/sdb/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 sdc -> ../devices/pci0000:00/0000:00:11.0/ata9/host4/target4:0:0/4:0:0:0/block/sdc/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 sdd -> ../devices/pci0000:00/0000:00:11.0/ata10/host5/target5:0:0/5:0:0:0/block/sdd/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 sde -> ../devices/pci0000:00/0000:00:14.4/0000:05:06.0/ata4/host8/target8:0:0/8:0:0:0/block/sde/
lrwxrwxrwx 1 root root 0 Jan 9 09:56 sr0 -> ../devices/pci0000:00/0000:00:14.1/ata5/host1/target1:0:0/1:0:0:0/block/sr0/

I learned from a Linux forum that the naming convention here is the following:

  • hdx -> IDE devices
  • sdx -> SCSI, SATA and USB devices
  • sr0, scd0, etc. -> CD/DVD drives

Thankfully, I won’t be needing my CD/DVD drive for this exercise. I was worried that a hard drive was failing on me, but that was not the case. One 1 TB drive was mounted and ready to use.

marcuse@redblue:/$ mount -l | grep 'Disk 2'
/dev/sdc1 on /media/marcuse/Disk 2 type fuseblk (ro,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096,uhelper=udisks2) [Disk 2]

marcuse@redblue:/$ lsblk | grep sdc
sdc 8:32 0 931.5G 0 disk
├─sdc1 8:33 0 462.2G 0 part /media/marcuse/Disk 2
├─sdc2 8:34 0 1K 0 part
├─sdc5 8:37 0 461.3G 0 part /media/marcuse/0c2712f4-019e-4e61-a59e-8356b2ec9632
└─sdc6 8:38 0 8G 0 part

I used fdisk to create the swap partition and the LFS primary partition.

marcuse@redblue:/$ umount /dev/sdc1
marcuse@redblue:/$ sudo fdisk /dev/sdc1

Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

The device contains 'ntfs' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.

Command (m for help): F
Unpartitioned space /dev/sdc1: 915.63 GiB, 983150711808 bytes, 1920216234 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

Start End Sectors Size
4096 27722121 27718026 13.2G
27723776 1920221983 1892498208 902.4G

Command (m for help): p

Disk /dev/sdc1: 462.25 GiB, 496332768768 bytes, 969399939 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x73736572

Device Boot Start End Sectors Size Id Type
/dev/sdc1p1 1920221984 3736432267 1816210284 866G 72 unknown
/dev/sdc1p2 1936028192 3889681299 1953653108 931.6G 6c unknown
/dev/sdc1p3 0 0 0 0B 0 Empty
/dev/sdc1p4 27722122 27722568 447 223.5K 0 Empty

Partition table entries are not in disk order.

Command (m for help): d /dev/sdc1p1
Partition number (1-4, default 4):

Partition 4 has been deleted.

Command (m for help): p
Disk /dev/sdc1: 462.25 GiB, 496332768768 bytes, 969399939 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x73736572

Device Boot Start End Sectors Size Id Type
/dev/sdc1p1 1920221984 3736432267 1816210284 866G 72 unknown
/dev/sdc1p2 1936028192 3889681299 1953653108 931.6G 6c unknown
/dev/sdc1p3 0 0 0 0B 0 Empty

Partition table entries are not in disk order.

Command (m for help): d
Partition number (1-3, default 3): 1

Partition 1 has been deleted.

Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2,4, default 2): 2
First sector (434154515-969399938, default 434155520):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (434155520-969399938, default 969399938): +128M

Created a new partition 2 of type 'Linux' and of size 128 MiB.

Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1,4, default 1):
First sector (2048-969399938, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-434155519, default 434155519): +256G
Value out of range.
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-434155519, default 434155519): +200G

Created a new partition 1 of type 'Linux' and of size 200 GiB.

I had the correct partition table at the end of my fdisk session with two partitions. I created the primary partition with 200 GB of space and the swap partition with 128 MB of space.

Command (m for help): p
Disk /dev/sdc1: 462.25 GiB, 496332768768 bytes, 969399939 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x73736572

Device Boot Start End Sectors Size Id Type
/dev/sdc1p1 2048 419432447 419430400 200G 83 Linux
/dev/sdc1p2 434155520 434417663 262144 128M 83 Linux
/dev/sdc1p3 0 0 0 0B 0 Empty

Partition table entries are not in disk order.

marcuse@redblue:~$ grep MemTotal /proc/meminfo
MemTotal: 8163616 kB

I did a bit more messing around to get the partition sizes and additional convenience partitions setup just right.

marcuse@redblue:~$ grep MemTotal /proc/meminfo
MemTotal: 8163616 kB
Command (m for help): d
Partition number (1-3, default 3): 1

Partition 1 has been deleted.

Command (m for help): d
Partition number (1-3, default 3): 1

Partition 1 has been deleted.

Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1,2,4, default 1): 1
First sector (2048-969399938, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-969399938, default 969399938): +200M

Created a new partition 1 of type 'Linux' and of size 200 MiB.

Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2,4, default 2): 2
First sector (411648-969399938, default 411648):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (411648-969399938, default 969399938): +200G

Created a new partition 2 of type 'Linux' and of size 200 GiB.

Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): p

Selected partition 4
First sector (419842048-969399938, default 419842048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (419842048-969399938, default 969399938): +16G

Created a new partition 4 of type 'Linux' and of size 16 GiB.

This gave me a boot partition, home partition and swap partition. The swap partition was setup with twice the size of my onboard RAM — 16 GB.

Command (m for help): p
Disk /dev/sdc1: 462.25 GiB, 496332768768 bytes, 969399939 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x73736572

Device Boot Start End Sectors Size Id Type
/dev/sdc1p1 2048 411647 409600 200M 83 Linux
/dev/sdc1p2 411648 419842047 419430400 200G 83 Linux
/dev/sdc1p3 0 0 0 0B 0 Empty
/dev/sdc1p4 419842048 453396479 33554432 16G 83 Linux

Partition table entries are not in disk order.

Thanks for following along this yak shave and stay tuned for the next.

--

--

No responses yet