[a32a241] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[5632009] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
[a42ba00] | 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[5632009] | 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="initramfs">
|
---|
| 9 | <?dbhtml filename="initramfs.html"?>
|
---|
| 10 |
|
---|
| 11 | <sect1info>
|
---|
| 12 | <date>$Date$</date>
|
---|
| 13 | </sect1info>
|
---|
| 14 |
|
---|
| 15 | <title>About initramfs</title>
|
---|
| 16 |
|
---|
[29244b7] | 17 | <para>
|
---|
| 18 | The only purpose of an initramfs is to mount the root filesystem. The
|
---|
| 19 | initramfs is a complete set of directories that you would find on a normal
|
---|
| 20 | root filesystem. It is bundled into a single cpio archive and compressed
|
---|
| 21 | with one of several compression algorithms.
|
---|
| 22 | </para>
|
---|
| 23 |
|
---|
| 24 | <para>
|
---|
| 25 | At boot time, the boot loader loads the kernel and the initramfs image
|
---|
| 26 | into memory and starts the kernel. The kernel checks for the presence
|
---|
| 27 | of the initramfs and, if found, mounts it as / and runs /init. The init
|
---|
| 28 | program is typically a shell script. Note that the boot process takes
|
---|
| 29 | longer, possibly significantly longer, if an initramfs is used.
|
---|
| 30 | </para>
|
---|
| 31 |
|
---|
| 32 | <para>
|
---|
| 33 | For most distributions, kernel modules are the biggest reason to have
|
---|
| 34 | an initramfs. In a general distribution, there are many unknowns such
|
---|
| 35 | as file system types and disk layouts. In a way, this is the opposite
|
---|
| 36 | of LFS where the system capabilities and layout are known and a custom
|
---|
| 37 | kernel is normally built. In this situation, an initramfs is rarely
|
---|
| 38 | needed.
|
---|
| 39 | </para>
|
---|
| 40 |
|
---|
| 41 | <para>
|
---|
| 42 | There are only four primary reasons to have an initramfs in the LFS
|
---|
| 43 | environment: loading the rootfs from a network, loading it from an LVM
|
---|
| 44 | logical volume, having an encrypted rootfs where a password is required, or
|
---|
| 45 | for the convenience of specifying the rootfs as a LABEL or UUID. Anything
|
---|
| 46 | else usually means that the kernel was not configured properly.
|
---|
| 47 | </para>
|
---|
[5632009] | 48 |
|
---|
| 49 | <sect2 id="initramfs-build">
|
---|
| 50 | <title>Building an initramfs</title>
|
---|
| 51 |
|
---|
[29244b7] | 52 | <para>
|
---|
| 53 | If you do decide to build an initramfs, the following scripts will
|
---|
| 54 | provide a basis to do it. The scripts will allow specifying a rootfs
|
---|
| 55 | via partition UUID or partition LABEL or a rootfs on an LVM logical
|
---|
| 56 | volume. They do not support an encrypted root file system or mounting
|
---|
| 57 | the rootfs over a network card. For a more complete capability see
|
---|
[c9aa980] | 58 | <ulink url="https://www.linuxfromscratch.org/hints/read.html"> the LFS
|
---|
[29244b7] | 59 | Hints</ulink> or <ulink
|
---|
| 60 | url="http://fedoraproject.org/wiki/Dracut">dracut</ulink>.
|
---|
| 61 | </para>
|
---|
[5632009] | 62 |
|
---|
[29244b7] | 63 | <para>
|
---|
| 64 | To install these scripts, run the following commands as the
|
---|
| 65 | <systemitem class="username">root</systemitem> user:
|
---|
| 66 | </para>
|
---|
[5632009] | 67 |
|
---|
| 68 | <screen role="root"><userinput>cat > /sbin/mkinitramfs << "EOF"
|
---|
[51dfb3e] | 69 | <literal>#!/bin/bash
|
---|
[fe58aa0] | 70 | # This file based in part on the mkinitramfs script for the LFS LiveCD
|
---|
[5632009] | 71 | # written by Alexander E. Patrakov and Jeremy Huntwork.
|
---|
| 72 |
|
---|
| 73 | copy()
|
---|
| 74 | {
|
---|
| 75 | local file
|
---|
| 76 |
|
---|
[6c183b56] | 77 | if [ "$2" = "lib" ]; then
|
---|
[99ff4fad] | 78 | file=$(PATH=/lib:/usr/lib type -p $1)
|
---|
[5632009] | 79 | else
|
---|
[99ff4fad] | 80 | file=$(type -p $1)
|
---|
[5632009] | 81 | fi
|
---|
| 82 |
|
---|
[6e493187] | 83 | if [ -n "$file" ] ; then
|
---|
[5632009] | 84 | cp $file $WDIR/$2
|
---|
| 85 | else
|
---|
| 86 | echo "Missing required file: $1 for directory $2"
|
---|
| 87 | rm -rf $WDIR
|
---|
| 88 | exit 1
|
---|
| 89 | fi
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | if [ -z $1 ] ; then
|
---|
| 93 | INITRAMFS_FILE=initrd.img-no-kmods
|
---|
| 94 | else
|
---|
| 95 | KERNEL_VERSION=$1
|
---|
| 96 | INITRAMFS_FILE=initrd.img-$KERNEL_VERSION
|
---|
| 97 | fi
|
---|
| 98 |
|
---|
| 99 | if [ -n "$KERNEL_VERSION" ] && [ ! -d "/lib/modules/$1" ] ; then
|
---|
| 100 | echo "No modules directory named $1"
|
---|
| 101 | exit 1
|
---|
| 102 | fi
|
---|
| 103 |
|
---|
| 104 | printf "Creating $INITRAMFS_FILE... "
|
---|
| 105 |
|
---|
[90c6607] | 106 | binfiles="sh cat cp dd killall ls mkdir mknod mount "
|
---|
[5632009] | 107 | binfiles="$binfiles umount sed sleep ln rm uname"
|
---|
[8b6d8b6] | 108 | binfiles="$binfiles readlink basename"
|
---|
[5632009] | 109 |
|
---|
[f350508] | 110 | # Systemd installs udevadm in /bin. Other udev implementations have it in /sbin
|
---|
| 111 | if [ -x /bin/udevadm ] ; then binfiles="$binfiles udevadm"; fi
|
---|
| 112 |
|
---|
| 113 | sbinfiles="modprobe blkid switch_root"
|
---|
[90c6607] | 114 |
|
---|
[8253f9fc] | 115 | #Optional files and locations
|
---|
[f8f7442] | 116 | for f in mdadm mdmon udevd udevadm; do
|
---|
[8253f9fc] | 117 | if [ -x /sbin/$f ] ; then sbinfiles="$sbinfiles $f"; fi
|
---|
| 118 | done
|
---|
[5632009] | 119 |
|
---|
[288c825] | 120 | # Add lvm if present (cannot be done with the others because it
|
---|
| 121 | # also needs dmsetup
|
---|
| 122 | if [ -x /sbin/lvm ] ; then sbinfiles="$sbinfiles lvm dmsetup"; fi
|
---|
| 123 |
|
---|
[5632009] | 124 | unsorted=$(mktemp /tmp/unsorted.XXXXXXXXXX)
|
---|
| 125 |
|
---|
| 126 | DATADIR=/usr/share/mkinitramfs
|
---|
| 127 | INITIN=init.in
|
---|
| 128 |
|
---|
[f8f7442] | 129 | # Create a temporary working directory
|
---|
[5632009] | 130 | WDIR=$(mktemp -d /tmp/initrd-work.XXXXXXXXXX)
|
---|
| 131 |
|
---|
| 132 | # Create base directory structure
|
---|
[8b6d8b6] | 133 | mkdir -p $WDIR/{bin,dev,lib/firmware,run,sbin,sys,proc,usr}
|
---|
[5632009] | 134 | mkdir -p $WDIR/etc/{modprobe.d,udev/rules.d}
|
---|
| 135 | touch $WDIR/etc/modprobe.d/modprobe.conf
|
---|
| 136 | ln -s lib $WDIR/lib64
|
---|
[8b6d8b6] | 137 | ln -s ../bin $WDIR/usr/bin
|
---|
[5632009] | 138 |
|
---|
| 139 | # Create necessary device nodes
|
---|
| 140 | mknod -m 640 $WDIR/dev/console c 5 1
|
---|
| 141 | mknod -m 664 $WDIR/dev/null c 1 3
|
---|
| 142 |
|
---|
| 143 | # Install the udev configuration files
|
---|
[50f410f] | 144 | if [ -f /etc/udev/udev.conf ]; then
|
---|
| 145 | cp /etc/udev/udev.conf $WDIR/etc/udev/udev.conf
|
---|
| 146 | fi
|
---|
[5632009] | 147 |
|
---|
| 148 | for file in $(find /etc/udev/rules.d/ -type f) ; do
|
---|
| 149 | cp $file $WDIR/etc/udev/rules.d
|
---|
| 150 | done
|
---|
| 151 |
|
---|
[a32a241] | 152 | # Install any firmware present
|
---|
| 153 | cp -a /lib/firmware $WDIR/lib
|
---|
| 154 |
|
---|
[f350508] | 155 | # Copy the RAID configuration file if present
|
---|
[5632009] | 156 | if [ -f /etc/mdadm.conf ] ; then
|
---|
| 157 | cp /etc/mdadm.conf $WDIR/etc
|
---|
| 158 | fi
|
---|
| 159 |
|
---|
| 160 | # Install the init file
|
---|
| 161 | install -m0755 $DATADIR/$INITIN $WDIR/init
|
---|
| 162 |
|
---|
[ea8a884] | 163 | if [ -n "$KERNEL_VERSION" ] ; then
|
---|
| 164 | if [ -x /bin/kmod ] ; then
|
---|
| 165 | binfiles="$binfiles kmod"
|
---|
| 166 | else
|
---|
| 167 | binfiles="$binfiles lsmod"
|
---|
[64cb61a] | 168 | sbinfiles="$sbinfiles insmod"
|
---|
[ea8a884] | 169 | fi
|
---|
| 170 | fi
|
---|
| 171 |
|
---|
[5632009] | 172 | # Install basic binaries
|
---|
| 173 | for f in $binfiles ; do
|
---|
[8b6d8b6] | 174 | if [ -e /bin/$f ]; then d="/bin"; else d="/usr/bin"; fi
|
---|
| 175 | ldd $d/$f | sed "s/\t//" | cut -d " " -f1 >> $unsorted
|
---|
| 176 | copy $d/$f bin
|
---|
[5632009] | 177 | done
|
---|
| 178 |
|
---|
| 179 | for f in $sbinfiles ; do
|
---|
| 180 | ldd /sbin/$f | sed "s/\t//" | cut -d " " -f1 >> $unsorted
|
---|
| 181 | copy $f sbin
|
---|
| 182 | done
|
---|
| 183 |
|
---|
[8253f9fc] | 184 | # Add udevd libraries if not in /sbin
|
---|
| 185 | if [ -x /lib/udev/udevd ] ; then
|
---|
[f350508] | 186 | ldd /lib/udev/udevd | sed "s/\t//" | cut -d " " -f1 >> $unsorted
|
---|
| 187 | elif [ -x /lib/systemd/systemd-udevd ] ; then
|
---|
| 188 | ldd /lib/systemd/systemd-udevd | sed "s/\t//" | cut -d " " -f1 >> $unsorted
|
---|
[8253f9fc] | 189 | fi
|
---|
| 190 |
|
---|
[ea8a884] | 191 | # Add module symlinks if appropriate
|
---|
| 192 | if [ -n "$KERNEL_VERSION" ] && [ -x /bin/kmod ] ; then
|
---|
| 193 | ln -s kmod $WDIR/bin/lsmod
|
---|
| 194 | ln -s kmod $WDIR/bin/insmod
|
---|
| 195 | fi
|
---|
| 196 |
|
---|
[5632009] | 197 | # Add lvm symlinks if appropriate
|
---|
[50f410f] | 198 | # Also copy the lvm.conf file
|
---|
[5632009] | 199 | if [ -x /sbin/lvm ] ; then
|
---|
| 200 | ln -s lvm $WDIR/sbin/lvchange
|
---|
[8253f9fc] | 201 | ln -s lvm $WDIR/sbin/lvrename
|
---|
| 202 | ln -s lvm $WDIR/sbin/lvextend
|
---|
[5632009] | 203 | ln -s lvm $WDIR/sbin/lvcreate
|
---|
| 204 | ln -s lvm $WDIR/sbin/lvdisplay
|
---|
| 205 | ln -s lvm $WDIR/sbin/lvscan
|
---|
| 206 |
|
---|
| 207 | ln -s lvm $WDIR/sbin/pvchange
|
---|
| 208 | ln -s lvm $WDIR/sbin/pvck
|
---|
| 209 | ln -s lvm $WDIR/sbin/pvcreate
|
---|
| 210 | ln -s lvm $WDIR/sbin/pvdisplay
|
---|
| 211 | ln -s lvm $WDIR/sbin/pvscan
|
---|
| 212 |
|
---|
[068c8df] | 213 | ln -s lvm $WDIR/sbin/vgchange
|
---|
[5632009] | 214 | ln -s lvm $WDIR/sbin/vgcreate
|
---|
| 215 | ln -s lvm $WDIR/sbin/vgscan
|
---|
| 216 | ln -s lvm $WDIR/sbin/vgrename
|
---|
| 217 | ln -s lvm $WDIR/sbin/vgck
|
---|
[50f410f] | 218 | # Conf file(s)
|
---|
| 219 | cp -a /etc/lvm $WDIR/etc
|
---|
[5632009] | 220 | fi
|
---|
| 221 |
|
---|
| 222 | # Install libraries
|
---|
[8253f9fc] | 223 | sort $unsorted | uniq | while read library ; do
|
---|
[6e493187] | 224 | # linux-vdso and linux-gate are pseudo libraries and do not correspond to a file
|
---|
| 225 | # libsystemd-shared is in /lib/systemd, so it is not found by copy, and
|
---|
| 226 | # it is copied below anyway
|
---|
| 227 | if [[ "$library" == linux-vdso.so.1 ]] ||
|
---|
| 228 | [[ "$library" == linux-gate.so.1 ]] ||
|
---|
| 229 | [[ "$library" == libsystemd-shared* ]]; then
|
---|
[5632009] | 230 | continue
|
---|
| 231 | fi
|
---|
| 232 |
|
---|
| 233 | copy $library lib
|
---|
| 234 | done
|
---|
| 235 |
|
---|
[f350508] | 236 | if [ -d /lib/udev ]; then
|
---|
| 237 | cp -a /lib/udev $WDIR/lib
|
---|
| 238 | fi
|
---|
| 239 | if [ -d /lib/systemd ]; then
|
---|
| 240 | cp -a /lib/systemd $WDIR/lib
|
---|
| 241 | fi
|
---|
[2f6d8ec] | 242 | if [ -d /lib/elogind ]; then
|
---|
| 243 | cp -a /lib/elogind $WDIR/lib
|
---|
| 244 | fi
|
---|
[5632009] | 245 |
|
---|
| 246 | # Install the kernel modules if requested
|
---|
| 247 | if [ -n "$KERNEL_VERSION" ]; then
|
---|
| 248 | find \
|
---|
| 249 | /lib/modules/$KERNEL_VERSION/kernel/{crypto,fs,lib} \
|
---|
| 250 | /lib/modules/$KERNEL_VERSION/kernel/drivers/{block,ata,md,firewire} \
|
---|
| 251 | /lib/modules/$KERNEL_VERSION/kernel/drivers/{scsi,message,pcmcia,virtio} \
|
---|
| 252 | /lib/modules/$KERNEL_VERSION/kernel/drivers/usb/{host,storage} \
|
---|
| 253 | -type f 2> /dev/null | cpio --make-directories -p --quiet $WDIR
|
---|
| 254 |
|
---|
[8253f9fc] | 255 | cp /lib/modules/$KERNEL_VERSION/modules.{builtin,order} \
|
---|
| 256 | $WDIR/lib/modules/$KERNEL_VERSION
|
---|
| 257 |
|
---|
[5632009] | 258 | depmod -b $WDIR $KERNEL_VERSION
|
---|
| 259 | fi
|
---|
| 260 |
|
---|
| 261 | ( cd $WDIR ; find . | cpio -o -H newc --quiet | gzip -9 ) > $INITRAMFS_FILE
|
---|
| 262 |
|
---|
[6e493187] | 263 | # Prepare early loading of microcode if available
|
---|
| 264 | if ls /lib/firmware/intel-ucode/* >/dev/null 2>&1 ||
|
---|
| 265 | ls /lib/firmware/amd-ucode/* >/dev/null 2>&1; then
|
---|
| 266 |
|
---|
| 267 | # first empty WDIR to reuse it
|
---|
| 268 | rm -r $WDIR/*
|
---|
| 269 |
|
---|
| 270 | DSTDIR=$WDIR/kernel/x86/microcode
|
---|
| 271 | mkdir -p $DSTDIR
|
---|
| 272 |
|
---|
| 273 | if [ -d /lib/firmware/amd-ucode ]; then
|
---|
| 274 | cat /lib/firmware/amd-ucode/microcode_amd*.bin > $DSTDIR/AuthenticAMD.bin
|
---|
| 275 | fi
|
---|
| 276 |
|
---|
| 277 | if [ -d /lib/firmware/intel-ucode ]; then
|
---|
| 278 | cat /lib/firmware/intel-ucode/* > $DSTDIR/GenuineIntel.bin
|
---|
| 279 | fi
|
---|
| 280 |
|
---|
| 281 | ( cd $WDIR; find . | cpio -o -H newc --quiet ) > microcode.img
|
---|
| 282 | cat microcode.img $INITRAMFS_FILE > tmpfile
|
---|
| 283 | mv tmpfile $INITRAMFS_FILE
|
---|
| 284 | rm microcode.img
|
---|
| 285 | fi
|
---|
| 286 |
|
---|
| 287 | # Remove the temporary directories and files
|
---|
[5632009] | 288 | rm -rf $WDIR $unsorted
|
---|
| 289 | printf "done.\n"
|
---|
[51dfb3e] | 290 | </literal>
|
---|
[5712a7d] | 291 | EOF
|
---|
| 292 |
|
---|
[7b82eb14] | 293 | chmod 0755 /sbin/mkinitramfs</userinput></screen>
|
---|
[0d7900a] | 294 |
|
---|
[5632009] | 295 | <screen role="root"><userinput>mkdir -p /usr/share/mkinitramfs &&
|
---|
| 296 | cat > /usr/share/mkinitramfs/init.in << "EOF"
|
---|
[51dfb3e] | 297 | <literal>#!/bin/sh
|
---|
[5632009] | 298 |
|
---|
| 299 | PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
---|
| 300 | export PATH
|
---|
| 301 |
|
---|
| 302 | problem()
|
---|
| 303 | {
|
---|
| 304 | printf "Encountered a problem!\n\nDropping you to a shell.\n\n"
|
---|
| 305 | sh
|
---|
| 306 | }
|
---|
| 307 |
|
---|
| 308 | no_device()
|
---|
| 309 | {
|
---|
| 310 | printf "The device %s, which is supposed to contain the\n" $1
|
---|
| 311 | printf "root file system, does not exist.\n"
|
---|
| 312 | printf "Please fix this problem and exit this shell.\n\n"
|
---|
| 313 | }
|
---|
| 314 |
|
---|
| 315 | no_mount()
|
---|
| 316 | {
|
---|
| 317 | printf "Could not mount device %s\n" $1
|
---|
| 318 | printf "Sleeping forever. Please reboot and fix the kernel command line.\n\n"
|
---|
| 319 | printf "Maybe the device is formatted with an unsupported file system?\n\n"
|
---|
| 320 | printf "Or maybe filesystem type autodetection went wrong, in which case\n"
|
---|
| 321 | printf "you should add the rootfstype=... parameter to the kernel command line.\n\n"
|
---|
| 322 | printf "Available partitions:\n"
|
---|
| 323 | }
|
---|
| 324 |
|
---|
| 325 | do_mount_root()
|
---|
| 326 | {
|
---|
| 327 | mkdir /.root
|
---|
| 328 | [ -n "$rootflags" ] && rootflags="$rootflags,"
|
---|
| 329 | rootflags="$rootflags$ro"
|
---|
| 330 |
|
---|
| 331 | case "$root" in
|
---|
[99ff4fad] | 332 | /dev/* ) device=$root ;;
|
---|
| 333 | UUID=* ) eval $root; device="/dev/disk/by-uuid/$UUID" ;;
|
---|
| 334 | PARTUUID=*) eval $root; device="/dev/disk/by-partuuid/$PARTUUID" ;;
|
---|
| 335 | LABEL=* ) eval $root; device="/dev/disk/by-label/$LABEL" ;;
|
---|
| 336 | "" ) echo "No root device specified." ; problem ;;
|
---|
[5632009] | 337 | esac
|
---|
| 338 |
|
---|
| 339 | while [ ! -b "$device" ] ; do
|
---|
| 340 | no_device $device
|
---|
| 341 | problem
|
---|
| 342 | done
|
---|
| 343 |
|
---|
| 344 | if ! mount -n -t "$rootfstype" -o "$rootflags" "$device" /.root ; then
|
---|
| 345 | no_mount $device
|
---|
| 346 | cat /proc/partitions
|
---|
| 347 | while true ; do sleep 10000 ; done
|
---|
| 348 | else
|
---|
| 349 | echo "Successfully mounted device $root"
|
---|
| 350 | fi
|
---|
| 351 | }
|
---|
| 352 |
|
---|
[2f6d8ec] | 353 | do_try_resume()
|
---|
| 354 | {
|
---|
| 355 | case "$resume" in
|
---|
| 356 | UUID=* ) eval $resume; resume="/dev/disk/by-uuid/$UUID" ;;
|
---|
| 357 | LABEL=*) eval $resume; resume="/dev/disk/by-label/$LABEL" ;;
|
---|
| 358 | esac
|
---|
| 359 |
|
---|
| 360 | if $noresume || ! [ -b "$resume" ]; then return; fi
|
---|
| 361 |
|
---|
| 362 | ls -lH "$resume" | ( read x x x x maj min x
|
---|
| 363 | echo -n ${maj%,}:$min > /sys/power/resume )
|
---|
| 364 | }
|
---|
| 365 |
|
---|
[5632009] | 366 | init=/sbin/init
|
---|
| 367 | root=
|
---|
| 368 | rootdelay=
|
---|
| 369 | rootfstype=auto
|
---|
| 370 | ro="ro"
|
---|
| 371 | rootflags=
|
---|
| 372 | device=
|
---|
[2f6d8ec] | 373 | resume=
|
---|
| 374 | noresume=false
|
---|
[5632009] | 375 |
|
---|
| 376 | mount -n -t devtmpfs devtmpfs /dev
|
---|
[a32a241] | 377 | mount -n -t proc proc /proc
|
---|
| 378 | mount -n -t sysfs sysfs /sys
|
---|
| 379 | mount -n -t tmpfs tmpfs /run
|
---|
[5632009] | 380 |
|
---|
| 381 | read -r cmdline < /proc/cmdline
|
---|
| 382 |
|
---|
| 383 | for param in $cmdline ; do
|
---|
| 384 | case $param in
|
---|
| 385 | init=* ) init=${param#init=} ;;
|
---|
| 386 | root=* ) root=${param#root=} ;;
|
---|
| 387 | rootdelay=* ) rootdelay=${param#rootdelay=} ;;
|
---|
| 388 | rootfstype=*) rootfstype=${param#rootfstype=} ;;
|
---|
| 389 | rootflags=* ) rootflags=${param#rootflags=} ;;
|
---|
[2f6d8ec] | 390 | resume=* ) resume=${param#resume=} ;;
|
---|
| 391 | noresume ) noresume=true ;;
|
---|
[5632009] | 392 | ro ) ro="ro" ;;
|
---|
| 393 | rw ) ro="rw" ;;
|
---|
| 394 | esac
|
---|
| 395 | done
|
---|
| 396 |
|
---|
[8253f9fc] | 397 | # udevd location depends on version
|
---|
| 398 | if [ -x /sbin/udevd ]; then
|
---|
[f350508] | 399 | UDEVD=/sbin/udevd
|
---|
| 400 | elif [ -x /lib/udev/udevd ]; then
|
---|
| 401 | UDEVD=/lib/udev/udevd
|
---|
| 402 | elif [ -x /lib/systemd/systemd-udevd ]; then
|
---|
| 403 | UDEVD=/lib/systemd/systemd-udevd
|
---|
[8253f9fc] | 404 | else
|
---|
[f350508] | 405 | echo "Cannot find udevd nor systemd-udevd"
|
---|
| 406 | problem
|
---|
[8253f9fc] | 407 | fi
|
---|
| 408 |
|
---|
[f350508] | 409 | ${UDEVD} --daemon --resolve-names=never
|
---|
[5632009] | 410 | udevadm trigger
|
---|
| 411 | udevadm settle
|
---|
| 412 |
|
---|
[50f410f] | 413 | if [ -f /etc/mdadm.conf ] ; then mdadm -As ; fi
|
---|
| 414 | if [ -x /sbin/vgchange ] ; then /sbin/vgchange -a y > /dev/null ; fi
|
---|
| 415 | if [ -n "$rootdelay" ] ; then sleep "$rootdelay" ; fi
|
---|
[5632009] | 416 |
|
---|
[2f6d8ec] | 417 | do_try_resume # This function will not return if resuming from disk
|
---|
[5632009] | 418 | do_mount_root
|
---|
| 419 |
|
---|
[f350508] | 420 | killall -w ${UDEVD##*/}
|
---|
[5632009] | 421 |
|
---|
| 422 | exec switch_root /.root "$init" "$@"
|
---|
[51dfb3e] | 423 | </literal>
|
---|
[5632009] | 424 | EOF</userinput></screen>
|
---|
[0d7900a] | 425 |
|
---|
[5632009] | 426 | </sect2>
|
---|
| 427 |
|
---|
| 428 | <sect2 id="initramfs-install">
|
---|
| 429 | <title>Using an initramfs</title>
|
---|
| 430 |
|
---|
[ea8a884] | 431 | <bridgehead renderas="sect3">Required Runtime Dependency</bridgehead>
|
---|
| 432 |
|
---|
| 433 | <para role="required">
|
---|
[96e9478] | 434 | <xref role="runtime" linkend="cpio"/>
|
---|
[ea8a884] | 435 | </para>
|
---|
[20598a7] | 436 |
|
---|
| 437 | <bridgehead renderas="sect3">Other Runtime Dependencies</bridgehead>
|
---|
| 438 |
|
---|
| 439 | <para role="optional">
|
---|
| 440 | <xref role="runtime" linkend="lvm2"/> and/or
|
---|
| 441 | <xref role="runtime" linkend="mdadm"/> must be installed before
|
---|
| 442 | generating the initramfs, if the system partition uses them.
|
---|
| 443 | </para>
|
---|
[ea8a884] | 444 |
|
---|
| 445 | <para condition="html" role="usernotes">User Notes:
|
---|
| 446 | <ulink url="&blfs-wiki;/initramfs"/>
|
---|
| 447 | </para>
|
---|
| 448 |
|
---|
| 449 |
|
---|
[29244b7] | 450 | <para>
|
---|
| 451 | To build an initramfs, run the following as the <systemitem
|
---|
| 452 | class="username">root</systemitem> user:
|
---|
| 453 | </para>
|
---|
[5632009] | 454 |
|
---|
[7b82eb14] | 455 | <screen role="nodump"><userinput>mkinitramfs [KERNEL VERSION]</userinput></screen>
|
---|
[5632009] | 456 |
|
---|
[29244b7] | 457 | <para>
|
---|
| 458 | The optional argument is the directory where the appropriate kernel
|
---|
| 459 | modules are located. This must be a subdirectory of <filename
|
---|
| 460 | class='directory'> /lib/modules</filename>. If no modules are specified,
|
---|
| 461 | then the initramfs is named <emphasis>initrd.img-no-kmods</emphasis>.
|
---|
| 462 | If a kernel version is specified, the initrd is named
|
---|
| 463 | <emphasis>initrd.img-$KERNEL_VERSION</emphasis> and is only appropriate
|
---|
| 464 | for the specific kernel specified. The output file will be placed in the
|
---|
| 465 | current directory.
|
---|
| 466 | </para>
|
---|
[5632009] | 467 |
|
---|
[29244b7] | 468 | <para>
|
---|
| 469 | If early loading of microcode is needed (see <xref
|
---|
| 470 | linkend="cpu-microcode"/>), you can install the appropriate blob or
|
---|
| 471 | container in <filename class="directory">/lib/firmware</filename>.
|
---|
| 472 | It will be automatically added to the initrd when running
|
---|
| 473 | <command>mkinitramfs</command>.
|
---|
| 474 | </para>
|
---|
[6e493187] | 475 |
|
---|
[29244b7] | 476 | <para>
|
---|
| 477 | After generating the initrd, copy it to the <filename
|
---|
| 478 | class='directory'>/boot</filename> directory.
|
---|
| 479 | </para>
|
---|
[5632009] | 480 |
|
---|
[29244b7] | 481 | <para>
|
---|
| 482 | Now edit <filename>/boot/grub/grub.cfg</filename> and add a new
|
---|
| 483 | menuentry. Below are several examples.
|
---|
| 484 | </para>
|
---|
[5632009] | 485 |
|
---|
[7b82eb14] | 486 | <screen role="nodump"><userinput># Generic initramfs and root fs identified by UUID
|
---|
[0d7900a] | 487 | menuentry "LFS Dev (LFS-7.0-Feb14) initrd, Linux 3.0.4"
|
---|
[5632009] | 488 | {
|
---|
| 489 | linux /vmlinuz-3.0.4-lfs-20120214 root=UUID=54b934a9-302d-415e-ac11-4988408eb0a8 ro
|
---|
| 490 | initrd /initrd.img-no-kmods
|
---|
| 491 | }</userinput></screen>
|
---|
| 492 |
|
---|
[7b82eb14] | 493 | <screen role="nodump"><userinput># Generic initramfs and root fs on LVM partition
|
---|
[0d7900a] | 494 | menuentry "LFS Dev (LFS-7.0-Feb18) initrd lvm, Linux 3.0.4"
|
---|
[5632009] | 495 | {
|
---|
| 496 | linux /vmlinuz-3.0.4-lfs-20120218 root=/dev/mapper/myroot ro
|
---|
| 497 | initrd /initrd.img-no-kmods
|
---|
| 498 | }</userinput></screen>
|
---|
| 499 |
|
---|
[7b82eb14] | 500 | <screen role="nodump"><userinput># Specific initramfs and root fs identified by LABEL
|
---|
[0d7900a] | 501 | menuentry "LFS Dev (LFS-7.1-Feb20) initrd label, Linux 3.2.6"
|
---|
[5632009] | 502 | {
|
---|
| 503 | linux /vmlinuz-3.2.6-lfs71-120220 root=LABEL=lfs71 ro
|
---|
| 504 | initrd /initrd.img-3.2.6-lfs71-120220
|
---|
| 505 | }</userinput></screen>
|
---|
| 506 |
|
---|
[29244b7] | 507 | <para>
|
---|
| 508 | Finally, reboot the system and select the desired system.
|
---|
| 509 | </para>
|
---|
[5632009] | 510 |
|
---|
| 511 | </sect2>
|
---|
| 512 |
|
---|
| 513 | </sect1>
|
---|