From Fedora Project Wiki

 
(20 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{admon/note | Note | for older method (namely for Fedora 23) using livecd-tools ('''livecd-creator''') visit https://fedoraproject.org/wiki/How_to_create_and_use_a_Live_CD}}
{{admon/note | Note | If you simply want to burn a pre-made ISO to a disc, visit http://fedoraproject.org/en/get-fedora to download a LiveCD or LiveDVD, then see the [http://docs.fedoraproject.org/install-guide/ install guide] or [http://docs.fedoraproject.org/readme-burning-isos/ burning how-to] for further instructions.}}
{{admon/note | Note | If you simply want to burn a pre-made ISO to a disc, visit http://fedoraproject.org/en/get-fedora to download a LiveCD or LiveDVD, then see the [http://docs.fedoraproject.org/install-guide/ install guide] or [http://docs.fedoraproject.org/readme-burning-isos/ burning how-to] for further instructions.}}




=='''livemedia-creator'''==
=='''livemedia-creator'''==
=== Documentation ===
* Livemedia Creator: http://weldr.io/lorax/livemedia-creator.html
* Kickstart: https://github.com/rhinstaller/pykickstart/blob/master/docs/kickstart-docs.rst
=== Setup Environment ===
==== Cloud Base/Vagrant ====
If using the cloud base or vagrant images, install the needed kernel modules:


===Install files===
# dnf install kernel-modules-$(uname -r)
*'''ksflatten is part of pykickstart'''
 
==== Install Mock ====
You should always do all work in mock, this will allow you to ensure that the compose environment matches the target environment.


  # dnf install mock
  # dnf install mock
  # usermod -a -G mock <user>
  # usermod -a -G mock <user>


=== Documentation ===
=== Setup Build Environment ===
*Important
To setup a Fedora 27 x86_64 environment use mock to setup and install tools.
: http://lorax.readthedocs.io/en/latest/livemedia-creator.html
 
: https://github.com/rhinstaller/lorax/blob/master/docs/livemedia-creator.rst
==== Init Environment ====
$ mock -r fedora-27-x86_64 --init
$ mock -r fedora-27-x86_64 --install lorax-lmc-novirt vim-minimal pykickstart


=== mock ===
==== Get kickstarts ====
you should always do all work in mock, this will allow you to ensure that the compose environment matches the target environment
The official Fedora kickstarts are stored in [https://pagure.io/fedora-kickstarts a git repository]. The 'master' branch is for Rawhide; there are branches for each release as well. You can use a kickstart from this repository (on the correct branch for whatever release you want your live image to be) as a base. You could also take a fully flattened kickstart from [http://koji.fedoraproject.org/koji/tasks?state=closed&view=flat&method=createLiveMedia&order=-id a recent official live image compose task] as a base.


to setup a Fedora 25 x86_64 environment you would run the following
If you wanted a different arch or release you would use the correct mock configuration file.


$ mock -r fedora-25-x86_64 --init
==== SELinux ====
$ mock -r fedora-25-x86_64 --install lorax-lmc-novirt git vim-minimal pykickstart
If your system is using SELinux, it needs to be set to Permissive mode while running lorax.


if you wanted a different arch or release you would use the correct mock configuration file
$ sudo setenforce 0


=== kickstarts ===
=== Running a Compose ===
inside the mock chroot, clone the kickstarts
Go into your prepared environment to do a compose.


$ sudo setenforce 0
  $ mock -r fedora-27-x86_64 --shell --old-chroot --enable-network
  $ mock -r fedora-25-x86_64 --shell
  <mock-chroot> sh-4.3#
  <mock-chroot> sh-4.3# git clone https://pagure.io/fedora-kickstarts.git
 
==== Flatten a Kickstart ====
The official Fedora spins are composed from templates. Flattening fully resolves the templates to a valid kickstart which can be fed to livemedia-creator. After copying a base kickstart into the mock environment, you can flatten it with e.g.:
 
<mock-chroot> sh-4.3# ksflatten --config fedora-live-soas.ks -o flat-fedora-live-soas.ks --version F27


=== ksflatten ===  
==== Create the Live Image ====
change directory into fedora-kickstarts and flatten a kickstart
Run livemedia-creator with the flattened kickstart and relevant options. This creates a Sugar on a Stick live iso that also has EFI/Mac booting support.
<mock-chroot> sh-4.3# cd fedora-kickstarts
<mock-chroot> sh-4.3# ksflatten -v, --config fedora-live-soas.ks -o flat-fedora-live-soas.ks --version F25


===livemedia-creator example===
  <mock-chroot> sh-4.3# livemedia-creator --ks flat-fedora-live-soas.ks --no-virt --resultdir /var/lmc --project Fedora-soas-Live --make-iso --volid Fedora-SoaS-27 --iso-only --iso-name Fedora-SoaS-27-x86_64.iso --releasever 27 --macboot
  <mock-chroot> sh-4.3# livemedia-creator --ks flat-fedora-live-soas.ks --no-virt --resultdir /var/lmc --project Fedora-soas-Live --make-iso --volid Fedora-SoaS-25 --iso-only --iso-name Fedora-SoaS-25-x86_64.iso --releasever 25 --title Fedora-SoaS-live --macboot


=== Make a remix ===
===== Example Output =====
*edit the bottom of the flat-fedora-live-soas.ks
<mock-chroot> sh-4.4# livemedia-creator --ks flat-fedora-live-soas.ks --no-virt --resultdir /var/lmc --project Fedora-soas-Live --make-iso --volid Fedora-SoaS-27 --iso-only --iso-name Fedora-SoaS-27-x86_64.iso --releasever 27 --macboot
:that you produced with ksflatten (above)
2018-04-13 01:36:05,320: livemedia-creator v27.11-1
:in this section of the flattened.ks:
  2018-04-13 01:36:05,399: disk_img = /var/lmc/lmc-disk-1t7520xh.img
%packages
2018-04-13 01:36:05,400: Using disk size of 5122MiB
:add a program  (add name)
2018-04-13 01:36:05,983: Running anaconda.
:'''-''' delete a program ( put - in front)
2018-04-13 01:36:07,427: Starting installer, one moment...
:put '''#''' in front of listed program to not install it
2018-04-13 01:36:07,428: terminal size detection failed, using default width
2018-04-13 01:36:07,428: anaconda 27.20.4-1 for Fedora-soas-Live 27 (pre-release) started.
2018-04-13 01:36:07,428: 01:36:07 Not asking for VNC because of an automated install
2018-04-13 01:36:07,428: 01:36:07 Not asking for VNC because of an automated install
2018-04-13 01:36:07,428: 01:36:07 Not asking for VNC because we don't have Xvnc
2018-04-13 01:36:07,428: 01:36:07 Not asking for VNC because we don't have Xvnc
2018-04-13 01:36:07,597: Processing logs from ('127.0.0.1', 36114)
2018-04-13 01:37:03,791: Starting automated install........................................................
2018-04-13 01:37:03,792: ================================================================================
2018-04-13 01:37:03,792: ================================================================================
2018-04-13 01:37:03,793: Installation
2018-04-13 01:37:03,793:
2018-04-13 01:37:03,793: 1) [x] Language settings                2) [x] Time settings
2018-04-13 01:37:03,793: (English (United States))                (US/Eastern timezone)
2018-04-13 01:37:03,793: 3) [x] Installation source              4) [x] Software selection
2018-04-13 01:37:03,793: (...)                                                      (Custom software selected)
2018-04-13 01:37:03,793: 5) [x] Network configuration            6) [ ] User creation
2018-04-13 01:37:03,793: (No network devices available)          (No user will be created)
2018-04-13 01:37:03,793:
2018-04-13 01:37:03,793: ================================================================================
2018-04-13 01:37:03,793: ================================================================================
2018-04-13 01:37:03,793: Progress
2018-04-13 01:37:03,793:
2018-04-13 01:37:03,793: Setting up the installation environment
2018-04-13 01:37:04,534: Configuring storage
2018-04-13 01:37:04,535: Running pre-installation scripts
2018-04-13 01:37:04,627: Running pre-installation tasks
2018-04-13 01:38:30,542: Installing.
2018-04-13 01:38:30,542: Starting package installation process
2018-04-13 01:38:30,542: Downloading packages
2018-04-13 01:41:39,991: Configuring storage
2018-04-13 01:41:39,991: Performing post-installation setup tasks
2018-04-13 01:41:40,670: Configuring installed system
2018-04-13 01:41:40,723: Creating users
2018-04-13 01:41:40,724: Configuring addons
2018-04-13 01:41:58,165: Generating initramfs
2018-04-13 01:42:11,649: Running post-installation scripts
2018-04-13 01:42:11,649: Storing configuration files and kickstarts
2018-04-13 01:42:49,377: Shutting down log processing
2018-04-13 01:42:50,189: Disk Image install successful
2018-04-13 01:42:50,190: working dir is /var/tmp/lmc-work-8c_bx5tx
2018-04-13 01:46:57,049: Rebuilding initrds
2018-04-13 01:46:57,049: dracut args = ['--xz', '--add', 'livenet dmsquash-live convertfs pollcdrom qemu qemu-net', '--omit', 'plymouth', '--no-hostonly', '--debug', '--no-early-microcode']
2018-04-13 01:46:57,050: rebuilding boot/initramfs-4.15.15-300.fc27.x86_64.img
2018-04-13 01:47:45,442: Building boot.iso
2018-04-13 01:47:45,528: running x86.tmpl
2018-04-13 01:48:13,968: Disk image erased
2018-04-13 01:48:14,709: SUMMARY
2018-04-13 01:48:14,709: -------
2018-04-13 01:48:14,709: Logs are in /usr/share/spin-kickstarts
2018-04-13 01:48:14,709: Results are in /var/lmc


====kickstart-docs====
==== Compose Results ====
* https://github.com/rhinstaller/pykickstart/blob/master/docs/kickstart-docs.rst
The resulting images will be located in the mock chroot. Copy them somewhere outside of the mock-chroot.


====livemedia-creator terminal output====
  $ cp /var/lib/mock/fedora-27-x86_64/root/var/lmc/*.iso $HOME
:Build takes a long time wait for completion
:
  [root@localhost pagure]# livemedia-creator --ks /home/(user)/Downloads/pagure/flat-fedora-live-soas.ks --no-virt --resultdir /var/lmc --project Fedora-soas-Live --make-iso --volid Fedora-SoaS-f24 --iso-only --iso-name Fedora-SoaS-f24.iso --releasever 24 --title Fedora-SoaS-live --macboot
/usr/lib64/python3.5/optparse.py:999: PendingDeprecationWarning: The KSOption class is deprecated and will be removed in pykickstart-3.  Use the argparse module instead.
  option = self.option_class(*args, **kwargs)
2016-07-08 11:27:53,350: disk_size = 5122MiB
2016-07-08 11:27:53,351: disk_img = /var/lmc/lmc-disk-7mztqnci.img
2016-07-08 11:27:58,818: Running anaconda.
2016-07-08 11:28:01,751: Processing logs from ('127.0.0.1', 48934)
2016-07-08 11:28:04,776: Starting installer, one moment...
2016-07-08 11:28:04,776: terminal size detection failed, using default width
2016-07-08 11:28:04,776: anaconda 24.13.7-1 for Fedora-soas-Live 24 (pre-release) started.
2016-07-08 11:28:04,776: The 'logging' function is not a part of DNF API and will be removed in the upcoming DNF release. Please use only officially supported API functions. DNF API documentation is available at https://dnf.readthedocs.org/en/latest/api.html.
2016-07-08 11:29:01,131: Starting automated install........................................................
2016-07-08 11:29:01,146: ================================================================================
..........clip........
..........clip........
2016-07-08 11:50:37,613: Disk Image install successful
2016-07-08 11:50:37,613: working dir is /var/tmp/lmc-work-ey7rlb4p
2016-07-08 12:02:35,166: Rebuilding initrds
2016-07-08 12:02:35,166: dracut args = ['--xz', '--add', 'livenet dmsquash-live convertfs pollcdrom qemu qemu-net', '--omit', 'plymouth', '--no-hostonly', '--debug', '--no-early-microcode']
2016-07-08 12:02:35,167: rebuilding boot/initramfs-4.6.3-300.fc24.x86_64.img
2016-07-08 12:03:57,231: Building boot.iso
2016-07-08 12:03:57,328: running x86.tmpl
2016-07-08 12:04:37,262: Disk image erased
2016-07-08 12:04:37,945: SUMMARY
2016-07-08 12:04:37,945: -------
2016-07-08 12:04:37,946: Logs are in /home/(user)/Downloads/pagure
2016-07-08 12:04:37,946: Results are in /var/lmc


===Retrieve finished live.iso===
Note: The location will be different based on your mock configuration.
"Results are in /var/lib/mock/<mock config>/root/var/lmc"
*start files application
*click on '''Files system'''
:open  /var folder
:open lmc folder
*click on the '''.....iso''' you just built
'''copy to''' (mouse right click) '''Home''' with files application
*Check that it is in Home


===Clean Up===
=== Cleanup ===
* delete the instance in /var
We can now safely clean up the build environment and set SELinux back to enforcing.
:delete the /var/lmc directory  (cannot run new build unless this is done?)


  [root@localhost pagure]# cd /var
  $ mock -r fedora-27-x86_64 --clean
[root@localhost var]# ls
  $ sudo setenforce 1
account  adm  cache  crash  db  empty  ftp  games  gopher  kerberos  lib  lmc  local  lock  log  mail  nis  opt  preserve  run  spool  tmp  www  yp
[root@localhost var]# rm -r lmc
rm: descend into directory 'lmc'? y
rm: remove regular file 'lmc/Fedora-SoaS-f24.iso'? y
rm: remove directory 'lmc'? y
  [root@localhost var]#

Latest revision as of 14:55, 30 September 2020

Note.png
Note
If you simply want to burn a pre-made ISO to a disc, visit http://fedoraproject.org/en/get-fedora to download a LiveCD or LiveDVD, then see the install guide or burning how-to for further instructions.


livemedia-creator

Documentation

Setup Environment

Cloud Base/Vagrant

If using the cloud base or vagrant images, install the needed kernel modules:

# dnf install kernel-modules-$(uname -r)

Install Mock

You should always do all work in mock, this will allow you to ensure that the compose environment matches the target environment.

# dnf install mock
# usermod -a -G mock <user>

Setup Build Environment

To setup a Fedora 27 x86_64 environment use mock to setup and install tools.

Init Environment

$ mock -r fedora-27-x86_64 --init
$ mock -r fedora-27-x86_64 --install lorax-lmc-novirt vim-minimal pykickstart

Get kickstarts

The official Fedora kickstarts are stored in a git repository. The 'master' branch is for Rawhide; there are branches for each release as well. You can use a kickstart from this repository (on the correct branch for whatever release you want your live image to be) as a base. You could also take a fully flattened kickstart from a recent official live image compose task as a base.

If you wanted a different arch or release you would use the correct mock configuration file.

SELinux

If your system is using SELinux, it needs to be set to Permissive mode while running lorax.

$ sudo setenforce 0

Running a Compose

Go into your prepared environment to do a compose.

$ mock -r fedora-27-x86_64 --shell --old-chroot --enable-network
<mock-chroot> sh-4.3#

Flatten a Kickstart

The official Fedora spins are composed from templates. Flattening fully resolves the templates to a valid kickstart which can be fed to livemedia-creator. After copying a base kickstart into the mock environment, you can flatten it with e.g.:

<mock-chroot> sh-4.3# ksflatten --config fedora-live-soas.ks -o flat-fedora-live-soas.ks --version F27

Create the Live Image

Run livemedia-creator with the flattened kickstart and relevant options. This creates a Sugar on a Stick live iso that also has EFI/Mac booting support.

<mock-chroot> sh-4.3# livemedia-creator --ks flat-fedora-live-soas.ks --no-virt --resultdir /var/lmc --project Fedora-soas-Live --make-iso --volid Fedora-SoaS-27 --iso-only --iso-name Fedora-SoaS-27-x86_64.iso --releasever 27 --macboot
Example Output
<mock-chroot> sh-4.4# livemedia-creator --ks flat-fedora-live-soas.ks --no-virt --resultdir /var/lmc --project Fedora-soas-Live --make-iso --volid Fedora-SoaS-27 --iso-only --iso-name Fedora-SoaS-27-x86_64.iso --releasever 27 --macboot
2018-04-13 01:36:05,320: livemedia-creator v27.11-1
2018-04-13 01:36:05,399: disk_img = /var/lmc/lmc-disk-1t7520xh.img
2018-04-13 01:36:05,400: Using disk size of 5122MiB
2018-04-13 01:36:05,983: Running anaconda.
2018-04-13 01:36:07,427: Starting installer, one moment...
2018-04-13 01:36:07,428: terminal size detection failed, using default width
2018-04-13 01:36:07,428: anaconda 27.20.4-1 for Fedora-soas-Live 27 (pre-release) started.
2018-04-13 01:36:07,428: 01:36:07 Not asking for VNC because of an automated install
2018-04-13 01:36:07,428: 01:36:07 Not asking for VNC because of an automated install
2018-04-13 01:36:07,428: 01:36:07 Not asking for VNC because we don't have Xvnc
2018-04-13 01:36:07,428: 01:36:07 Not asking for VNC because we don't have Xvnc
2018-04-13 01:36:07,597: Processing logs from ('127.0.0.1', 36114)
2018-04-13 01:37:03,791: Starting automated install........................................................
2018-04-13 01:37:03,792: ================================================================================
2018-04-13 01:37:03,792: ================================================================================
2018-04-13 01:37:03,793: Installation
2018-04-13 01:37:03,793: 
2018-04-13 01:37:03,793: 1) [x] Language settings                 2) [x] Time settings
2018-04-13 01:37:03,793: (English (United States))                (US/Eastern timezone)
2018-04-13 01:37:03,793: 3) [x] Installation source               4) [x] Software selection
2018-04-13 01:37:03,793: (...)                                                      (Custom software selected)
2018-04-13 01:37:03,793: 5) [x] Network configuration             6) [ ] User creation
2018-04-13 01:37:03,793: (No network devices available)           (No user will be created)
2018-04-13 01:37:03,793: 
2018-04-13 01:37:03,793: ================================================================================
2018-04-13 01:37:03,793: ================================================================================
2018-04-13 01:37:03,793: Progress
2018-04-13 01:37:03,793: 
2018-04-13 01:37:03,793: Setting up the installation environment
2018-04-13 01:37:04,534: Configuring storage
2018-04-13 01:37:04,535: Running pre-installation scripts
2018-04-13 01:37:04,627: Running pre-installation tasks
2018-04-13 01:38:30,542: Installing.
2018-04-13 01:38:30,542: Starting package installation process
2018-04-13 01:38:30,542: Downloading packages
2018-04-13 01:41:39,991: Configuring storage
2018-04-13 01:41:39,991: Performing post-installation setup tasks
2018-04-13 01:41:40,670: Configuring installed system
2018-04-13 01:41:40,723: Creating users
2018-04-13 01:41:40,724: Configuring addons
2018-04-13 01:41:58,165: Generating initramfs
2018-04-13 01:42:11,649: Running post-installation scripts
2018-04-13 01:42:11,649: Storing configuration files and kickstarts
2018-04-13 01:42:49,377: Shutting down log processing
2018-04-13 01:42:50,189: Disk Image install successful
2018-04-13 01:42:50,190: working dir is /var/tmp/lmc-work-8c_bx5tx
2018-04-13 01:46:57,049: Rebuilding initrds
2018-04-13 01:46:57,049: dracut args = ['--xz', '--add', 'livenet dmsquash-live convertfs pollcdrom qemu qemu-net', '--omit', 'plymouth', '--no-hostonly', '--debug', '--no-early-microcode']
2018-04-13 01:46:57,050: rebuilding boot/initramfs-4.15.15-300.fc27.x86_64.img
2018-04-13 01:47:45,442: Building boot.iso
2018-04-13 01:47:45,528: running x86.tmpl
2018-04-13 01:48:13,968: Disk image erased
2018-04-13 01:48:14,709: SUMMARY
2018-04-13 01:48:14,709: -------
2018-04-13 01:48:14,709: Logs are in /usr/share/spin-kickstarts
2018-04-13 01:48:14,709: Results are in /var/lmc

Compose Results

The resulting images will be located in the mock chroot. Copy them somewhere outside of the mock-chroot.

$ cp /var/lib/mock/fedora-27-x86_64/root/var/lmc/*.iso $HOME

Note: The location will be different based on your mock configuration.

Cleanup

We can now safely clean up the build environment and set SELinux back to enforcing.

$ mock -r fedora-27-x86_64 --clean
$ sudo setenforce 1