Sunday 24 May 2020

Creating a multiboot USB CD

Work on an Ubuntu machine.

https://wiki.archlinux.org/index.php/Multiboot_USB_drive#Hybrid_UEFI_GPT_.2B_BIOS_GPT.2FMBR_boot

https://www.funtoo.org/Partitioning_using_gdisk

Insert the USB into an Ubuntu computer. Make sure all partitions have been deleted.
Make sure it has GPT tables installed.

Use gdisk

This configuration is useful for creating a universal USB key, bootable everywhere. First of all you must create a GPT partition table on your device. You need at least 3 partitions:
  1. A BIOS boot partition (gdisk type code EF02). This partition must be 1 MiB in size
  2. An EFI System partition (gdisk type code EF00 with a FAT32 filesystem). This partition can be as small as 50 MiB.
  3. Your data partition (use a filesystem supported by GRUB). This partition can take up the rest of the space of your drive.


Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-60088286, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-60088286, default = 60088286) or {+-}size{KMGTP}: +1M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): l
0700 Microsoft basic data  0c01 Microsoft reserved    2700 Windows RE          
3000 ONIE boot             3001 ONIE config           3900 Plan 9              
4100 PowerPC PReP boot     4200 Windows LDM data      4201 Windows LDM metadata
4202 Windows Storage Spac  7501 IBM GPFS              7f00 ChromeOS kernel     
7f01 ChromeOS root         7f02 ChromeOS reserved     8200 Linux swap          
8300 Linux filesystem      8301 Linux reserved        8302 Linux /home         
8303 Linux x86 root (/)    8304 Linux x86-64 root (/  8305 Linux ARM64 root (/)
8306 Linux /srv            8307 Linux ARM32 root (/)  8400 Intel Rapid Start   
8e00 Linux LVM             a000 Android bootloader    a001 Android bootloader 2
a002 Android boot          a003 Android recovery      a004 Android misc        
a005 Android metadata      a006 Android system        a007 Android cache       
a008 Android data          a009 Android persistent    a00a Android factory     
a00b Android fastboot/ter  a00c Android OEM           a500 FreeBSD disklabel   
a501 FreeBSD boot          a502 FreeBSD swap          a503 FreeBSD UFS         
a504 FreeBSD ZFS           a505 FreeBSD Vinum/RAID    a580 Midnight BSD data   
a581 Midnight BSD boot     a582 Midnight BSD swap     a583 Midnight BSD UFS    
a584 Midnight BSD ZFS      a585 Midnight BSD Vinum    a600 OpenBSD disklabel   
a800 Apple UFS             a901 NetBSD swap           a902 NetBSD FFS          
a903 NetBSD LFS            a904 NetBSD concatenated   a905 NetBSD encrypted    
a906 NetBSD RAID           ab00 Recovery HD           af00 Apple HFS/HFS+      
af01 Apple RAID            af02 Apple RAID offline    af03 Apple label         
Press the <Enter> key to see more codes: 
af04 AppleTV recovery      af05 Apple Core Storage    af06 Apple SoftRAID Statu
af07 Apple SoftRAID Scrat  af08 Apple SoftRAID Volum  af09 Apple SoftRAID Cache
b300 QNX6 Power-Safe       bc00 Acronis Secure Zone   be00 Solaris boot        
bf00 Solaris root          bf01 Solaris /usr & Mac Z  bf02 Solaris swap        
bf03 Solaris backup        bf04 Solaris /var          bf05 Solaris /home       
bf06 Solaris alternate se  bf07 Solaris Reserved 1    bf08 Solaris Reserved 2  
bf09 Solaris Reserved 3    bf0a Solaris Reserved 4    bf0b Solaris Reserved 5  
c001 HP-UX data            c002 HP-UX service         e100 ONIE boot           
e101 ONIE config           ea00 Freedesktop $BOOT     eb00 Haiku BFS           
ed00 Sony system partitio  ed01 Lenovo system partit  ef00 EFI System          
ef01 MBR partition scheme  ef02 BIOS boot partition   f800 Ceph OSD            
f801 Ceph dm-crypt OSD     f802 Ceph journal          f803 Ceph dm-crypt journa
f804 Ceph disk in creatio  f805 Ceph dm-crypt disk i  fb00 VMWare VMFS         
fb01 VMWare reserved       fc00 VMWare kcore crash p  fd00 Linux RAID          
Hex code or GUID (L to show codes, Enter = 8300): ef02
Changed type of partition to 'BIOS boot partition'

Command (? for help): n
Partition number (2-128, default 2): 2
First sector (34-60088286, default = 4096) or {+-}size{KMGTP}: 
Last sector (4096-60088286, default = 60088286) or {+-}size{KMGTP}: +50M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef00
Changed type of partition to 'EFI System'

Command (? for help): n
Partition number (3-128, default 3): 3
First sector (34-60088286, default = 106496) or {+-}size{KMGTP}: 
Last sector (106496-60088286, default = 60088286) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y

OK; writing new GUID partition table (GPT) to /dev/sdc.



Format the partitions :

# mkfs.fat -F32 /dev/sdX2
# mkfs.ext4 /dev/sdX3



You can now install GRUB to support both EFI + GPT and BIOS + GPT/MBR. The GRUB configuration (--boot-directory) can be kept in the same place.

First, you need to mount the EFI system partition and the data partition of your USB drive.

An example of this would be as follows:

# mount /dev/sdX3 /mnt
# mkdir -p /mnt/boot/EFI
# mount /dev/sdX2 /mnt/boot/EFI

Then, you can install GRUB for UEFI with:

In most cases EFI_MOUNTPOINT will correspond to the /mnt/boot/EFI subdirectory on your mounted USB disk.

# grub-install --target=x86_64-efi --recheck --removable --efi-directory=/EFI_MOUNTPOINT --boot-directory=/DATA_MOUNTPOINT/boot
And for BIOS with:

# grub-install --target=i386-pc --recheck --boot-directory=/DATA_MOUNTPOINT/boot /dev/sdX
As an additional fallback, you can also install GRUB on your MBR-bootable data partition:


# grub-install --target=i386-pc --recheck --boot-directory=/DATA_MOUNTPOINT/boot /dev/sdX3



If you get:
grub-install: error: /usr/lib/grub/x86_64-efi/modinfo.sh doesn't exist. Please specify --target or --directory.

It may be necessary to install EFI support for grub:
apt-get install grub-efi

Testing is very quick and simple using the qemu virtual machine:

qemu-system-x86_64 -enable-kvm -rtc base=localtime -m 2G -vga std -drive file=/dev/sdb,readonly,cache=none,format=raw,if=virtio

Saturday 23 May 2020

FreeNAS 0.7.2 - GEOM: adn: the secondary GPT table is corrupt or invalid

On booting FreeNAS 0.72 you may see the message: "the secondary GPT table is corrupt or invalid".

This can be ignored. According to this article:

"This error is caused by a basic flaw in the software used in FreeBSD and XigmaNAS to create and manage RAID arrays. Until FreeBSD version 7x the OS ignored / did not report the error. Now it and XigmaNAS, since it is based on FreeBSD, do report it. In the future, this may be fixed in FreeBSD, until then let's all continue blissfully ignoring it like we did prior to version 7x"

Wednesday 20 May 2020

Rsync with SystemRescueCD

Using the SystemRescueCD:

mkdir /mnt/usb
mkdir /mnt/Data

Mount the NTFS USB disk
ntfs-3g /dev/sdc1 /mnt/usb

Mount the UFS disk
mount -t ufs -o ufstype=ufs2,ro /dev/sda1 /mnt/Data

then use grsync to copy the data

Source: /mnt/Data
Destination: /mnt/usb
This will copy the Data folder and its subdirectories to the mounted USB drive.

Tuesday 19 May 2020

Rebuild a RAID 1 in FreeNAS 0.7.2

Determine the disk that has failed: is it ad0 or ad1?

Go to Disks > Software RAID > Tools
Select the failed drive, select Forget and click Send
Insert the new drive
Select the inserted drive, select Insert and click Send
Wait 5 minutes, select the drive and hit Status. You should see a percentage next to the new drive: this is it rebuilding.