3

we often deal with some machines with ubuntu live cd.

Most of the times there's lot of repetitive tasks we have to do in order to have our ubuntu live cd gets ready.

I would like to know how create a ubuntu 18.04 live cd with the following features:

  • first of all start with the most updated 18.04 packages so that there are smaller updates once the system starts (I would like to avoid use the first 18.04 build iso from April 2018..)

then

  • 1) start as toram, like when you go in f6, additional commands and write "toram" at start so that all system goes in ram and you can remove the cd after the loading.

  • 2) set the keymap to sweden

  • 3) disable both WIFI and BlueTooth, basically what appens when you turn the Airplane mode ON

  • 4) enable the universe and multiverse repository (my guess is there's something that could be added via sed to /etc/apt/sources.list )

  • 5) do an apt-get update then apt-get upgrade assuming yes to all file replacements (avoiding rebooting the machines because makes no sense)

  • 6) do an apt-get -y install screen unzip unrar rsync lm-sensors htop sysstat iftop ncdu fuse sshfs curlftpfs netcat-openbsd cifs-utils nfs-common portmap ntfs-3g samba exfat-fuse exfat-utils hfsplus hfsutils hfsprogs ncdu iotop dstat nmap because often i like to have this packets mounted for operate

  • 7) remove all the icons from the launchbar (eg. the music player, the sound one..) adding instead only firefox, gedit and terminal

  • 8) set the gedit size to 18

  • 9) disable the previews of files inside nautilus

I would like to have all of this already done so that when all loading is finished and I have to operate to my machine I can focus directly on other operations!

user3450548
  • 423
  • 1
  • 4
  • 9
  • Based on your exacting requirements, you're looking more for automation and configuration toolsets like Ansible or Chef. – Mark Sep 22 '19 at 12:20
  • @Mark those tools are designed to be unattended nodes to being controlled externally via net, I need an ubuntu live cd with a simple automated script at startup.. – user3450548 Sep 22 '19 at 12:26
  • Actually @user3450547 the tools I've cited are for configuration management, which is what you've described. Do they require a network for access? yes. If you want air-gapped nodes that spin up from a media-based stored image (e.g. DVD) then you need to add that to your description and create a custom image as described below using a kickstart script. If you want that to happen on a network look at iPXE. – Mark Sep 22 '19 at 16:07
  • Doing an upgrade on a Live USB will generally break it. Unless you are using the USB to install Ubuntu you might consider doing a Full install to USB, or install using an image file. (mkusb or Image Writer) – C.S.Cameron Sep 22 '19 at 17:30
  • @C.S.Cameron, This is often the case, I think particularly because the persistent live drive is small (and maybe because it is slow and the buffers get jammed). I have tested sudo apt update && sudo apt full-upgrade for a long time on a system in a USB SSD, with plenty of space for persistence and good speed, and it works well. (But of course, the installed new kernels will not get activated, because the linux system is started before the overlay for persistence is performed.) – sudodus Sep 24 '19 at 12:08
  • 1
    @sudodus : It is only when the USB casper-rw file or folder gets filled that it fails, but my experience is the drive gets filled fast when doing upgrades. This may not be an immediate problem with large casper-rw partitions. It is murder with 4GB casper-rw Persistence files. Usually better to do Full installs if planning on keeping the drive for a while. – C.S.Cameron Sep 24 '19 at 16:14

2 Answers2

5

You can achieve this with CUBIC https://launchpad.net/cubic

Note:
Tested the created Custom ISO with live USB with UEFI Boot Mode
Custom ISO Created with Ubuntu 18.04 with CUBIC and the ISO Ubuntu 18.04.3

Please see the Short Videos first before proceeding:

  1. customized Grub color: https://i.stack.imgur.com/Ba5Z7.jpg

  2. gnome-terminal execution: Exec=gnome-terminal -- /usr/bin/myscript.sh https://i.stack.imgur.com/xm8JP.jpg

  3. script running, language, fav-apps: https://i.stack.imgur.com/BZTby.jpg


from the 9 Points you mentioned..

the order of Points varies like this..

  1. for point

    (4) enable the universe and multiverse repository (my guess is there's something that could be added via sed to /etc/apt/sources.list )

in chroot environment of CUBIC run the below command

add-apt-repository multiverse
  1. for points

    (2) set the keymap to sweden

    (7) remove all the icons from the launchbar (eg. the music player, the sound one..) adding instead only firefox, gedit and terminal

    (8) set the gedit size to 18

    (9) disable the previews of files inside nautilus

paste the below content in a text file out side CUBIC, named 20_my-settings.gschema.override

# Custom Settings for keyboard-layout fav-apps, gedit & nautilus #

[org.gnome.desktop.input-sources]
sources = [('xkb', 'se'), ('xkb', 'us')]

[org.gnome.shell]
favorite-apps = [ 'firefox.desktop', 'gedit.desktop', 'gnome-terminal.desktop' ]

[org.gnome.gedit.preferences.editor]
use-default-font = false
editor-font = 'Monospace 18'

[org.gnome.nautilus.preferences]
show-image-thumbnails = 'never'

in chroot environment of CUBIC, run

cd /usr/share/glib-2.0/schemas/ 

then drag and drop the 20_my-settings.gschema.override file & click on COPY (green-highlighted)

to compile these new custom settings, run

glib-compile-schemas .
  1. for Points

    (3) disable both WIFI and BlueTooth, basically what appens when you turn the Airplane mode ON

    (5) do an apt-get update then apt-get upgrade assuming yes to all file replacements (avoiding rebooting the machines because makes no sense)

    (6) do an apt-get -y install screen unzip unrar rsync lm-sensors htop sysstat iftop ncdu fuse sshfs curlftpfs netcat-openbsd cifs-utils nfs-common portmap ntfs-3g samba exfat-fuse exfat-utils hfsplus hfsutils hfsprogs ncdu iotop dstat nmap because often i like to have this packets mounted for operate

paste the below content in a text file out side CUBIC, named myscript.sh

#!/bin/bash

sudo rfkill block wifi bluetooth
sudo apt update && sudo apt upgrade
sudo apt -y install screen unzip unrar rsync lm-sensors htop sysstat iftop ncdu fuse sshfs curlftpfs netcat-openbsd cifs-utils nfs-common portmap ntfs-3g samba exfat-fuse exfat-utils hfsplus hfsutils hfsprogs ncdu iotop dstat nmap

in chroot environment of CUBIC, run

cd /usr/bin/

then drag and drop the myscript.sh file & click on COPY (green-highlighted)

chmod 777 myscript.sh
  1. paste the below content in a text file out side of CUBIC named autostart.desktop

Content:

[Desktop Entry]
Type=Application
Exec=gnome-terminal -- /usr/bin/myscript.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=run-myscript
X-GNOME-Autostart-Delay=20
Comment=Run's My Custom Script after 20seconds of Login
Name[en_IN]=autostart.desktop

run

cd /etc/xdg/autostart/

then drag and drop the autostart.desktop file & click on COPY (green-highlighted)

run

chmod 777 autostart.desktop
  1. for point

    (1) start as toram, like when you go in f6, additional commands and write "toram" at start so that all system goes in ram and you can remove the cd after the loading.

Proceed with Next (green Highlighted) in CUBIC and at "Generate" screen edit the kernel parameter to add the option toram

  1. Click on Generate --> Finish --> Close in CUBIC.. and your Custom ISO is ready..

Some Screenshots while doing this work

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

PRATAP
  • 22,460
3

Creating a custom iso file to use as a live CD/DVD disk

It is rather complicated to create a custom iso file to use in a CD/DVD drive.

You can find many links via the internet, but unfortunately several of them are obsolete.


Creating USB drives is easier but will not create read-only systems

You can do most if not all these tasks with a

It is also possible to create a

sudodus
  • 46,324
  • 5
  • 88
  • 152
  • My main point using a live cd is that I could be 100% sure that is read only and always the same each time I access to a machine that's why I seriously avoid USB drives / keys. I think it shouldn't be so difficult.. basically I'm asking a way to run an unattended script that does various tasks at startup of the cd on a 18.04 environment.. – user3450548 Sep 22 '19 at 10:16
  • I see your point. It is possible to make a custom iso file and there are threads here at AskUbuntu as well as elsewhere via the internet describing current but also obsolete methods. If you are lucky you will find a method, that works early in your search process. I have done such tasks, but it was more than 3 years ago, and you may need newer tools/methods. Anyway, good luck :-) – sudodus Sep 22 '19 at 10:24
  • Yeah indeed I found some answers but them are very outdated and I hope someone could help me on ubuntu 18.04 now in 2019 :) – user3450548 Sep 22 '19 at 10:26
  • I added some links (that may help you) to the answer. – sudodus Sep 22 '19 at 12:02
  • thanks, I'm in short of time for actual testing but as soon as possible I will try something, hoping that someone could put additional infos on the board ;) – user3450548 Sep 22 '19 at 12:23
  • between step 3 & 4 you are using LAN connection? – PRATAP Sep 22 '19 at 12:24
  • @PRATAP yeah sorry for not specifying but yes the computer is connected via lan cable with a router that gives him via dhcp an ip - so I don't need wifi or bluetooth – user3450548 Sep 22 '19 at 12:32
  • Hi.. the point you mentioned about F6.. are you trying to Boot in BIOS mode or UEFI?? – PRATAP Sep 22 '19 at 13:30
  • @user3450548, I think that PRATAP wrote a great answer for you. – sudodus Sep 23 '19 at 18:17
  • @PRATAP no, it's just after you started booting from cd, there's the keyboard = person logo, if you hit F6 you go to the main menu, at this point if you press f6 again and then esc you could write inside the boot options "toram" that allows you to run the live cd in ram, so after the system is finally booted you can remove the cd/dvd :) – user3450548 Sep 24 '19 at 12:00
  • Hi.. for BIOS mode F6.. for UEFI its just the key e for edit – PRATAP Sep 24 '19 at 12:17
  • Editing the boot options: In BIOS mode it boots via syslinux and you use F6. In UEFI mode it boots via grub and you use the key e. Installed Ubuntu systems boot via grub also in BIOS mode, and you use the key e. – sudodus Sep 24 '19 at 12:44