Thinstation / thinstation

A framework for making thin and light Linux based images for x86 based machines and thinclients.
https://www.thinstation.net/
804 stars 187 forks source link

Install ThinStation to Hdd #836

Closed SajjadSabzkar closed 3 weeks ago

SajjadSabzkar commented 3 months ago

Hello. I want to install Thin Station on the hard drive and don't need flash or CD anymore. What is the proposed solution?

SajjadSabzkar commented 2 months ago

any solution?

Thinstation commented 2 months ago

There have been several solutions over the years. There is the hdupdate package, the local-install package. Both might need some polishing. There is the installer package, which is what is used for the DevStation install. Some did some work to make it more generic, but I think that mode might need some maintenance as well. 

It's pretty easy to make a script and that does the installing for you. Here is an example. 

!/bin/bash

if [ "$1" == "-f" ]; then     FORCE=true else     unset FORCE fi

if [ -b /dev/sda ]; then     DRIVE=/dev/sda     p="" elif [ -b /dev/nvme0n1 ]; then     DRIVE=/dev/nvme0n1     p=p fi

Check if the first partition exists

if [ ! -b ${DRIVE}${p}1 ] || [ -n "$FORCE" ]; then   # Create partition table   /sbin/parted $DRIVE --script mklabel msdos

  # Create the 'boot' partition with a size of 4GB   /sbin/parted $DRIVE --script mkpart primary 1MiB 4GiB

  # Create the 'home' partition with the remaining space   /sbin/parted $DRIVE --script mkpart primary 4GiB 100%

  # Wait a bit for the partition table to be recognized   sleep 2   blockdev --rereadpt $DRIVE   sleep 2      # Format the 'boot' partition as VFAT and label it   /sbin/mkfs.vfat -F 32 -n BOOT ${DRIVE}${p}1

  # Format the 'home' partition as ext4, label it, and force overwrite if necessary   /sbin/mkfs.ext4 -F -L home ${DRIVE}${p}2      echo "Partitions created and labeled successfully."      # Copy the ISO to the boot partition   mkdir -p /mnt/boot   mount ${DRIVE}${p}1 /mnt/boot   cp -a /mnt/cdrom0/* /mnt/boot/      echo -e "\nInstalling Master Boot Record"   dd if=/mnt/boot/boot/grub/boot.img of=$DRIVE bs=446 count=1   dd if=/mnt/boot/boot/grub/core.img of=$DRIVE bs=512 seek=1      sync   

  reboot

else   echo "The first partition already exists. Exiting without changes."   echo "Use -f to force install." fi

SajjadSabzkar commented 2 months ago

thanks for your answer. Is it possible to add this bash to the project automatically so that it is available inside /usr/local/bin or any other path after the iso is built?

Thinstation commented 2 months ago

You can make a package that has the script in bin/ For dependencies, also include linux-util and parted packages.

There is too much variation in disk layout to make this a permanent fixture. What I provided you is a cut down of something that I use for another project. Extend it to meet your own needs.

SajjadSabzkar commented 2 months ago
 echo -e "\nInstalling Master Boot Record"
  dd if=/mnt/boot/boot/grub/boot.img of=$device bs=446 count=1
  dd if=/mnt/boot/boot/grub/core.img of=$device bs=512 seek=1

$device Where does it refer to?

Thinstation commented 2 months ago

It's worked out at the top the script.

SajjadSabzkar commented 2 months ago

It's worked out at the top the script. On Tuesday, July 9, 2024 at 03:33:19 AM MDT, Sajjad Sabzkar @.> wrote: $device Where does it refer to? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

$DRIVE only defined by that script. i'm try by install boot on first partition but not worked, for example i have '/dev/sda' as $DRIVE and i use

 dd if=/mnt/boot/boot/grub/boot.img of=/dev/sda1 bs=446 count=1
 dd if=/mnt/boot/boot/grub/core.img of=/dev/sda1  bs=512 seek=1

what is problem?

Thinstation commented 2 months ago

You don't want to write the boot sectors to the first partition, you want to write them to the first sector of the driver itself.

Correct is of=/dev/sda, Wrong is of=/dev/sda1

Thinstation commented 2 months ago

I updated the above script for reference.

SajjadSabzkar commented 2 months ago

thanks for your help, my issue solved but your script need to update. dos not defined by mklabel

 /sbin/parted $DRIVE --script mklabel dos

to

  /sbin/parted $DRIVE --script mklabel msdos
SajjadSabzkar commented 2 months ago

thins Apparently he could not load '/boot/boot/lib.squash'

Thinstation commented 2 months ago

You need an fstab entry that will mount your partition at /boot

SajjadSabzkar commented 2 months ago

When I change the /etc/fstab file, it returns to the default state after restarting

Thinstation commented 2 months ago

add this to your thinstation.conf.buildtime, assuming you made the label BOOT MOUNT_0="LABEL=BOOT     /boot           auto    x-mount.mkdir,defaults  0       0"

SajjadSabzkar commented 2 months ago

Thanks, that's work.

SajjadSabzkar commented 2 months ago

In order to be more consistent with the document and ready files, I suggest that this line /sbin/mkfs.vfat -F 32 -n BOOT ${DRIVE}${p}1 be changed to this /sbin/mkfs.vfat -F 32 -n boot ${DRIVE}${p}1 in default thinstation.conf.buildtime have MOUNT_0="LABEL=boot /boot auto x-mount.mkdir,defaults 0 0"

SajjadSabzkar commented 2 months ago

It is very strange to me that I change the name of the boot partition from large-case to small-case and I also make this change in the thinstation.conf.buildtime file, the system is not able to load.