Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • aports aports
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Graph
    • Compare
  • Issues 659
    • Issues 659
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 340
    • Merge requests 340
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • alpinealpine
  • aportsaports
  • Issues
  • #5384
Closed
Open
Issue created Apr 08, 2016 by jkk jkk88@jkk

boot from an iso file on a filesystem

Hi,

what I was really missing on alpine was booting iso file directly with grub2.
Here is my attempt to add this feature. It was mostly tested in qemu with edge release.
For general info you can use http://www.supergrubdisk.org/wiki/Loopback.cfg
It adds boot option isoloop used by initial ramdisk. This option defines file path of stored iso on
existing filesystem.

Please integrate in some form this feature.

--- a/usr/share/mkinitfs/initramfs-init
+++ b/usr/share/mkinitfs/initramfs-init
@@ -235,6 +235,9 @@
 find_boot_repositories() {
    if [ -n "$ALPINE_REPO" ]; then
        echo "$ALPINE_REPO"
+   elif [ -n "$KOPT_isoloop" ]; then
+       find /lib/live/* -name .boot_repository -type f -maxdepth 2 \
+           | sed 's:/.boot_repository$::'
    else
        find /media/* -name .boot_repository -type f -maxdepth 3 \
            | sed 's:/.boot_repository$::'
@@ -248,7 +251,7 @@
 myopts="alpine_dev autodetect autoraid chart cryptroot cryptdm debug_init
    dma init_args keep_apk_new modules ovl_dev pkgs quiet root_size root
    usbdelay ip alpine_repo apkovl alpine_start splash blacklist
-   overlaytmpfs rootfstype rootflags"
+   overlaytmpfs rootfstype rootflags isoloop"

 for opt; do
    case "$opt" in
@@ -390,7 +393,32 @@
 nlplug-findfs $cryptopts -p /sbin/mdev ${KOPT_debug_init:+-d} \
    ${KOPT_usbdelay:+-t $(( $KOPT_usbdelay * 1000 ))} \
    $repoopts -a /tmp/apkovls
-eend $?
+return=$?
+if [ -n "$KOPT_isoloop" ]; then
+   retstat=1
+   mkdir -p /lib/live/store /lib/live/medium
+   for dev in $(blkid | sed "s/:.*//"); do
+       mpoint=$(mount | grep "^$dev" | awk '{print $3}')
+       if [ -n "$mpoint" ]; then
+           mount -o bind $mpoint /lib/live/store
+       else
+           mount $dev /lib/live/store
+       fi
+       [ $? -eq 0 ] || continue
+       mount /lib/live/store$KOPT_isoloop \
+           /lib/live/medium
+       if [ $? -eq 0 ]; then
+           echo /lib/live/medium/apks > /tmp/apkovls
+           retstat=0
+           break
+       else
+           umount /lib/live/store
+       fi
+   done
+   eend $retstat
+else
+   eend $retstat
+fi

 # early console?
 if [ "$SINGLEMODE" = "yes" ]; then

--- a/etc/init.d/modloop
+++ b/etc/init.d/modloop
@@ -10,11 +10,14 @@

 # read kernel options
 init_KOPT() {
-   eval set -- $(cat /proc/cmdline 2>/dev/null)
-   for opt; do
-           case "$opt" in
+   for x in $(cat /proc/cmdline); do
+       case $x in
            modloop=*)
-               eval "KOPT_${opt%%=*}='${opt#*=}'" ;;
+           KOPT_modloop=${x#modloop=}
+           ;;
+           isoloop=*)
+           KOPT_isoloop=${x#isoloop=}
+           ;;
        esac
    done
 }
@@ -58,13 +61,17 @@
                && modloop=$modloop_dldir/$(basename $KOPT_modloop)
            ;;
        *)
-           for dir in $(mountdirs); do
-               if [ -f "$dir"/$KOPT_modloop ]; then
-                   modloop="$dir/${KOPT_modloop##/}"
-                   alpine_mnt="$dir"
-                   break
-               fi
-           done
+           if [ -n "$KOPT_isoloop" ]; then
+               modloop=/lib/live/medium$KOPT_modloop
+           else
+               for dir in $(mountdirs); do
+                   if [ -f "$dir"/$KOPT_modloop ]; then
+                       modloop="$dir/${KOPT_modloop##/}"
+                       alpine_mnt="$dir"
+                       break
+                   fi
+               done
+           fi
            ;;
    esac

And here are some examples how grub configuration may look like.

cat /media/sda1/boot/grub/grub.cfg

set timeout=3

menuentry "Boot via ISO loopback with apkovl placed on iso media" {
  iso_path=/boot/boot-isos/alpine-edge-160408.iso
  search --set=root --file $iso_path
  loopback loop $iso_path
  root=(loop)
  linux /boot/vmlinuz-grsec modloop=/boot/modloop-grsec nomodeset isoloop=${iso_path} apkovl=/lib/live/store/localhost.apkovl.tar.gz
  initrd /boot/initramfs-grsec
  loopback --delete loop
}

menuentry "Boot via ISO loopback (root not set)" {
  iso_path=/boot/boot-isos/alpine-edge-160408.iso
  search --set=root --file $iso_path
  loopback loop $iso_path
  echo 'Alpine ISO (loop)/path...'
  linux (loop)/boot/vmlinuz-grsec modloop=/boot/modloop-grsec nomodeset isoloop=${iso_path}
  initrd (loop)/boot/initramfs-grsec
  loopback --delete loop
}

menuentry "Boot via config file loopback.cfg placed on sda1" {
  iso_path=/boot/boot-isos/alpine-edge-160408.iso
  export iso_path
  search --set=root --file $iso_path
  loopback loop $iso_path
  root=(loop)
  configfile (hd0,1)/loopback.cfg
  loopback --delete loop
}

menuentry "Boot via config file loopback.cfg placed on iso" {
  iso_path=/boot/boot-isos/alpine-edge-160408.iso
  export iso_path
  search --set=root --file $iso_path
  loopback loop $iso_path
  root=(loop)
  configfile /boot/grub/loopback.cfg
  loopback --delete loop
}

# ovl_dev option is ignored

(from redmine: issue id 5384, created on 2016-04-08)

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking