Write a script to help the installation in a internal drive of a PC

Moderator: BarryK

Post Reply
Caramel
Posts: 476
Joined: Sun Oct 02, 2022 6:25 pm
Location: France
Has thanked: 100 times
Been thanked: 78 times

Write a script to help the installation in a internal drive of a PC

Post by Caramel »

Following the topic Difficulties installing EasyOS and some suggestions, I believe a script to automate the creation of an easyos folder containing the initrd, vmlinuz and easy.sfs files in a partition for installation on an internal hard drive a PC would be useful. The script would be launched from an Easy USB key.

I suggest that we (EasyOS users) collaborate to write it, as my bash knowledge and skills are limited

First ideas :

The script would take as argument the partition where we want to create the folder. The partition would be previously mounted (by EasyOS on the key)

$1 is the first (and only) argument, i.e. the chosen partition (e.g. sdb2)

Testing the existence of /mnt/$1:

Code: Select all

PARTCHOSEN=$1
if [ ! -d "/mnt/PARTCHOSEN" ] ; then
  echo "The partition does not exist or it is not mounted"
  exit 1
fi

EDIT : Very bad, not work !

Checking that $1 is an ext4 partition:
??????

EDIT : the command lsblk -n -o FSTYPE /dev/PARTCHOSEN displays the filesystem type of /dev/$1

creation of the easyos folder:

Code: Select all

mkdir /mnt/PARTCHOSEN/easyos
if [$? = 1 ] ; then
  exit
fi

EDIT : the character $ is missing in this code

copy the initrd and wmlinuz files to the easyos folder:

Code: Select all

cp /mnt/wkg/initrd /mnt/PARTCHOSEN/easyos
cp /mnt/wkg/vmlinuz /mnt/PARTCHOSEN/easyos

EDIT : the character $ is missing in this code

copy of easy.sfs in easyos:

EDIT First try, Bad idea, it will generate an error if the version of EasyOS in use on the stick is not the last version installed.

(These commands are based on lines 1532 and following of the init script)

Code: Select all

