How to install GhostBSD-Arm64 into a USB Flash Drive stick April 24, 2024 update edition.

 How to install GhostBSD-Arm64 into a USB Flash Drive stick January 5, 2024 edition, update April 24 2024

The steps below are based on using a Raspberry Pi 4B,3B,400 computer, running sh shell scripts using FreeBSD or GhostBSD-ARM64.   

1.)  You can  may run these scripts on a standard X86_64 PC booting a live image of https://GhostBSD.org/download   "latest build" or the regular released version, then written to a USB flash Drive for booting up a live media version of GhostBSD or 
 
booting a snapshot .ISO image of FreeBSD.
https://freebsd.org/where   FreeBSD.org/where   13.2-RELEASE or 14.0-RELEASE

2.)  Balena Etcher Tool for Windows and Linux to burn an image file into a USB flash drive

3.)  http://ghostbsdarm64.hopto.org/packages/  Directory of  images you can download.
 
Download this 728 Mbyte image and XZ decompress into a full 12Gbyte image.  Then use a software or tool means to write into the USB flash drive of 16GB to 256Gb size.  USB SSD are much faster the USB Flash Sticks.

 or better yet, Use the write_freebsd_image_file* shell script to perform the download, decompress, and the dd write into a USB flash drive /dev/da1  ( or da0) set by DISK1 value.
This shell script write_freebsd_img*.sh  can be edited and modified to execute on a Linux host machine. and maybe with a little effort execute  under WSL2  Windows Subsystem for Linux.

camcontrol devlist
geom disk list
gpart show -lp      see what disk drives are available
Use this script file that will automatically download and decompress the 700MB file into a 12 GB bootable image file.  That takes about 850 seconds (~14 minutes) to decompress.  This script will  dd write the image file into /dev/da1  or da0.   DISK1=/dev/da1 ; export DISK1   Set "DISK1" value first before running the script.  Download this one shell script 6kbyte file.  or use from the ssd_test directory.  http://ghostbsdarm64.hopto.org/packages/write_freebsd_img_dd_to_da1.sh

Details on how the bootable image file was created, with reference to a Klara Systems article.


February 3, 2024  New Method to create a bootable Raspberry Pi 4B,3B,400 USB Flash Drive stick.  Using shell script files

Download these  two  tar files:    STILL a WIP to update files inside these tar.xz file

View the README.txt files inside these tar files:  
tar xvzf  create_ssd*.xz tar xvzf gh14_jan01*.xz
You will have 2 directories created with the shell scripts inside:   ssd_test  &  create_disk .   ssd_test files are a modification of the files used in the  create_disk directory

gpart show -lp          see what disks are available to use with the gpart command.
echo " ${DISK1} <--- This is the DISK1 environmental variable, set example: DISK1=/dev/da1; export DISK1 "

1.)  write_freebsd_img_file_dd_to_da1.sh  Start with this script to download, decompress, & write an image into a USB flash disk drive stick
script will Resize the 10G UFS partition image to a better larger size to fit in your USB flash drive stick.
next boot your Raspberry Pi 4B,3B,400 with this USB flash drive stick.  You can edit -s80G to your preferred size for your USB Flash Drive.
2.)  You can boot this image written onto the USB Flash Drive stick by placing this USB stick in your Raspberry Pi unit USB 3.0 blue Connector.
connect the  4 other cables, RJ45 Ethernet, HDMI cable to the port close to the USB-C port and the other end to the HDMI Input on the TV, Mouse, Keyboard, and  and last turn on the power by plugging in the UBC-C cable.  Now watch the video serial output as the Raspberry Pi boots up.
login:  root    GhostBSD: no password           FreeBSD: 'root'  password

If you don't have ethernet cable plugged in to Raspberry Pi and the screen is stuck with NTPD setting the current time,  Hit control-C to end the script and get to login: prompt.   You might have to comment out the NTPD commands in the /etc/rc.conf file if you don't reach the login prompt and don't have an ethernet cable from a router to plug in the RJ-45 connector on the Raspberry Pi 4B hardware.

3.)  Might have to manually fetch the updated GhostBSD.conf from the ghostbsdarm64.hopto.org server.


cd  /usr/local /etc/pkg/repos ;  fetch  http://ghostbsdarm64.hopto.org/packages/GhostBSD.conf
adduser  your_user_name     create a common user with password.  create multiple users if you wish.
cd /root  ; pkg update
cd ssd_test ;  ls -lht ; ls -lht ../create_disk 

4.)  create_disk_da1_ssd_partitions.sh  This will create 7 partitions on a USB SSD pointed to by
  ${DISK1} environmental variable.    echo ${DISK1}

5.)  copy_usb_flash_esp_to_ZFS_msdos_ESP.sh  This copies from /mnt/esp or /dev/da0p1 files into directory /mnt/msdos_ESP or  /dev/da1p1 ; the ESP EFI FAT32 partition.  Check file content details, like file config.txt values to match your Raspberry Pi model 4B or other models.

