Hi,
I want to install Alpine Linux on a Linux multi-boot desktop PC, hence
the way to go seems to be
"System Disk Mode
This is a traditional hard-disk install.
If this mode is selected, the setup-alpine script creates three
partitions [...] For custom partitioning, see Setting up disks manually.
To install along side another operating systems, see Dualbooting." -
https://wiki.alpinelinux.org/wiki/Installation#Minimal_Hardware_Requirements
What I actually want to do is providing a partition that is already
formatted as ext4 and that should hold everything, including /boot in
the root directory (IOW /, not /root ;), excepted of a swap. A swap is
already available.
I don't want that the setup-script installs a bootloader.
If I click on "Setting up disks manually" the very next thing I need to
do is to click the next link and so on, without getting clear
information. If I click Dualbooting I get a lot of irrelevant
information, too.
I'm used to a user-centric approach. I know what BIOS I'm on, how to
format a SSD, how to setup syslinux or grub (grub without the auto-
crap). What I don't know is, how to use the Alpine Linux installer/setup
script.
There is https://wiki.alpinelinux.org/wiki/Alpine_setup_scripts , but
it's not clear to me. All the hints are too long too read and don't get
to the point.
Would
BOOTLOADER=""
or
Bootloader=flase
or else be for not installing a bootloader?
I installed iSH [ https://github.com/ish-app/ish/ ] on an iPad, it's
based on Alpine Linux.
What I want to get, is something very close to the iPad's iSH Alpine
Linux on my desktop PC.
I want an Alpine install on bare metal, but the plan is to run it most
of the times from within an Arch Linux session, by
"systemd-nspawn --boot".
So let's assume I would have /dev/sda1 ext4 free for Alpine's /
including /boot. /dev/sda2 would provide a Linux swap and I don't want
to install a bootloader at all.
How can I achieve this by using the setup-scripts?
Regards,
Ralf
> Would>> BOOTLOADER="">> or>> Bootloader=flase>> or else be for not installing a bootloader?
It's BOOTLOADER=none
https://git.alpinelinux.org/alpine-conf/tree/setup-disk.in#n697> So let's assume I would have /dev/sda1 ext4 free for Alpine's /> including /boot. /dev/sda2 would provide a Linux swap and I don't want> to install a bootloader at all.>> How can I achieve this by using the setup-scripts?
I'd say it's easier to install manually using apk like this:
apk add --root /mnt --initdb --allow-untrusted --repository
https://mirror.yandex.ru/mirrors/alpine/edge/main alpine-base
Most distros ship apk-tools in their repos so you don't need to do it
from alpine.
This skips one important thing however - populating
/etc/runlevels/{sysinit,boot,shutdown}.
For bubblewrap/unshare/chroot purposes you don't need it.
But if you do, you can fill it manually from any working alpine installation.
On Fri, 2023-05-26 at 19:23 +0300, Konstantin Kulikov wrote:
> > I'd say it's easier to install manually using apk like this:> apk add --root /mnt --initdb --allow-untrusted --repository> https://mirror.yandex.ru/mirrors/alpine/edge/main alpine-base> > Most distros ship apk-tools in their repos so you don't need to do it> from alpine.
Thank You,
yes, it's in the Arch repos.
$ pacman -Si apk-tools | head -5
Repository : extra
Name : apk-tools
Version : 2.12.11-1
Description : Alpine Package Keeper - package manager for alpine
Architecture : x86_64
> This skips one important thing however - populating> /etc/runlevels/{sysinit,boot,shutdown}.> For bubblewrap/unshare/chroot purposes you don't need it.> But if you do, you can fill it manually from any working alpine> installation.
I'm not sure if I understand you correctly.
After booting the ISO /etc/runlevels/ holds the empty directories
default/ and nonetwork/. The content of the directories boot/, shutdown/
and sysinit/ are symbolic links against scripts in /etc/init.d.
When booted into the ISO, should I copy the items to the Alpine PC
install?
Regards,
Ralf
> When booted into the ISO, should I copy the items to the Alpine PC> install?
Yes, recreate them in the same way (using ln -s for example).
Also don't forget you'll need kernel, mkinitfs, firmware, maybe something else.
On Sat, 2023-05-27 at 08:46 +0300, Konstantin Kulikov wrote:
> > When booted into the ISO, should I copy the items to the Alpine PC> > install?> > Yes, recreate them in the same way (using ln -s for example).> > Also don't forget you'll need kernel, mkinitfs, firmware, maybe> something else.
Hi,
thank you, but I'll probably do a traditional disk install using
BOOTLOADER=none setup-alpine and then copy the /boot partition to the
root directory afterward, followed by commenting out the /boot partition
entry in fstab and replacing swap.
Regards,
Ralf
PS: I'm sorry I accidentally didn't send the answer via the mailing list
first.
Hi,
I booted the alpine-standard-3.18.0-x86_64.iso to run
# BOOTLOADER=none setup-alpine
The last steps were selecting the "sys" install and confirming the
erasing of an external USB HDD (instead of using the unallocated space
only).
setup-alpine generated an empty fat32 partition, a linux-swap and an
ext4 partition holding the root directory, including /boot.
I used cp -Tai to copy everything from the external USB HDD to an
internal NVMe SSD.
Then I edited fstab and grub.cfg, first using the labels and then using
the UUIDs of the root directory and another linux-swap.
If I try to boot it by grub Alpine Linux startup ends with
mount: mounting {LABEL,UUID} [...] on /sysroot failed: No such file or directory
Mounting root failed.
initramfs emergency recovery shell launched.
I wanted to run mkinitfs, but it's not available.
Trying to boot it from an Arch Linux session via systemd-nspawn results
in
# systemd-nspawn -bqD /mnt/m1.alpine
OpenRC 0.47.1 is starting up Linux 6.3.4-arch1-1 (x86_64) [SYSTEMD-NSPAWN]
* /proc is already mounted
* /run/openrc: creating directory
* /run/lock: creating directory
* /run/lock: correcting owner
* Caching service dependencies ... [ ok ]
* Loading hardware drivers ... [ ok ]
* Creating user login records ... [ ok ]
* Setting hostname ... [ ok ]
* Setting keymap ...
loadkmap: can't open console [ !! ]
* ERROR: loadkmap failed to start
* Loading modules ... [ ok ]
* Starting networking ...
* lo ... [ ok ]
* eth0 ...
ip: ioctl 0x8913 failed: No such device
udhcpc: ioctl 0x8933 failed: No such device
ifup: failed to change interface eth0 state to 'up' [ !! ]
* Starting busybox syslog ... [ ok ]
* Setting keymap ...
loadkmap: can't open console [ !! ]
* ERROR: loadkmap failed to start
* Starting busybox acpid ... [ ok ]
* Starting busybox crond ... [ ok ]
can't open /dev/tty1: No such file or directory
can't open /dev/tty2: No such file or directory
can't open /dev/tty3: No such file or directory
can't open /dev/tty4: No such file or directory
can't open /dev/tty5: No such file or directory
can't open /dev/tty6: No such file or directory
can't open /dev/tty1: No such file or directory
can't open /dev/tty2: No such file or directory
[...]
I booted again using grub. In the emergency shell I intended to run
# apk fix linux-lts
Obviously this is not possible in the emergency shell.
Now I try to chroot from Arch Linux.
• root@archlinux /mnt/m1.alpine
# mount -t proc none /mnt/m1.alpine/proc/
• root@archlinux /mnt/m1.alpine
# mount -o bind /dev /mnt/m1.alpine/dev/
• root@archlinux /mnt/m1.alpine
# mount -o bind /sys /mnt/m1.alpine/sys/
• root@archlinux /mnt/m1.alpine
# mount -o bind /run /mnt/m1.alpine/run/
• root@archlinux /mnt/m1.alpine
# chroot /mnt/m1.alpine/
chroot: failed to run command ‘/bin/bash’: No such file or directory
This makes sense. On my iPad iSH's Alpine I explicitly installed bash.
• root@archlinux /mnt/m1.alpine
# /usr/bin/ls -hl /mnt/m1.alpine/bin/*sh*
lrwxrwxrwx 1 root root 12 May 27 13:56 /mnt/m1.alpine/bin/ash -> /bin/busybox
lrwxrwxrwx 1 root root 12 May 27 13:56 /mnt/m1.alpine/bin/fdflush -> /bin/busybox
lrwxrwxrwx 1 root root 12 May 27 13:56 /mnt/m1.alpine/bin/sh -> /bin/busybox
Regards,
Ralf
> mount: mounting {LABEL,UUID} [...] on /sysroot failed: No such file or directory> Mounting root failed.> initramfs emergency recovery shell launched.
Either you got wrong uuid or nvme/filesystem modules didn't get packed
into initramfs.
Try mounting manually in an emergency shell and see what happens.
mkinitfs can be run from chroot or from host system using -b flag,
similar to apk. That works even across architectures.
[ ok ]
> can't open /dev/tty1: No such file or directory> can't open /dev/tty2: No such file or directory> can't open /dev/tty3: No such file or directory> can't open /dev/tty4: No such file or directory> can't open /dev/tty5: No such file or directory> can't open /dev/tty6: No such file or directory> can't open /dev/tty1: No such file or directory> can't open /dev/tty2: No such file or directory> [...]
Looks like system starts, but init can't find console to spawn login(1) on.
I'm not familiar with systemd, but reading its manpage i think it sets
up /dev/console.
Try replacing tty1 with console in /etc/inittab
> # chroot /mnt/m1.alpine/> chroot: failed to run command ‘/bin/bash’: No such file or directory
You need to specify command to run in chroot, in case of alpine it's /bin/sh.
On Sun, 2023-05-28 at 11:40 +0300, Konstantin Kulikov wrote:
> > nvme/filesystem modules didn't get packed into initramfs.
Thank you,
nvme was missing.
• rocketmouse@archlinux ~
$ cat /mnt/m1.alpine/etc/mkinitfs/mkinitfs.conf
features="ata base ide scsi usb virtio ext4"
• rocketmouse@archlinux ~
$ echo "features=\"ata base ext4 ide nvme scsi usb virtio\"" | sudo tee /mnt/m1.alpine/etc/mkinitfs/mkinitfs.conf
[sudo] password for rocketmouse:
features="ata base ext4 ide nvme scsi usb virtio"
• rocketmouse@archlinux ~
$ cat /mnt/m1.alpine/etc/mkinitfs/mkinitfs.conf
features="ata base ext4 ide nvme scsi usb virtio"
> You need to specify command to run in chroot, in case of alpine it's> /bin/sh.
• root@archlinux /home/rocketmouse
# mount -t proc none /mnt/m1.alpine/proc/
• root@archlinux /home/rocketmouse
# mount -o bind /dev /mnt/m1.alpine/dev/
• root@archlinux /home/rocketmouse
# mount -o bind /sys /mnt/m1.alpine/sys/
• root@archlinux /home/rocketmouse
# mount -o bind /run /mnt/m1.alpine/run/
• root@archlinux /home/rocketmouse
# chroot /mnt/m1.alpine/ /bin/sh -i
/ # mkinitfs -c /etc/mkinitfs/mkinitfs.conf -b / $(ls /lib/modules/)
/bin/sh: mkinitfs: not found
/ # /sbin/mkinitfs -c /etc/mkinitfs/mkinitfs.conf -b / $(ls /lib/modules/)
==> initramfs: creating /boot/initramfs-lts
/sbin/mkinitfs: line 132: depmod: not found
/ # exit
• root@archlinux /home/rocketmouse
# /bin/ls -hdltr /mnt/m1.alpine/{,usr/}*bin/depmod
lrwxrwxrwx 1 root root 4 Nov 1 2022 /mnt/m1.alpine/usr/sbin/depmod -> kmod
lrwxrwxrwx 1 root root 4 Nov 1 2022 /mnt/m1.alpine/usr/bin/depmod -> kmod
lrwxrwxrwx 1 root root 4 Nov 1 2022 /mnt/m1.alpine/sbin/depmod -> kmod
lrwxrwxrwx 1 root root 4 Nov 1 2022 /mnt/m1.alpine/bin/depmod -> kmod
• root@archlinux /home/rocketmouse
# /bin/ls -hdltr /mnt/m1.alpine/{,usr/}*bin/kmod
-rwxr-xr-x 1 root root 159K Nov 1 2022 /mnt/m1.alpine/usr/sbin/kmod
-rwxr-xr-x 1 root root 159K Nov 1 2022 /mnt/m1.alpine/usr/bin/kmod
-rwxr-xr-x 1 root root 159K Nov 1 2022 /mnt/m1.alpine/sbin/kmod
-rwxr-xr-x 1 root root 159K Nov 1 2022 /mnt/m1.alpine/bin/kmod
Running chroot now returns
"chroot: failed to run command ‘/bin/sh’: No such file or directory"
I probably made a mistake, so the easiest thing to do is to reboot, but
I can't do it right now, since the machine is busy. I even can't start a
terminal at the moment, it results in "Error connecting to dbus: Failed
to connect to socket /run/user/1000/bus: Permission denied".
Regards,
Ralf
On Sun, 2023-05-28 at 12:03 +0200, Ralf Mardorf wrote:
> # chroot /mnt/m1.alpine/ /bin/sh -i> / # mkinitfs -c /etc/mkinitfs/mkinitfs.conf -b / $(ls /lib/modules/)> /bin/sh: mkinitfs: not found> / # /sbin/mkinitfs -c /etc/mkinitfs/mkinitfs.conf -b / $(ls /lib/modules/) > ==> initramfs: creating /boot/initramfs-lts> /sbin/mkinitfs: line 132: depmod: not found
Hi,
I was forced to push the reset button. I wonder what mistake I've done
and why the above happened, before I made it even more worse.
At the moment I can't risk to be forced to reset the machine again,
since I've got some work to do.
Any pointers to reduce the risk using a chroot are welcome.
What are the easiest steps to run
mkinitfs -c /etc/mkinitfs/mkinitfs.conf -b / 6.1.30-0-lts
?
Keep in mind that when booting Alpine into the initramfs emergency
recovery shell it also doesn't find the command mkinitfs.
Regards,
Ralf
> # chroot /mnt/m1.alpine/ /bin/sh -i> / # mkinitfs -c /etc/mkinitfs/mkinitfs.conf -b / $(ls /lib/modules/)> /bin/sh: mkinitfs: not found> / # /sbin/mkinitfs -c /etc/mkinitfs/mkinitfs.conf -b / $(ls /lib/modules/)> ==> initramfs: creating /boot/initramfs-lts> /sbin/mkinitfs: line 132: depmod: not found
Use /bin/sh -l.
/etc/profile does not get sources unless you're running a login shell
so PATH from your host system gets inherited and alpine expects a
different one.
> • root@archlinux /home/rocketmouse> # apk add --root /mnt/m1.alpine/ fix linux-lts> fetch http://mirror.bahnhof.net/pub/alpinelinux/v3.18/main/x86_64/APKINDEX.tar.gz> fetch http://mirror.bahnhof.net/pub/alpinelinux/edge/main/x86_64/APKINDEX.tar.gz> ERROR: unable to select packages:> fix (no such package):> required by: world[fix]>
Mixing release and edge repositories is not supported by alpine. Choose one.
>> • root@archlinux /home/rocketmouse> # apk fix --root /mnt/m1.alpine/ linux-lts> (1/1) [APK unavailable, skipped] Reinstalling linux-lts (6.1.30-r0)> OK: 452 MiB in 54 packages
Maybe caused by mixing repos. Fix your /etc/apk/repositories and
/etc/apk/world and run apk upgrade -a
> I assume I can uncomment v3.18/community in addition to main, just> mixing v3.18 and edge doesn't work. Is this correct?
Yes. There is also testing repo with some more packages.
> I don't know what to do with /etc/apk/world. I suspect it's ok as is.
It is fine.
> Booting Alpine still ends up with the initramfs emergency recovery> shell, due to>> mount: mounting [snip] on /sysroot failed: No such file or directory> Mounting root failed.>>
You need to try and mount your root device initramfs shell by hand and
debug from there.
Possibly ext4 module is not loaded and you need to add modules=ext4 to
your bootloader.
[solved] Install on single partition and without a bootloader
On Tue, 2023-05-30 at 11:05 +0300, Konstantin Kulikov wrote:
> > I assume I can uncomment v3.18/community in addition to main, just> > mixing v3.18 and edge doesn't work. Is this correct?> > Yes. There is also testing repo with some more packages.
Thank You,
at the moment my /etc/apk/repositories does look like this:
• rocketmouse@archlinux ~
$ cat /mnt/m1.alpine/etc/apk/repositories
# Warning: Changing the repositories to latest-stable may initiate unexpected release upgrades.
#
http://mirror.bahnhof.net/pub/alpinelinux/v3.18/main
#http://mirror.bahnhof.net/pub/alpinelinux/latest-stable/main
#
http://mirror.bahnhof.net/pub/alpinelinux/v3.18/community
#http://mirror.bahnhof.net/pub/alpinelinux/latest-stable/community
#
# Using the testing repository on stable branches
# Warning: Only do this if you're 100% sure what you're doing!
# Installing packages from edge that link to something in main or community usually will not work.
# Alpine does not officially support mixing branches this way.
#
#http://mirror.bahnhof.net/pub/alpinelinux/edge/testing
> > Booting Alpine still ends up with the initramfs emergency recovery> > shell> You need to try and mount your root device initramfs shell by hand and> debug from there.
It wasn't necessary. However, just in case I ever should need to do
this. If startup should end with the messages
mount: mounting /dev/nvme0n1p5 on /sysroot failed: No such file or directory
Mouting root failed
initramfs emergency recovery shell launched.
then I need to run
mount -t ext4 /dev/nvme0n1p5 /sysroot
Is this correct?
> Possibly ext4 module is not loaded and you need to add modules=ext4 to> your bootloader.
This does the trick.
• rocketmouse@archlinux ~
$ grep Alpine /boot/grub/grub.cfg -A 4
menuentry " Alpine Linux" {
search --no-floppy --set=root --label m1.alpine
linux /boot/vmlinuz-lts root=/dev/disk/by-label/m1.alpine ro modules=ext4
initrd /boot/initramfs-lts
}
Regards,
Ralf
Booting Alpine by systemd-nspawn fails - Was: Install on single partition and without a bootloader
On Sun, 2023-05-28 at 11:40 +0300, Konstantin Kulikov wrote:
> > > can't open /dev/tty1: No such file or directory> > can't open /dev/tty2: No such file or directory> > can't open /dev/tty3: No such file or directory> > can't open /dev/tty4: No such file or directory> > can't open /dev/tty5: No such file or directory> > can't open /dev/tty6: No such file or directory> > can't open /dev/tty1: No such file or directory> > can't open /dev/tty2: No such file or directory> > [...]> > Looks like system starts, but init can't find console to spawn> login(1) on.> I'm not familiar with systemd, but reading its manpage i think it sets> up /dev/console.> Try replacing tty1 with console in /etc/inittab
Hi,
I don't understand what I need to do. This doesn't work:
• rocketmouse@archlinux ~
$ diff /mnt/m1.alpine/etc/inittab /mnt/m1.alpine/etc/inittab_no_console
8c8
< tty1::respawn:/sbin/getty 38400 console
---
> tty1::respawn:/sbin/getty 38400 tty1
An Internet search returned:
# /etc/inittab
::sysinit:/etc/rc.d/startup
tty1::respawn:/sbin/getty 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2
tty3::respawn:/sbin/getty 38400 tty3
tty4::respawn:/sbin/getty 38400 tty4
tty5::respawn:/sbin/getty 38400 tty5
tty6::respawn:/sbin/getty 38400 tty6
# Put a getty on the serial line (for a terminal). Uncomment this line if
# you're using a serial console on ttyS0, or uncomment and adjust it if using a
# serial console on a different serial port.
#::respawn:/sbin/getty -L ttyS0 115200 vt100
::shutdown:/etc/rc.d/shutdown
::ctrlaltdel:/sbin/reboot
[ http://clfs.org/view/clfs-embedded-0.0.1/mips/bootscripts/inittab.html ]
Oops, I missed that Alpine's inittab contains a similar line, too, but
uncommenting it doesn't help.
• rocketmouse@archlinux ~
$ diff /mnt/m1.alpine/etc/inittab /mnt/m1.alpine/etc/inittab_no_console
16c16
< ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100
---
> #ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100
So I use the default inittab again and systemd-nspawn still fails.
Regards,
Ralf
Re: Booting Alpine by systemd-nspawn fails - Was: Install on single partition and without a bootloader
Hi,
it's solved by gaining knowledge. Microsoft employee and Pwnie Award
winner Lennart Poettering once claimed that "Systemd-Nspawn is Chroot on
Steroids". He's probably right about the side effects of steroid abuse,
since systemd-nspawn only likes Linux that uses systemd, it's completely
intolerant of other init systems, and systemd-nspawn is impotent.
On my todo list is writing a chroot wrapper script, providing some
comfort. On the quick I wrote a "reminder" of what I want to do. The
"reminder" script is a ridiculous script, but it's just to remind me
what I want to get next should I have the time to write a wrapper.
Regards,
Ralf
;D
#! /bin/dash
# chroot-alpine
# v2023-05-31-1
CHROOT=m1.alpine
usage() {
cat<<EOF
Root privileges are mandatory
Usage:
chroot-alpine mount Alpine chroot no X server
chroot-alpine -u unmount Alpine chroot no X server
EOF
exit
}
[ $(id -u) -eq 0 ] || usage
case $2 in
"") ;;
*) usage
;;
esac
case $1 in
-u) printf "\n" # umount --recursive "$(blkid -L$CHROOT)" doesn't work
umount --recursive /mnt/$CHROOT/ # workaround, running two times,
umount --recursive /mnt/$CHROOT/ >/dev/null 2>&1 # if Alpine was already mounted before running this script
rmdir /mnt/$CHROOT/ && printf "[done]\n" # doesn't work if mounted countless times
printf "\n" # at same or different mount points
;;
"") mkdir -p /mnt/$CHROOT
mount -wL$CHROOT /mnt/$CHROOT/ -o noatime
mount -t proc /proc /mnt/$CHROOT/proc/
mount -t sysfs /sys /mnt/$CHROOT/sys/
mount -o bind /dev /mnt/$CHROOT/dev/
mount -o bind /run /mnt/$CHROOT/run/
#printf "\nDISPLAY=$DISPLAY\n\n$CHROOT is mounted:\n$(mount | sort -u | grep $(blkid -L$CHROOT))\n\n"
printf "\nDISPLAY=$DISPLAY\n\n$CHROOT is mounted:\n$(mount | grep $(blkid -L$CHROOT))\n\n" # better not hiding duplicates by sort -u
chroot /mnt/$CHROOT/ /bin/sh -l
;;
*) usage
;;
esac
exit