Re: Begin: Mounting root file system ... /init: line 221: arithmetic syntax error

John Paul Adrian Glaubitz <[email protected]>
Newsgroups gmane.linux.debian.ports.sparc
Message-ID <f517eeced4aa4c70f2d71c85d707e44699a1d7d2.camel@physik.fu-berlin.de>
Hi Dennis,

On Fri, 2025-09-05 at 14:32 -0400, Dennis Clarke wrote:
> > I would suggest to create sparc64 sid chroot with the debootstrap command I suggested in my previous mails.
> > 
> > Just make sure to install qemu-user before running it with »--arch=sparc64« on your x86_64 machine.
> > 
> 
> I have no idea how to do these things. I am guessing the qemu-user stuff
>   is for some cross compile procedure ?

No, it's not that difficult. qemu-user is a variant of QEMU that allows you to run
single binaries of a foreign architecture on your x86_64 machine as if it was a
native binary.

For example, you could download a static sparc64 binary, run it with

	qemu-user-sparc64 /path/to/binary

and it would just work.

Now, debootstrap is the command to create the directory structure of a minimum Debian
system into a directory, also called chroot. The chroot contains a fully working system
that you could then copy into the root directory of an empty partition and use this as
a new system partition to build your own Debian system from scratch.

debootstrap has basically this syntax:

# debootstrap --param1 --param2 --param3 --arch=$ARCH $DIST $DIR $MIRROR

where param1, param2, paramN are various parameters and:

- $ARCH - target architecture, e.g. sparc64
- $DIST - target distribution, e.g. unstable
- $DIR  - target directory, e.g. /tmp/sparc64-chroot
- $MIRROR - source mirror, e.g. http://ftp.ports.debian.org/debian-ports

debootstrap works by downloading set of fundamental deb packages for a target architecture
and extracts them into $DIR, this is called the first stage of debootstrap. After that
has happened, it tries to enter this chroot by running "chroot $DIR" and then install
additional packages and eventually configure all of them.

This would normally fail when the host architecture and the target architecture do not match
since your x86_64 CPU won't be able to execute sparc64. However, when you have the "qemu-user"
package installed, the Linux kernel can magically execute those sparc64 packages on your x86_64
machine without any additional configuration. It does that via the binfmt mechanism in the kernel
which can detect the executable format of a binary and automatically invoke it with the correct
interpreter, in our case ELF binaries for linux-sparc64 are automatically run with "qemu-user-sparc64".

To cut a long story short, run (as root):

# apt install qemu-user-binfmt debootstrap debian-ports-archive-keyring

Then:

# mkdir -p /path/to/sparc64/chroot # to create a target directory for the sparc64 chroot

and finally:

# debootstrap --keyring=/usr/share/keyrings/debian-ports-archive-keyring.gpg
              --include=debian-ports-archive-keyring,wget unstable /path/to/sparc64/chroot \
              http://ftp.ports.debian.org/debian-ports

After that, you will have a minimal sparc64 chroot in /path/to/sparc64/chroot.

You can even enter the chroot on your x86_64 machine with:

# chroot /path/to/sparc64/chroot

and then just run:

# apt update && apt install pkg1 pkg2 pkg3

to install any additional software.

Then tar this directory up:

# cd /path/to/sparc64/chroot
# tar czf ../sparc64-chroot.tgz .
# cd ..
# scp -r sparc64-chroot.tgz root@$IP_OF_YOUR_SPARC

On the SPARC machine, mount your new root partition:

# mount /dev/sdbN /mnt/ # /dev/sdbN being the root device of your new system disk

Enter it:

# cd /mnt/

Extract the tarball into it:

# tar xf /path/to/sparc64-chroot.tgz

And bind-mount /dev, /proc and /sys into it:

# mount -o bind /dev /mnt/dev
# mount -o bind /proc /mnt/proc
# mount -o bind /sys /mnt/sys

Enter the chroot:

# chroot /mnt/

Download the patched kernel:

# wget https://people.debian.org/~glaubitz/sparc64/linux-image-6.12.3-sparc64-smp_6.12.3-1+sparc64_sparc64.deb

And install it:

# apt update && apt install ./linux-image-6.12.3-sparc64-smp_6.12.3-1+sparc64_sparc64.deb

Leave the chroot:

# exit

Umount the bind-mounts:

# umount /mnt/{dev,proc,sys}

Copy the kernel and initrd from the chroot to where SILO can find them:

# cp -av /mnt/boot/vmlinux* /
# cp -av /mnt/boot/initrd* /

Then point your silo.conf to the new boot partition and reboot.

> > Then tar that directory up, transfer it to the SPARC and unpack it into the root directory of the second hard drive
> > 
> > Then point the root partition in silo.conf to the newly generated sid sparc64 partition.
> 
> That sounds cool ... if I can get there.

It's not that hard actually. I gave you the instructions above from memory, so it will
hopefully work for you, plus or minus some small corrections you may have to apply.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.