6.)  create_GhostBSD_Arm64_ZPOOL_ZFS_on_da1.sh  This creates the ZFS file systems, that will copy the root file system files  from root '/' in the UFS file system on the USB flash drive into the ZFS file system alternate root mountpoint /zpialt on the USB SSD.  This is a 350GB size partition referenced by device name /dev/da1p3 or gpt label name /dev/gpt/rootfs.  You may change the size of the created partition in step 2.)  above.

7.) XFCE_Install  ./create_distk/xfce_install_AK_Aunby.sh  execute this shell script.  Edit lightdm or slim  to match your needs.
pkg install -y xorg xfce xfce4-goodies lightdm  

Windows or Linux command line download using Curl or Wget.



curl http://ghostbsdarm64.hopto.org/packages/write_freebsd_img_file_dd_to_da1.sh
wget -c http://ghostbsdarm64.hopto.org/packages/write_freebsd_img_file_dd_to_da1.sh




A couple more screen shots of XFCE on Raspberry Pi 4B
Telegram on the first picture; Poudriere Builder on the 2nd

Old previous manual steps that work.  I prefer you to use the 4 shell script file steps above

Use this image,  Ghost14_5g_selfbuilt_raspi4b_Feb27_2.img.xz  version.
Sha512sum  Ghost14_5g_selfbuilt_raspi4b_Feb27_2.img.xz
xz --decompress --keep --verbose Ghost14*.img.xz 
Sha512sum  Ghost14_5g_selfbuilt_raspi4b_Feb27_2.img.xz

Check that we have the correct images by comparing checksums and have a correct download.  
X = 0, 1, 2  Use a 16GB- 256GB USB Flash disk stick,  USB 3.2 or USB 2.0 interface
dd if=Ghost14_5g_selfbuilt_raspi4b_Feb27_2.img of=/dev/daX bs=1M conv=sync status=progress

Resize the Partition in the USB Flash Drive Stick and GrowFS the file system


With partitioned mounted copy the files off to another medium
su - ;  mkdir /mnt/tmp1root ; mkdir /mnt/rootfs ; mkdir /home/da1_rootfs
mount /dev/da1p3 /mnt/rootfs  
cp -pr  /mnt/rootfs/  /home/da1_rootfs    Copy off the files from /mnt/rootfs  to /home/da1_rootfs directory
cd /  ;  umount /dev/da1p3 ; mount  ; df -h

gpart resize -i 3 -a 4k -s 80G da1    #  resize the 3rd partition UFS type on a 128Gbyte to 80Gbyte size
resize the UFS partition first,  growfs the file system second.

Use resize command with the disk name, ada0, ada1 da0, da1

camcontrol devlist
geom disk list
gpart status da1
gpart show -lp da1
gpart resize -i 3 -s 15G -a 4k ada0
growfs ada0p3 
gpart resize -i 3 -a 4k da1
growfs da1p3 

Reference, How to create a MBR FAT32 formatted USB. 

devicename=/dev/da1
gpart create -s MBR ${devicename}
gpart -t fat32 ${devicename}
newfs_msdos -F 32 -L  thumbdrive ${devicename}s1
copy the above 4 lines into a shell script file: make_fat32_thumbdrive.sh
chmod +x make_fat32_thumbdrive.sh

Reference, How to create a GPT FAT32 formatted USB. 

devicename=/dev/da1
gpart create -s GPT $ve{devicename}
gpart -t fat32 -l gpt_thumbdrive ${devicename}
newfs_msdos -F 32 -L  thumbdrive  ${devicename}p1
copy the above 4 lines into a shell script file: make_fat32_thumbdrive.sh
chmod +x make_fat32_thumbdrive.sh

Mount FAT32 Thumbdrive to a mount point and access files.

su - 
mkdir /mnt/esp 
sudo mount_msdosfs /dev/da0p1 /mnt/esp
cd /mnt/esp  ;  ls -lht ; cat config.txt 

Setup Desktop Environment,  XFCE

pkg install xorg xfce xfce4-goodies lightdm abiword dia tree
https://mabufs.com/blog/freebsd-xinitrc    Xinitrc contents for various Desktop Environment Like Cinanmon, Lumina DE, fluxbox



Here assume a blank unpartitioned SSD  interfaced to a USB cable,  either SATA 2.5" inch drive with a Sabrent USB 3.0 to SATA converter cable, or a USB 3.0 to NVMe stick in a Aluminum case like UGreen NVME PCIe   commands  camcontrol devlist ; gpart status  and gpart show -lp  should indicate which drive letters are assigned to the unpartitioned SSD connected through a USB 3.0 cable.  Was not necessary to install any software device drivers.  Did not use  nvmecontrol ns  identify  commands with the Ugreen aluminum case with the NVMe 500GB stick mounted inside.