VERS="$(ls -l -d /mnt/wkg/releases/easy-* | rev | cut -f 1 -d '-' | rev)"
sortedVERS="$(echo "$VERS" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n)" #lowest to highest.
for LASTVERS in echo "$sortedVERS" | tail -n -1 | tr '\n' ' '`
  do
   cp /mnt/wkg/sfs/easyos/oe/kirstone/easy_${LASTVERS}_amd64.sfs /mnt/PARTCHOSEN/easys.sfs
  done

EDIT New try :

Code: Select all

. /etc/lsb-release # retrieve the variable DISTRIB_RELEASE
cp /mnt/wkg/sfs/easyos/oe/kirstone/easy_${DISTRIB_RELEASE}_amd64.sfs /mnt/PARTCHOSEN/easys.sfs

EDIT : $PARTCHOSEN/easyos/ instead of PARTCHOSEN/

EDIT : it's easy.sfs, not easys.sfs

Thanks for your help

Last edited by Caramel on Wed Dec 13, 2023 9:18 am, edited 13 times in total.
Clarity
Posts: 3842
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1632 times
Been thanked: 525 times

Re: Write a script to help the installation in a internal drive of a PC

Post by Clarity »

If I could offer a corollary where little to no effort would achieve this desire, would @BarryK (and others) be interested.

I have a solution that would NOT involve development work. But there must be some willingness to consider because it is NOT a development effort needing forum support. Further it would address/reduce most-all problems users encourter from the past, IMHO.

It has actually been done, per se. Kinda like; "in plain site (er... 'sight')".

If fact, I foresee the elements offered by the OP @Caramel as having relevance to this as well.

Caramel
Posts: 476
Joined: Sun Oct 02, 2022 6:25 pm
Location: France
Has thanked: 100 times
Been thanked: 78 times

Re: Write a script to help the installation in a internal drive of a PC

Post by Caramel »

Clarity wrote: Sun Dec 03, 2023 12:47 pm

If I could offer a corollary where little to no effort would achieve this desire, would @BarryK (and others) be interested.

I have a solution that would NOT involve development work. But there must be some willingness to consider because it is NOT a development effort needing forum support. Further it would address/reduce most-all problems users encourter from the past, IMHO.

It has actually been done, per se. Kinda like; "in plain site (er... 'sight')".

If fact, I foresee the elements offered by the OP @Caramel as having relevance to this as well.

@Clarity , I didn't really understand

Caramel
Posts: 476
Joined: Sun Oct 02, 2022 6:25 pm
Location: France
Has thanked: 100 times
Been thanked: 78 times

Re: Write a script to help the installation in a internal drive of a PC

Post by Caramel »

Another idea is to copy the easyos folder of the USB stick to the ext4 partition of the PC where EasyOS will be installed.

I have tested, it seems to work. But the encryption is lost (And, anecdotally, there will a partition integrity check at first boot)

Last edited by Caramel on Fri Dec 08, 2023 6:36 pm, edited 2 times in total.
Clarity
Posts: 3842
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1632 times
Been thanked: 525 times

Re: Write a script to help the installation in a internal drive of a PC

Post by Clarity »

Hi @Caramel
An ISO or IMG 'LIve" distro "is already a container to what you are asking to develop".

Your request is about "extraction". Extractions efforts are unnecessary for almost all distros on this forum'; from DOGs to PUPs.
Technology exist negating that need, if employed. Thus it eliminates the many-many problems of users attempting to extract info out for use elsewhere, the problems resulting from extracts, as well as those attempting to create new bootable media.

That's what I was offering to consider and is seen on the EASY forum here.

For the PUPs/DOGs, the systems behave exactly the same as an extraction-fixup you are asking to develop...except the extraction-fixup and future maintenance by some develop would be eliminated, too.

Caramel
Posts: 476
Joined: Sun Oct 02, 2022 6:25 pm
Location: France
Has thanked: 100 times
Been thanked: 78 times

Re: Write a script to help the installation in a internal drive of a PC

Post by Caramel »

My first post was full of errors.

Probably no one cares, or you are too polite to tell me.

First script frugal_install_assistant.sh (it needs a lot of improvements)

Code: Select all

#! /bin/bash

. /usr/bin/gettext.sh 
export TEXTDOMAIN=frugal_install_assistant.sh
export OUTPUT_CHARSET=UTF-8
. /etc/lsb-release # retrieve the variable DISTRIB_RELEASE

CHOSENPART=$(yad --title="$(gettext 'Frugal Install Assistant')" --text="$(gettext 'Choose the partition where to install') EasyOS" --entry)

TYPE=$(lsblk -n -o FSTYPE /dev/$CHOSENPART)
if [ ! "$TYPE" = "ext4" ]; then
yad --title=$(gettext 'Message') --text="/dev/$CHOSENPART $(gettext 'is not an ext4 partition')"
 echo "$(gettext '/dev/')$CHOSENPART $(gettext 'is not an ext4 partition')"
 exit
fi
mount -t ext4 /dev/$CHOSENPART /mnt/$CHOSENPART 2> /dev/null # mount the chosen partition if it is not already mounted, the possible error message is deleted by the code 2> /dev/null
CHOSENREP=$(yad --title="$(gettext 'Frugal Install Assistant')" --text="$(gettext 'Enter the name of a repository where to install') EasyOS.\n$(gettext 'You can choose a sub folder.\nThe default choice is /easyos')" --entry --entry-text='easyos')
if [ "$CHOSENREP" == "" ]; then
 exit
elif [ -d /mnt/$CHOSENPART/$CHOSENREP ] || [ -f /mnt/$CHOSENPART/$CHOSENREP ]; then
 yad --title=$(gettext 'Message') --text="/mnt/$CHOSENPART/$CHOSENREP $(gettext 'already exists')"
 exit
fi
mkdir -p /mnt/$CHOSENPART/$CHOSENREP
cp /mnt/wkg/initrd /mnt/$CHOSENPART/$CHOSENREP
cp /mnt/wkg/vmlinuz /mnt/$CHOSENPART/$CHOSENREP
cp /mnt/wkg/sfs/easyos/oe/kirkstone/easy_${DISTRIB_RELEASE}_amd64.sfs /mnt/$CHOSENPART/$CHOSENREP/easy.sfs

EDIT1 :
addition of the option -p at the command mkdir

EDIT2:
CHOSENREP=$(yad --title="$(gettext 'Frugal Install Assistant')" --text="$(gettext 'Choose the repository where to install') EasyOS" --entry)
if [ -d /mnt/$CHOSENPART/$CHOSENREP ] || [ -f /mnt/$CHOSENPART/$CHOSENREP ]; then
yad --title=$(gettext 'Message') --text="/mnt/$CHOSENPART/$CHOSENREP $(gettext 'already exists')"
exit
fi

was replaced by

CHOSENREP=$(yad --title="$(gettext 'Frugal Install Assistant')" --text="$(gettext 'Enter the name of a repository where to install') EasyOS.\n$(gettext 'You can choose a sub folder.\nThe default choice is /easyos')" --entry --entry-text='easyos')
if [ "$CHOSENREP" == "" ]; then
exit
elif [ -d /mnt/$CHOSENPART/$CHOSENREP ] || [ -f /mnt/$CHOSENPART/$CHOSENREP ]; then
yad --title=$(gettext 'Message') --text="/mnt/$CHOSENPART/$CHOSENREP $(gettext 'already exists')"
exit
fi

EDIT3:
typo corrected easys.sfs replaced by easy.sfs

Caramel
Posts: 476
Joined: Sun Oct 02, 2022 6:25 pm
Location: France
Has thanked: 100 times
Been thanked: 78 times

Re: Write a script to help the installation in a internal drive of a PC

Post by Caramel »

New version.
Kirstone replaced by Scarthgap
Examples of stanzas for boot manager added (Inspired by QV-installer viewtopic.php?p=116473#p116473)

Code: Select all

#! /bin/bash

. /usr/bin/gettext.sh 
export TEXTDOMAIN=frugal_install_assistant.sh
export OUTPUT_CHARSET=UTF-8
. /etc/lsb-release # retrieve the variable DISTRIB_RELEASE

CHOSENPART=$(yad --title="$(gettext 'Frugal Install Assistant')" --text="$(gettext 'Choose the partition where to install EasyOS.\nFor example: sda2, nvme0n1p2.\nIt must be an ext4 type partition')" --entry)
[ $? -ne 0 ] && exit
TYPE=$(lsblk -n -o FSTYPE /dev/$CHOSENPART)
if [ ! "$TYPE" = "ext4" ]; then
yad --title=$(gettext 'Message') --text="/dev/$CHOSENPART $(gettext 'is not an ext4 partition')"
 echo "$(gettext '/dev/')$CHOSENPART $(gettext 'is not an ext4 partition')"
 exit
fi
mount -t ext4 /dev/$CHOSENPART /mnt/$CHOSENPART 2> /dev/null # mount the chosen partition if it is not already mounted, the possible error message is deleted by the code 2> /dev/null
CHOSENDIR=$(yad --title="$(gettext 'Frugal Install Assistant')" --text="$(gettext 'Enter the name of a repository where to install') EasyOS.\n$(gettext 'You can also choose a sub folder like /Easy/Scarthgap.\nThe default choice is /easyos')" --entry --entry-text='easyos')
CHOSENDIR=${CHOSENDIR#/}
if [ "$CHOSENDIR" == "" ]; then
 exit
elif [ -d /mnt/$CHOSENPART/$CHOSENDIR ] || [ -f /mnt/$CHOSENPART/$CHOSENDIR ]; then
 yad --title=$(gettext 'Message') --text="/mnt/$CHOSENPART/$CHOSENDIR $(gettext 'already exists')"
 exit
fi
mkdir -p /mnt/$CHOSENPART/$CHOSENDIR
echo
echo "$(gettext 'Start copying files on /mnt/$CHOSENPART/$CHOSENDIR')"
cp /mnt/wkg/initrd /mnt/$CHOSENPART/$CHOSENDIR
cp /mnt/wkg/vmlinuz /mnt/$CHOSENPART/$CHOSENDIR
cp /mnt/wkg/sfs/easyos/oe/scarthgap/easy_${DISTRIB_RELEASE}_amd64.sfs /mnt/$CHOSENPART/$CHOSENDIR/easy.sfs

echo
echo "$(gettext 'Copy of the files finished')"
WKG_DEV=$CHOSENPART
WKG_DIR=$CHOSENDIR

WBLKID="$(blkid /dev/${WKG_DEV} | tr ' ' '\n')"
WKG_LABEL="$(echo "$WBLKID" | grep '^LABEL=' | cut -f 2 -d '"')"
WKG_UUID="$(echo "$WBLKID" | grep '^UUID=' | cut -f 2 -d '"')"

KCMD="rw wkg_uuid=${WKG_UUID} wkg_dir=$WKG_DIR" # options to pass to kernel


echo
echo "$(gettext 'If you need to make a bootloader menu entry, pass these parameters on the kernel command line')"
echo "$KCMD"
echo
echo "$(gettext 'Here is an example entry for the menu.lst file in GRUB4DOS:')"
echo "title EasyOS Scartgap (partition $CHOSENPART, folder $CHOSENDIR)
  find --set-root uuid () ${WKG_UUID}
  kernel /${CHOSENDIR}/vmlinuz ${KCMD}
  initrd /${CHOSENDIR}/initrd"

echo
echo "$(gettext 'Here is an example menu entry for /etc/grub.d/40_custom in GRUB2:')"
echo "menuentry EasyOS Scartgap (partition $CHOSENPART, folder $CHOSENDIR) {
 insmod ext2
 insmod search_fs_uuid
 search --no-floppy --fs-uuid --set=root ${WKG_UUID}
 linux /${CHOSENDIR}/vmlinuz ${KCMD} 
 initrd /${CHOSENDIR}/initrd
}"

 echo
 echo "$(gettext 'Here is an example entry for the limine.cfg file in Limine bootloader:')"
 echo ":EasyOS Scarthgap
    PROTOCOL=linux
    KERNEL_PATH=uuid://${WKG_UUID}/${CHOSENDIR}/vmlinuz
    MODULE_PATH=uuid://${WKG_UUID}/${CHOSENDIR}/initrd
    KERNEL_CMDLINE=${KCMD}"
 echo
 echo "$(gettext 'Here is an example entry for the refind.conf file in rEFInd boot-manager:')"
 echo "menuentry \"EasyOS Scarthgap (${WKG_DEV})\" {
 volume ${WKG_LABEL}
 loader /${CHOSENDIR}/vmlinuz
 initrd /${CHOSENDIR}/initrd
 ostype Linux
 options \"${KCMD}\"
}"
User avatar
pp4mnklinux
Posts: 1139
Joined: Wed Aug 19, 2020 5:43 pm
Location: Edinburgh
Has thanked: 637 times
Been thanked: 284 times
Contact:

Re: Write a script to help the installation in a internal drive of a PC

Post by pp4mnklinux »

Caramel wrote: Fri Dec 08, 2023 6:28 pm

Another idea is to copy the easyos folder of the USB stick to the ext4 partition of the PC where EasyOS will be installed.

I have tested, it seems to work. But the encryption is lost (And, anecdotally, there will a partition integrity check at first boot)

That's the way... 4 me, haha.

viewtopic.php?t=12137

Essential.- EasyOS requires a partition with ext4 filesystem.

Nowadays, the easier to install, the more interesting for everybody.

https://easyosinstall.wordpress.com/202 ... ng-easyos/

MikeAndreas1
Posts: 1
Joined: Fri Jul 12, 2024 11:54 am

Re: Write a script to help the installation in a internal drive of a PC

Post by MikeAndreas1 »

Caramel wrote: Sun Dec 03, 2023 9:47 am

Following the topic Difficulties installing EasyOS and some suggestions, I believe a script to automate the creation of an easyos folder containing the initrd, vmlinuz and easy.sfs files in a partition for installation on an internal hard drive a PC would be useful. The script would be launched from an Easy USB key.

I suggest that we (EasyOS users) collaborate to write it, as my bash knowledge and skills are limited

First ideas :

The script would take as argument the partition where we want to create the folder. The partition would be previously mounted (by EasyOS on the key)

$1 is the first (and only) argument, i.e. the chosen partition (e.g. sdb2)

Testing the existence of /mnt/$1:

Code: Select all

PARTCHOSEN=$1
if [ ! -d "/mnt/PARTCHOSEN" ] ; then
  echo "The partition does not exist or it is not mounted"
  exit 1
fi

EDIT : Very bad, not work !

Checking that $1 is an ext4 partition:
??????

EDIT : the command lsblk -n -o FSTYPE /dev/PARTCHOSEN displays the filesystem type of /dev/$1

creation of the easyos folder:

Code: Select all

mkdir /mnt/PARTCHOSEN/easyos
if [$? = 1 ] ; then
  exit
fi

EDIT : the character $ is missing in this code

copy the initrd and wmlinuz files to the easyos folder:

Code: Select all

cp /mnt/wkg/initrd /mnt/PARTCHOSEN/easyos
cp /mnt/wkg/vmlinuz /mnt/PARTCHOSEN/easyos

EDIT : the character $ is missing in this code

copy of easy.sfs in easyos:

EDIT First try, Bad idea, it will generate an error if the version of EasyOS in use on the stick is not the last version installed.

(These commands are based on lines 1532 and following of the init script)

Code: Select all

VERS="$(ls -l -d /mnt/wkg/releases/easy-* | rev | cut -f 1 -d '-' | rev)"
sortedVERS="$(echo "$VERS" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n)" #lowest to highest.
for LASTVERS in echo "$sortedVERS" | tail -n -1 | tr '\n' ' '`
  do
   cp /mnt/wkg/sfs/easyos/oe/kirstone/easy_${LASTVERS}_amd64.sfs /mnt/PARTCHOSEN/easys.sfs
  done

