-
-
Save zengxinhui/f328fdce54f5039689ee3aa4e91fc805 to your computer and use it in GitHub Desktop.
[09/23/2023] | |
Refs: | |
1. http://mirror.cs.pitt.edu/archlinux/iso/2023.09.01/archlinux-bootstrap-2023.09.01-x86_64.tar.gz | |
2. https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-virt-3.18.0-x86_64.iso | |
3. https://wiki.alpinelinux.org/wiki/Replacing_non-Alpine_Linux_with_Alpine_remotely | |
4. https://wiki.archlinux.org/index.php/installation_guide#Configure_the_system | |
See also: | |
1. Convert to Debian https://gist.github.com/zengxinhui/ee0ad6b7c7f99e2ead6cd0d2bd6641fd | |
2. Convert to arch x64 https://gist.github.com/zengxinhui/f328fdce54f5039689ee3aa4e91fc805 | |
3. Convert to arch arm https://gist.github.com/zengxinhui/01afb43b8d663a4232a42ee9858be45e | |
Requirement: | |
Console access. | |
# Prepare alpine linux, which can be configured to run from ram only. | |
# Alpine is leveraged to do the conversion. | |
# In any linux(ubuntu/debian/arch tested) become root first: | |
sudo su - | |
cd /tmp && wget https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-virt-3.18.0-x86_64.iso | |
dd if=alpine-virt-3.18.0-x86_64.iso of=/dev/sda && sync && reboot | |
# In Alpine with console: | |
# [Bring up networking] | |
ip li set eth0 up | |
udhcpc eth0 | |
# [Setup SSH, answer RET, yes, RET] | |
setup-sshd | |
# [set temp password] | |
passwd | |
# [At this point it's easier to use SSH to copy & paste] | |
# [Per Ref #3. Move alpine to ram only] | |
mkdir /media/setup | |
cp -a /media/sda/* /media/setup | |
mkdir /lib/setup | |
cp -a /.modloop/* /lib/setup | |
/etc/init.d/modloop stop | |
umount /dev/sda | |
mv /media/setup/* /media/sda/ | |
mv /lib/setup/* /.modloop/ | |
# [Setup apk and bring in pacman] | |
setup-apkrepos | |
# [enable community] | |
vi /etc/apk/repositories | |
apk update | |
apk add dosfstools e2fsprogs cfdisk pacman arch-install-scripts | |
# [Disk partitioning & mounting] | |
# (use gpt table, set esp partition 15 size 256M), set root partition 1 size remaining) | |
# g, n, 15, RET, +256m, t, 1, n, RET, RET, RET, p, w | |
fdisk /dev/sda | |
ls /dev/sda* | |
# if sda1 or sda15 is missing, do "/etc/init.d/devfs restart" | |
mkfs.vfat /dev/sda15 | |
mkfs.ext4 /dev/sda1 | |
mount -t ext4 /dev/sda1 /mnt | |
mkdir /mnt/boot | |
mount /dev/sda15 /mnt/boot | |
# [1G ram is not enough to hold arch bootstrap. Use HDD for now.] | |
# [or technically you could just use the bootstrap tarball.] | |
mkdir /mnt/tmp | |
cd /mnt/tmp | |
wget http://mirror.cs.pitt.edu/archlinux/iso/2023.09.01/archlinux-bootstrap-2023.09.01-x86_64.tar.gz | |
tar xf archlinux-bootstrap-2023.09.01-x86_64.tar.gz | |
vi root.x86_64/etc/pacman.d/mirrorlist | |
arch-chroot root.x86_64/ | |
pacman-key --init | |
pacman-key --populate archlinux | |
# [Any other way than to mount again?] | |
mount /dev/sda1 /mnt | |
mount /dev/sda15 /mnt/boot | |
pacstrap /mnt base linux | |
genfstab -U /mnt >> /mnt/etc/fstab | |
umount /mnt/boot | |
umount /mnt | |
exit | |
cd /; arch-chroot /mnt | |
# follow https://wiki.archlinux.org/index.php/installation_guide#Configure_the_system | |
# This is your arch root password. Choose carefully and remember it | |
passwd | |
pacman --noconfirm -S openssh grub efibootmgr vi | |
systemctl enable sshd | |
systemctl enable systemd-networkd | |
cat > ~/.ssh/authorized_keys << EOF | |
<your key here> | |
EOF | |
cat > /etc/systemd/network/en.network << EOF | |
[Match] | |
Name=en* | |
[Network] | |
DHCP=yes | |
DNSSEC=no | |
EOF | |
cat > /etc/systemd/network/eth.network << EOF | |
[Match] | |
Name=eth* | |
[Network] | |
DHCP=yes | |
DNSSEC=no | |
EOF | |
cat > /etc/resolv.conf << EOF | |
nameserver 1.1.1.1 | |
nameserver 4.2.2.2 | |
nameserver 8.8.8.8 | |
EOF | |
# [EFI boot] | |
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB | |
vi /etc/default/grub | |
# Better console. Comparison below: | |
# GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet" | |
# GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 console=ttyS0,115200" | |
# Or use perl/sed to replace | |
# perl -pi.bak -e "s/quiet/console=ttyS0,115200/" /etc/default/grub | |
# sed -i.bak -e "s/quiet/console=ttyS0,115200/" /etc/default/grub | |
grub-mkconfig -o /boot/grub/grub.cfg | |
exit | |
reboot |
oh! ok. well it worked with a few modifications. thanks!
somehow I always end up with this error on reboot
error: file
/boot/grub/locale/C.gmo' not found`
it's something related to grub configuration and I don't know how to solve that, any help?
@zengxinhui thanks for posting this!!
@Azertooth the issue seems to be because /etc/grub.d/10_linux
doesn't detect linux images to boot. reference: https://forums.gentoo.org/viewtopic-p-8691498.html?sid=6edb16db140eee71a21fcd0ef82388e9
Adding linux
package before running grub-mkconfig
seem to fix it:
pacman -S linux
you should see a file Image.gz
[root@localhost boot]# ls -la /boot
total 74280
drwxr-xr-x 6 root root 4096 Aug 13 09:08 .
drwxr-xr-x 17 root root 4096 Aug 13 08:46 ..
drwxr-xr-x 3 root root 16384 Jan 1 1970 EFI
drwxr-xr-x 2 root root 4096 Aug 13 08:46 GNUSparseFile.0
-rw-r--r-- 1 root root 40264192 Jun 2 01:33 Image
-rw-r--r-- 1 root root 14339605 Jun 2 01:33 Image.gz
drwxr-xr-x 16 root root 4096 Aug 13 08:46 dtbs
drwxr-xr-x 6 root root 4096 Aug 13 09:08 grub
-rw------- 1 root root 15550453 Aug 13 09:07 initramfs-linux-fallback.img
-rw------- 1 root root 7412723 Aug 13 09:07 initramfs-linux.img
double check your /boot/grub/grub.cfg has an entry between
### BEGIN /etc/grub.d/10_linux ###
### END /etc/grub.d/10_linux ###
should look like:
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0259d95e-8535-4bcb-a81f-c5ec7ed6a50e' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//sas/disk@0\,1000000000000,gpt2' --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 0259d95e-8535-4bcb-a81f-c5ec7ed6a50e
else
search --no-floppy --fs-uuid --set=root 0259d95e-8535-4bcb-a81f-c5ec7ed6a50e
fi
echo 'Loading Linux Image ...'
linux /boot/Image root=/dev/sda2 rw loglevel=3 quiet
}
submenu 'Advanced options for Arch Linux' $menuentry_id_option 'gnulinux-advanced-0259d95e-8535-4bcb-a81f-c5ec7ed6a50e' {
menuentry 'Arch Linux, with Linux Image' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-Image-advanced-0259d95e-8535-4bcb-a81f-c5ec7ed6a50e' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//sas/disk@0\,1000000000000,gpt2' --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 0259d95e-8535-4bcb-a81f-c5ec7ed6a50e
else
search --no-floppy --fs-uuid --set=root 0259d95e-8535-4bcb-a81f-c5ec7ed6a50e
fi
echo 'Loading Linux Image ...'
linux /boot/Image root=/dev/sda2 rw loglevel=3 quiet
}
}
### END /etc/grub.d/10_linux ###
@PortNumber53 thank you for joining to help me. However, even with linux package installed I cannot see that file Image.gz in the /boot directory
[root@localhost /]# pacman -Q | grep linux
archlinux-keyring 20220831-1
linux 5.19.7.arch1-1
linux-api-headers 5.18.15-1
linux-firmware 20220815.8413c63-1
linux-firmware-whence 20220815.8413c63-1
util-linux 2.38.1-1
util-linux-libs 2.38.1-1
[root@localhost /]# ls -hal /boot/
total 53M
drwxr-xr-x 4 root root 4.0K Sep 6 15:55 .
drwxr-xr-x 17 root root 4.0K Sep 6 15:47 ..
drwxr-xr-x 3 root root 4.0K Jan 1 1970 EFI
drwxr-xr-x 6 root root 4.0K Sep 6 15:55 grub
-rw------- 1 root root 34M Sep 6 15:53 initramfs-linux-fallback.img
-rw------- 1 root root 8.8M Sep 6 15:52 initramfs-linux.img
-rw-r--r-- 1 root root 11M Sep 6 15:52 vmlinuz-linux
this is the /etc/grub.d/10_linux
part in /boot/grub/grub.cfg
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-1905b216-9c1e-406b-928c-820d3c96358c' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 1905b216-9c1e-406b-928c-820d3c96358c
else
search --no-floppy --fs-uuid --set=root 1905b216-9c1e-406b-928c-820d3c96358c
fi
echo 'Loading Linux linux ...'
linux /boot/vmlinuz-linux root=/dev/sda2 rw loglevel=3 quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initramfs-linux.img
}
submenu 'Advanced options for Arch Linux' $menuentry_id_option 'gnulinux-advanced-1905b216-9c1e-406b-928c-820d3c96358c' {
menuentry 'Arch Linux, with Linux linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-1905b216-9c1e-406b-928c-820d3c96358c' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 1905b216-9c1e-406b-928c-820d3c96358c
else
search --no-floppy --fs-uuid --set=root 1905b216-9c1e-406b-928c-820d3c96358c
fi
echo 'Loading Linux linux ...'
linux /boot/vmlinuz-linux root=/dev/sda2 rw loglevel=3 quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initramfs-linux.img
}
menuentry 'Arch Linux, with Linux linux (fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-1905b216-9c1e-406b-928c-820d3c96358c' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 1905b216-9c1e-406b-928c-820d3c96358c
else
search --no-floppy --fs-uuid --set=root 1905b216-9c1e-406b-928c-820d3c96358c
fi
echo 'Loading Linux linux ...'
linux /boot/vmlinuz-linux root=/dev/sda2 rw loglevel=3 quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initramfs-linux-fallback.img
}
}
### END /etc/grub.d/10_linux ###
@Azertooth sounds like you are in arch x64 already since pacman is working. Can you do a google search "grub c.gmo not found" and see if any of the result helps?
@Azertooth sounds like you are in arch x64 already since pacman is working. Can you do a google search "grub c.gmo not found" and see if any of the result helps?
pacman is working because that commands were sent in chroot. I managed to solve that error
edit: now when I reboot it fails without any output on the Cloud Shell Connection
these are the main commands related to efi partition and grub
# mount efi partition
mount /dev/sda1 /mnt/boot
# grub install and config
pacman -S grub efibootmgr
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB --removable
grub-mkconfig -o /boot/grub/grub.cfg
I can't wrap my head around on what could be the problem
@Azertooth Try these instructions - https://gist.github.com/amishmm/e2dc93e65cf79116f2ef2d542f05e61b
@Azertooth Try these instructions - https://gist.github.com/amishmm/e2dc93e65cf79116f2ef2d542f05e61b
You just saved me from a week long troubleshooting, thank you so much!
This is what I was missing from my steps:
GRUB_TERMINAL_INPUT="console serial"
GRUB_TERMINAL_OUTPUT="gfxterm serial"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"
GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT/quiet/}"
GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} console=tty0 console=ttyS0,115200"
These instructions worked for me. However, if I change the memory/number of CPUs after installation, the machine does not boot any more. It gets stuck in EFI prompt. Any ideas what could be causing this?
These instructions worked for me. However, if I change the memory/number of CPUs after installation, the machine does not boot any more. It gets stuck in EFI prompt. Any ideas what could be causing this?
If you still have that problem, check this out.
Oddly enough, I use neboot. XYZ installs Arch directly, but systemboot fails after installing it in chroot according to the guide
I covered ARM here: https://gist.github.com/zengxinhui/01afb43b8d663a4232a42ee9858be45e