https://www.amazon.com/s?k=Ugreen  Ugreen Amazon Store USA


Assume we are booted up from the USB flash drive and running GhostBSD-Arm64_Dec12_3.img version.
Download this tar compressed file tar.xz  
cd /home/fred
tar xvzf gh14_jan01_arm64_create_disk.tar.xz   ./

root@Ghost14-selfbuilt-rpi4B-nginx-tst1:/mnt/rootfs/root/create_disk # ls -lht *.sh
-rwxr-xr-x  1 root wheel  2.6K Dec 31 21:41 GhostBSD_Arm64_ZPOOL_ZFS_create_2A.sh
-rwxr-xr-x  1 root wheel  5.5K Dec 31 21:02 GhostBSD_AK_Aunby_Arm64_create_shell_script.sh
-rwxr-xr-x  1 root wheel  5.0K Dec 31 18:00 GhostBSD_AK3_Aunby.sh
-rwxr-xr-x  1 root wheel  2.3K Dec 29 23:59 xfce_install_AK_Aunby.sh
-rwxr-xr-x  1 root wheel  850B Dec 29 23:46 xfce_install.sh
-rwxr-xr-x  1 root wheel  658B Dec 29 21:34 dd_ghost14.sh
-rwxr-xr-x  1 root wheel  1.9K Dec 24 21:27 GhostBSD_AK2save_Aunby_Arm64_create_shell_script.sh
-rwxr-xr-x  1 root wheel  657B Dec 18 11:18 gh14_arm64_create_disk.sh
-rwxr-xr-x  1 root wheel  513B Dec 18 11:16 systst2.sh
-rwxr-xr-x  1 root wheel  1.8K Dec 17 22:08 GhostBSD_Arm64_ZPOOL_ZFS_create.sh



Now plug in a blank unpartitioned & unformatted USB SATA or SSD drive.   
camcontrol devlist
geom disk list
gparted status
gparted show -lp

gpart destroy da1     OR     gpart destroy -F da1

cd create_disk ;  cat ./gh14_arm64_create_disk.sh ;  edit the value $USB_SSD or $DISK1  to  /dev/da1
./gh14_arm64_create_disk.sh     # create the 7 paritions on the SSD.

./GhostBSD_Arm64_ZPOOL_ZFS_create_2A.sh   create the ZPOOL from a single partition /dev/da1p3
#  Create the ZFS file systems,  and then copy all the existing files from the booted, running USB flash drive stick onto the USB 3.0 SSD disk.    Finally shutdown.  Wait until all the file buffers are synced up and the terminate screen goes black.  Pull out the existing USB Flash Drive Stick with the partition using a UFS file system.   Reboot the System with the USB 3.0 SSD still plugged in.  This should boot up as a ZFS partition  "boot on root" configuration.

You might have to repair a couple files, and modify whether to boot from an ethernet cable network connection or  a USB wifi dongle wireless connection.
5 files are important   /etc/fstab  /boot/loader.conf  /boot/defaults/loader.conf  /etc/rc.conf /etc/wpa_supplicant.conf 

Fred L. Finster

Ugreen Aluminum Case,  USB Vendor, Product IDs RealTek 0x0bda : 0x9210 USB to NVMe

fred@rpi-Ghost4B-test-Dec12-3:/root/ssd_test $ sudo usbconfig
Password:
ugen0.1: <(0x1106) XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.2: <vendor 0x2109 USB2.0 Hub> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (100mA)
ugen0.3: <Logitech Logitech USB Optical Mouse> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)
ugen0.4: <Primax Lenovo Traditional USB Keyboard> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (98mA)
ugen0.5: <Ugreen Ugreen Storage Device> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (224mA)
ugen0.6: <Kingston DataTraveler 3.0> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (36mA)


fred@rpi-Ghost4B-test-Dec12-3:/root/ssd_test $ sudo usbconfig -d ugen0.5 dump_device_desc
ugen0.5: <Ugreen Ugreen Storage Device> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (224mA)

  bLength = 0x0012 
  bDescriptorType = 0x0001 
  bcdUSB = 0x0320 
  bDeviceClass = 0x0000  <Probed by interface class>
  bDeviceSubClass = 0x0000 
  bDeviceProtocol = 0x0000 
  bMaxPacketSize0 = 0x0009 
  idVendor = 0x0bda 
  idProduct = 0x9210 
  bcdDevice = 0x2001 
  iManufacturer = 0x0001  <Ugreen>
  iProduct = 0x0002  <Ugreen Storage Device>
  iSerialNumber = 0x0003  <0129380524CE>
  bNumConfigurations = 0x0001 

fred@rpi-Ghost4B-test-Dec12-3:/root/ssd_test $ 

Comments

Popular posts from this blog

FreeBSD 14.0 Compiling kernel for Raspberry Pi 4B

HDMI Audio sound patches into GhostBSD source code /usr/ghost14/ghostbsd-src SOLVED Jan20 2024