When you need to do certain maintenance tasks (such as replacing the root partition) or need to troubleshoot boot issues of a Linux machine, a common way to do this is by booting the machine from a live/rescue image and then chroot into the installed OS.
Knoppix is such a live Linux image and contains a lot of tools and commands to do such maintenance tasks or fix issues within an installed Linux. It can be used in graphical or in text mode.
But after I mounted the OS-partition (just /dev/sda1 in this case) and the other required run-time partitions, I ran into an error:
root@Microknoppix:/# mount /dev/sda1 /mnt
root@Microknoppix:/# for mp in proc sys dev run; do mount /${mp} /mnt/${mp}; done
root@Microknoppix:/# chroot /mnt bash
chroot: failed to run command 'bash': Exec format error
Huh? What did I do wrong? Did I miss mounting a specific partition?
No. It turns out I started Knoppix the wrong way. That's something I already had run into in the past. And I probably will again, hence writing this post will create a beacon in my brain.
The Knoppix Cheat Codes show a couple of very helpful (or rather must-use!) boot parameters, which can be entered right under the Knoppix logo. A simple [Enter] at the boot screen starts Knoppix in the default settings and starts up a user interface (init 5 for the older Sys Admins like me).
But the default boot settings also starts Knoppix as a 32bit system. On a 64bit machine, whether physical or virtual, this doesn't make sense and you will run into that error (Exec format error) when trying to run a 64bit command (from the chroot environment) with the booted 32bit Live/Rescue system and vice versa.
To boot Knoppix in 64bit mode, the first boot parameter should be knoppix64 followed by additional parameters, such as lang (for the keyboard language):
The following boot parameters are used in this example:
Now that Knoppix has started up again in 64bit mode, let's try the chroot again:
Chrooting into the OS installed on the disk now worked.
No comments yet.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Database Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Observability Office OpenSearch PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder