Alpine linux how to load system into RAM
1
vote
0
answers
1137
views
I need advice if possible to load entire system into RAM.
Let's imagine following situation:
Booting LIVE OS from DVD and login as root
lsblk shows
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 2.9G 1 loop
sda 8:0 0 19.1G 0 disk
|-sda1 8:1 0 1G 0 part
`-sda2 8:2 0 18.1G 0 part
sr0 11:0 1 1024M 0 rom
I cannot do netboot with ipxe because I will need to have VPN.
The only option here is to use DD and overwrite existing /dev/sda with my custom alpine.img
I will use qemu and apline linux virt image.
Here are the steps I have done so far:
- Booted Alpine linux from iso and created /dev/sda
- sda will bave only boot partition as mounting point as following:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 1G 0 disk
├─sda1 8:1 0 300M 0 part /boot
- in /boot directory I have copied following:
/boot/
├── alpine-rootfs.tar.gz
├── System.map-virt
├── boot -> .
├── config-virt
├── extlinux.conf
├── initramfs-virt
├── ldlinux.c32
├── ldlinux.sys
├── libcom32.c32
├── libutil.c32
├── lost+found
├── mboot.c32
├── menu.c32
├── vesamenu.c32
└── vmlinuz-virt
extlinux.conf contains
# Generated by update-extlinux 6.04_pre1-r15
DEFAULT menu.c32
PROMPT 0
MENU TITLE Alpine/Linux Boot Menu
MENU HIDDEN
MENU AUTOBOOT Alpine will be booted automatically in # seconds.
TIMEOUT 10
LABEL virt
MENU LABEL Linux virt
LINUX vmlinuz-virt
INITRD initramfs-virt
APPEND root=/dev/ram0 modules=sd-mod,usb-storage,ext4 quiet rootfstype=ext4
In the initramfs-virt I have added following code:
# Create a RAM disk with a filesystem (adjust the size as needed)
mkdir -p /sysroot
mount -t tmpfs -o size=512M tmpfs /sysroot
# Extract the contents of your root filesystem (e.g., Alpine Linux) to the RAM disk
tar -xzvf /path/to/your/alpine-rootfs.tar.gz -C /sysroot
# Pivot to the RAM disk as the new root filesystem
exec switch_root /sysroot /sbin/init
Unfortunately boot process fails,
Can someone advice what am I doing wrong here
The whole point here is to have following solution:
- Once rescue DVD is booted use dd to overwrite existing /dev/sda with my custom alpine.img
- next boot from custom alpine.img and load system into RAM
- once you login to shell create ssh tunnelling and deploy final operating system
Asked by Rafal Niznik
(333 rep)
Oct 15, 2023, 01:46 PM