Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

live hooks #17

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion docs/tinyramfs.cmdline.7
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.nh
.ad l
.\" Begin generated content:
.TH "tinyramfs.cmdline" "7" "2020-09-10"
.TH "tinyramfs.cmdline" "7" "2020-11-13"
.P
.SH NAME
.P
Expand Down Expand Up @@ -132,6 +132,32 @@ See \fBfstab\fR(5) fourth field.\&
.P
Initramfs must contain appropriate hooks for ability to use below parameters.\&
.P
.SS LIVE
.P
\fBlive_disk\fR=LABEL
.P
.RS 4
Specify LABEL from the live disk to boot from.
.P
.RE
\fBlive_img_file\fR=/path/to/pseudo-fs
.P
.RS 4
Specify location to the pseudo-fs image file.
.P
.RE
\fBlive_ram_opts\fR=opts
.P
.RS 4
Options for ram mountpoint.
.P
.RE
\fBlive_sfs_opts\fR=opts
.P
.RS 4
Options for pseudo-fs mountpoint.
.P
.RE
.SS LVM
.P
\fBlvm_tag\fR=tag
Expand Down Expand Up @@ -208,6 +234,13 @@ vmlinuz initrd=\\initramfs \&.\&.\&. -- args
.fi
.RE
.P
.SS BOOT FROM RAM IN LIVE CD
.nf
.RS 4
vmlinuz initrd=\\initramfs ram
.fi
.RE
.P
.SH SEE ALSO
.P
\fBtinyramfs\fR(8) \fBtinyramfs.\&config\fR(5) \fBtinyramfs.\&hooks\fR(7)
24 changes: 24 additions & 0 deletions docs/tinyramfs.cmdline.7.scd
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ kernel parameters without needing to regenerate initramfs image.

Initramfs must contain appropriate hooks for ability to use below parameters.

## LIVE

*live_disk*=LABEL

Specify LABEL from the live disk to boot from.

*live_img_file*=/path/to/pseudo-fs

Specify location to the pseudo-fs image file.

*live_ram_opts*=opts

Options for ram mountpoint.

*live_sfs_opts*=opts

Options for pseudo-fs mountpoint.

## LVM

*lvm_tag*=tag
Expand Down Expand Up @@ -117,6 +135,12 @@ vmlinuz initrd=\\initramfs luks_discard= lvm_discard= ...
vmlinuz initrd=\\initramfs ... -- args
```

## BOOT FROM RAM IN LIVE CD
```
vmlinuz initrd=\\initramfs ram
```

# SEE ALSO

*tinyramfs*(8) *tinyramfs.config*(5) *tinyramfs.hooks*(7)
tinyramfs.config(5)
52 changes: 51 additions & 1 deletion docs/tinyramfs.config.5
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.nh
.ad l
.\" Begin generated content:
.TH "tinyramfs.config" "5" "2020-09-07"
.TH "tinyramfs.config" "5" "2020-11-13"
.P
.SH NAME
.P
Expand Down Expand Up @@ -248,6 +248,15 @@ luks - LUKS support
.el \{\
.IP \(bu 4
.\}
live - live support
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
mdev - mdev support
.RE
.RS 4
Expand Down Expand Up @@ -307,6 +316,32 @@ More detailed information and how to write your own hooks described in
.RE
.SH HOOKS OPTIONS
.P
.SS LIVE
.P
\fBlive_disk\fR=LABEL
.P
.RS 4
Specify LABEL from the live disk to boot from.
.P
.RE
\fBlive_img_file\fR=/path/to/pseudo-fs
.P
.RS 4
Specify location to the pseudo-fs image file.
.P
.RE
\fBlive_ram_opts\fR=opts
.P
.RS 4
Options for ram mountpoint.
.P
.RE
\fBlive_sfs_opts\fR=opts
.P
.RS 4
Options for pseudo-fs mountpoint.
.P
.RE
.SS LVM
.P
\fBlvm_tag\fR=tag
Expand Down Expand Up @@ -432,6 +467,21 @@ keymap_path=/usr/share/bkeymaps/colemak/en-latin9\&.bmap
.fi
.RE
.P
.SS ROOT + LIVE
.P
.nf
.RS 4
hooks="mdev live"

root=overlay
root_type="$root"

live_disk=LIVECD
live_img_file=system/livefs\&.sfs
live_ram_opts="size=50%,mode=0755"
.fi
.RE
.P
.SS ROOT + LUKS
.P
.nf
Expand Down
32 changes: 32 additions & 0 deletions docs/tinyramfs.config.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ you can simply prepend \#.

- lvm - LVM support
- luks - LUKS support
- live - live support
- mdev - mdev support
- proc - CONFIG_UEVENT_HELPER support
- mdevd - mdevd support
Expand All @@ -135,6 +136,24 @@ you can simply prepend \#.

# HOOKS OPTIONS

## LIVE

*live_disk*=LABEL

Specify LABEL from the live disk to boot from.

*live_img_file*=/path/to/pseudo-fs

Specify location to the pseudo-fs image file.

*live_ram_opts*=opts

Options for ram mountpoint.

*live_sfs_opts*=opts

Options for pseudo-fs mountpoint.

## LVM

*lvm_tag*=tag
Expand Down Expand Up @@ -230,6 +249,19 @@ root=UUID=13bcb7cc-8fe5-4f8e-a1fe-e4b5b336f3ef
keymap_path=/usr/share/bkeymaps/colemak/en-latin9.bmap
```

## ROOT + LIVE

```
hooks="mdev live"

root=overlay
root_type="$root"

live_disk=LIVECD
live_img_file=system/livefs.sfs
live_ram_opts="size=50%,mode=0755"
```

## ROOT + LUKS

```
Expand Down
9 changes: 9 additions & 0 deletions hooks/live/live
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
eudaldgr marked this conversation as resolved.
Show resolved Hide resolved

for _mod in cdrom loop overlay squashfs; do
copy_module "$_mod"
done

for _bin in blockdev cp losetup umount; do
copy_binary "$_bin"
done
30 changes: 30 additions & 0 deletions hooks/live/live.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
eudaldgr marked this conversation as resolved.
Show resolved Hide resolved
#
# false positive
# shellcheck disable=2154

modprobe -a cdrom loop overlay squashfs

medium=/run/initramfs/medium
system=/run/initramfs/system

mkdir -p "$medium" "$system" /run/initramfs/overlayfs/work /run/initramfs/overlayfs/write

[ -h "/dev/disk/by-$live_disk_type/$live_disk" ] || { sleep 5; }
eudaldgr marked this conversation as resolved.
Show resolved Hide resolved

mount -o ro "/dev/disk/by-$live_disk_type/$live_disk" "$medium" || panic

sfsimg="$medium/$live_img_file"

[ "$ram" ] && {
mkdir -p /run/initramfs/ram
mount -t tmpfs -o "${live_ram_opts:?}" ram /run/initramfs/ram || panic
cp "$sfsimg" /run/initramfs/ram || panic
umount "$medium"
sfsimg="/run/initramfs/ram/$live_img_file"
}

sfsdev=$(losetup -f)
losetup -f -r "$sfsimg"

mount -t squashfs -o "${live_sfs_opts:-defaults,ro}" "$sfsdev" "$system" || panic