EDIT New try :

Code: Select all

. /etc/lsb-release # retrieve the variable DISTRIB_RELEASE
cp /mnt/wkg/sfs/easyos/oe/kirstone/easy_${DISTRIB_RELEASE}_amd64.sfs /mnt/PARTCHOSEN/easys.sfs

EDIT : $PARTCHOSEN/easyos/ instead of PARTCHOSEN/

EDIT : it's easy.sfs, not easys.sfs

Thanks for your help

Could you clarify what specific issues you're encountering with your current script? Are there particular steps that are causing errors or not behaving as expected?

Caramel
Posts: 476
Joined: Sun Oct 02, 2022 6:25 pm
Location: France
Has thanked: 100 times
Been thanked: 78 times

Re: Write a script to help the installation in a internal drive of a PC

Post by Caramel »

MikeAndreas1 wrote: Fri Jul 12, 2024 12:00 pm

Could you clarify what specific issues you're encountering with your current script? Are there particular steps that are causing errors or not behaving as expected?

After the numerous corrections in EDIT, the scripts (version Kirsktone/ version Scarthgap) work for me.

They could be used from an usb stick or from the internal drive for making a new install (frugal install with the same version of EasyOS as that used during installation)

Caramel
Posts: 476
Joined: Sun Oct 02, 2022 6:25 pm
Location: France
Has thanked: 100 times
Been thanked: 78 times

