Partitions and folder structure
There are two partitions on the Beckhoff TwinCAT/BSD installer stick, a FreeBSD partition with a read-only Unix file system (UFS) and a FAT partition for storing backups and scripts that can be used to automate processes. Make sure that the FAT partition is set up only after the USB stick is booted for the first time.
If you insert the USB stick into an industrial PC directly after creation, the FAT partition is initially called BHF-PREOP. Only when you boot from the USB stick for the first time, the FAT partition is renamed to BHF.
On the FAT partition there are two folders and a readme file with short description of all folders. The installer folder contains folders for SSH keys, logs and everything to automate processes with the TwinCAT/BSD installer stick.
Backups created with the TwinCAT/BSD installer stick are stored in a separate folder with the file extension *.tcbkp00. Since it is a FAT partition, the maximum size of a single file is 4 GB. If the backup exceeds the 4 GB, the backup will be split into several parts of 4 GB.
The installer folder contains further subfolders, which on the one hand contain sample scripts and on the other hand can be used to save own scripts for automating processes with the TwinCAT/BSD installer stick. For example, scripts can be created to run immediately after installation to customize a freshly installed image to your needs. Or scripts can be used that automatically backup or restore a TwinCAT/BSD system as soon as the TwinCAT/BSD installer stick is plugged in.
The samples listed are not exhaustive and other scenarios for the use of scripts are conceivable. The following table describes in which directory the scripts for each task must be placed in order to function properly.
Directory | Description |
---|---|
/INSTALLER | Base directory for files that are not backup data. |
/INSTALLER/.ssh | Copy your public key here to connect to the TwinCAT/BSD installer via SSH. You must enable the "start_ssh_server" example to connect. The sample is already in the Autorun folder by default. |
/INSTALLER/autorun | Scripts stored here are automatically executed in alphabetical order after booting. |
/INSTALLER/logs | Here you can find log files of autorun scripts. |
/INSTALLER/autorun_samples | Folder with ready samples. All scripts from the sample folder must be copied to the /INSTALLER/autorun/ directory to perform a specific task (e.g. start_ssh_server). |
/INSTALLER/autorun_samples/start_ssh_server | This sample starts the SSH daemon to enable SSH connections and runs by default. |
/INSTALLER/autorun_samples/autoinstall_tcbsd | Sample for the automatic installation of TwinCAT/BSD. The system is installed on the largest available hard disk by default. A specific hard disk can be configured as a parameter in the script. The default password for the installed system is provided as an environment variable and can be customized in the script. |
/INSTALLER/autorun_samples/auto_backup | Sample for the automatic backup of a TwinCAT/BSD system. The script searches for a TwinCAT/BSD system by looking for a hard disk that contains a pool "zroot". A backup is generated with a file name from the host name of the system and the current timestamp and stored in the \INSTALLER directory. |
/INSTALLER/autorun_samples/auto_restore | Sample for the automatic restore of a TwinCAT/BSD backup. You can select the target hard disk by a parameter in the script. Additionally, you can select a backup file by its name as a pattern (e.g. ".tcbkp" for each backup or "backup1.tcbkp00" for a specific backup). By default, available backups are listed alphabetically by their file extension. The first one is selected for recovery and restored to the largest available hard disk if no disk is specified. |
/INSTALLER/post_install.d | This folder contains scripts designed to modify the installed system. The scripts must have one of the following names:
|
/INSTALLER/runonce.d | The contents of this folder are copied to the "runonce" folder in the installed system. Scripts in the Runonce folder are executed once and then disabled by moving them to either "runonce.d/succeeded" or "runonce.d/failed". This is helpful if the industrial PC has to be booted once, for example if certain kernel modules are required that can only be loaded after booting. |
/autorun_preop.sh | Executed during the first boot of the TwinCAT/BSD installer to make device-specific adjustments. |