Re: Write a script to help the installation in a internal drive of a PC

Post by Caramel »

Script easy-install ( for the EasyOS Scarthgap series):

This script helps to install EasyOS on a directory of an ext4 partition.
It must be used on a running EasyOS. It copies the 3 files (vmlinuz, initrd and esy.sfs) needed for an install to the directory choosen.
It asks for the name of the partition (examples: sda3, nvme0n1p2) and then the name of the choosen directory. (No folder or file with that name must already exist in the partition)

If the partition is not mounted, the script mount it ( Example /dev/sda3 is mounted in /mnt/sda3. If /dev/sda3 was already mounted elsewhere, the script will fail)

If the script was launched in a terminal,

(for example, if the script is in /files/downloads/, with the command

Code: Select all

/files/downloads/install-easy 

)
it displays stanza to add to config files of a already installed bootloader grub4dos, grub2, limine or rEFInd.

install-easy.gz
(3.23 KiB) Downloaded 12 times

Remane it install-easy and make it executable :

Code: Select all

cd /files/downloads
mv install-easy.gz install-easy
chmod +x install-easy

OR

install-easy.gz
(1.29 KiB) Downloaded 9 times

(actual compressed file)
Decompress it (For example by clicking on it and then click on the OK of the dialog window)

Post Reply

Return to “EasyOS”