User:Txnintn: Difference between revisions

From Alpine Linux
No edit summary
No edit summary
Line 134: Line 134:




When the list of mirrors stop and at --More--, prompt
When the list of mirrors stop and at --More--, prompt <br>
PRESS: the letter "r".
PRESS: the letter "r". <br>
 
<br>
r) Add random from the above list
r) Add random from the above list <br>
f) Detect and add the fastest mirror from above list
f) Detect and add the fastest mirror from above list <br>
e) Edit /etc/apk/repositories with text editor
e) Edit /etc/apk/repositories with text editor <br>
 
<br>
At, Enter mirror number (1-72) or URL to add (or r/f/e/done) [1], prompt.
At, Enter mirror number (1-72) or URL to add (or r/f/e/done) [1], prompt. <br>
PRESS:  enter for the default number 1.
PRESS:  enter for the default number 1. <br>
 
<br>
 
<br>
At, Setup a user? (enter a lower-case loginname, or 'no') [no], prompt.
At, Setup a user? (enter a lower-case loginname, or 'no') [no], prompt. <br>
PRESS: enter for the default no.
PRESS: enter for the default no. <br>
 
<br>
 
<br>
At, which ssh server? ('openssh', 'dropbear' or 'none'), prompt.
At, which ssh server? ('openssh', 'dropbear' or 'none'), prompt.
TYPE: none and PRESS:  enter to continue.
TYPE: none and PRESS:  enter to continue.
<br>
At, Available disks are: <br>
        sda (15.4 GB USB SanDisk 3.2Gen1) <br>               
        sdb (15.4 GB USB SanDisk 3.2Gen1) <br>
  <br>     
At Which disk(s) would you like to use? (or '?' for help or 'none') [none], prompt. <br>
TYPE: sda sdb and PRESS:  enter to continue. <br>
<br>
The following disks are selected: <br>
        sda (15.4 GB USB SanDisk 3.2Gen1) <br>               
        sdb (15.4 GB USB SanDisk 3.2Gen1) <br>


At, Available disks are:
How would you like to use it? ('sys', 'data', 'crypt', 'lvm' or '?' for help) [?], prompt. <br>
        sda (15.4 GB USB SanDisk 3.2Gen1)               
TYPE:  lvm and PRESS: enter to continue. <br>
        sdb (15.4 GB USB SanDisk 3.2Gen1)
<br>
       
<br>
At Which disk(s) would you like to use? (or '?' for help or 'none') [none], prompt.
The following disks are selected (with LVM): <br>
TYPE: sda sdb and PRESS:  enter to continue.
         sda (15.4 GB USB SanDisk 3.2Gen1) <br>             
 
         sdb (15.4 GB USB SanDisk 3.2Gen1) <br>
The following disks are selected:
<br>
        sda (15.4 GB USB SanDisk 3.2Gen1)               
How would you like to use it? ('sys', 'data', or '?' for help) [?], prompt. <br>
        sdb (15.4 GB USB SanDisk 3.2Gen1)
TYPE:  sys for system disk and PRESS: enter to continue. <br>
How would you like to use it? ('sys', 'data', 'crypt', 'lvm' or '?' for help) [?], prompt.
<br>
TYPE:  lvm and PRESS: enter to continue.
<br>
 
At, WARNING: Erase the above disk(s) and continue? (y/n) [n], prompt. <br>
 
         sda (15.4 GB USB SanDisk 3.2Gen1) <br>             
The following disks are selected (with LVM):
         sdb (15.4 GB USB SanDisk 3.2Gen1) <br>
         sda (15.4 GB USB SanDisk 3.2Gen1)              
<br>
         sdb (15.4 GB USB SanDisk 3.2Gen1)
TYPE: y, for yes and PRESS: enter to continue. <br>
How would you like to use it? ('sys', 'data', or '?' for help) [?], prompt.
<br>
TYPE:  sys for system disk and PRESS: enter to continue.
<br>
 
 
At, WARNING: Erase the above disk(s) and continue? (y/n) [n], prompt.
         sda (15.4 GB USB SanDisk 3.2Gen1)              
         sdb (15.4 GB USB SanDisk 3.2Gen1)
TYPE: y, for yes and PRESS: enter to continue.
 
 
Partition #1 contains a vfat signature.<br>
Partition #1 contains a vfat signature.<br>
Partition #2 contains a ext4 signature.<br>
Partition #2 contains a ext4 signature.<br>
Line 185: Line 188:
Creating file systems<br>
Creating file systems<br>
mkfs.fat 4.2 ((2021-01-31)<br>
mkfs.fat 4.2 ((2021-01-31)<br>
         Physical volume "/dev/md1" successfully created.
         Physical volume "/dev/md1" successfully created. <br>
         Logical volume "lv_root" created.
         Logical volume "lv_root" created. <br>
* service lvm added to runlevel boot
* service lvm added to runlevel boot <br>
Installing system on /dev/vg0/lv_root"
Installing system on /dev/vg0/lv_root" <br>
100% ######################################
100% ###################################### <br>
=> initframfs: creating /boot/initramfs-rpi4
=> initframfs: creating /boot/initramfs-rpi4 <br>
 
<br>
 
<br>
Installation is complete.  Please reboot.  DO NOT REBOOT!!!
Installation is complete.  Please reboot.  DO NOT REBOOT!!! <br>
 
<br>


Alpine installed the boot drive as a FD linux raid autodetect, IT WILL NOT BOOT on a Raspberry Pi.  
Alpine installed the boot drive as a FD linux raid autodetect, IT WILL NOT BOOT on a Raspberry Pi.  
Line 225: Line 228:




Stop the madam raid device
Stop the madam raid device <br>
TYPE:  mdadm --stop /dev/md0
TYPE:  mdadm --stop /dev/md0 <br>
 
 
Remove the Superblocks <br>
TYPE:  mdadm --zero-superblock /dev/sda1 /dev/sdb1 /dev/mmcblk0p1 (due to dd backup copying) <br>




Remove the Superblocks
verify md0 has been removed <br>
TYPE:  mdadm --zero-superblock /dev/sda1 /dev/sdb1 /dev/mmcblk0p1 (due to dd backup copying)
TYPE:  lsblk and or cat /proc/mdstat <br>




verify md0 has been removed
TYPE:  apk add nano or use vi to remove RAID /dev/md0 entries by editing /etc/fstab and /etc/mdadm.conf <br>
TYPE:  lsblk and or cat /proc/mdstat




TYPE:  apk add nano or use vi to remove RAID /dev/md0 entries by editing /etc/fstab and /etc/mdadm.conf
reboot <br>


Verify partition table sizes are the same on the Micro SD card and USB Drives. <br>


reboot
TYPE:  fdisk -l (some entries removed for clairification) <br>
<br>
Disk /dev/mmcblk0: 15 GB, 15931539456 bytes, 31116288 sectors <-- <br>
15193 cylinders, 64 heads, 32 sectors/track <br>
Units: sectors of 1 * 512 = 512 bytes <br>
<br>
Device      Boot StartCHS    EndCHS        StartLBA    EndLBA    Sectors  Size Id Type <br>
/dev/mmcblk0p1 *  1,0,1      300,63,32        2048    616447    614400  300M  c Win95 FAT32 (LBA)    ok <br>
/dev/mmcblk0p2    301,0,1    1023,63,32      616448  31116287  30499840 14.5G fd Linux raid autodetect <-- <br>
<br>
<br>
Disk /dev/sda: 14 GB, 15401484288 bytes, 30081024 sectors <br>
14688 cylinders, 64 heads, 32 sectors/track <br>
Units: sectors of 1 * 512 = 512 bytes <br>
<br>
Device  Boot StartCHS    EndCHS        StartLBA    EndLBA    Sectors  Size Id Type <br>
/dev/sda1 *  1,0,1      300,63,32        2048    616447    614400  300M fd Linux raid autodetect ok <br>
/dev/sda2    301,0,1    1023,63,32      616448  30081023  29464576 14.0G fd Linux raid autodetect <-- <br>
<br>
<br>
Disk /dev/sdb: 14 GB, 15401484288 bytes, 30081024 sectors <br>
14688 cylinders, 64 heads, 32 sectors/track <br>
Units: sectors of 1 * 512 = 512 bytes <br>
<br>
Device  Boot StartCHS    EndCHS        StartLBA    EndLBA    Sectors  Size Id Type <br>
/dev/sdb1 *  1,0,1      300,63,32        2048    616447    614400  300M fd Linux raid autodetect ok <br>
/dev/sdb2    301,0,1    1023,63,32      616448  30081023  29464576 14.0G fd Linux raid autodetect <-- <br>


apk add sfdisk
The Micro SD card is larger then /dev/sda2 and /dev/sdb2.  <br>
Resize the partion before continuing.  <br>
<br>
<br>
Disk /dev/mmcblk0: 15 GB, 15931539456 bytes, 31116288 sectors <br>
15193 cylinders, 64 heads, 32 sectors/track <br>
Units: sectors of 1 * 512 = 512 bytes <br>
<br>
Device      Boot StartCHS    EndCHS        StartLBA    EndLBA    Sectors  Size Id Type <br>
/dev/mmcblk0p1 *  1,0,1      300,63,32        2048    616447    614400  300M  c Win95 FAT32 (LBA) <br>
/dev/mmcblk0p2    301,0,1    1023,63,32      616448  30081023  29464576 14.0G fd Linux raid autodetect <br>
<br>
<br>
Disk /dev/sda: 14 GB, 15401484288 bytes, 30081024 sectors <br>
14688 cylinders, 64 heads, 32 sectors/track <br>
Units: sectors of 1 * 512 = 512 bytes <br>
<br>
Device  Boot StartCHS    EndCHS        StartLBA    EndLBA    Sectors  Size Id Type <br>
/dev/sda1 *  1,0,1      300,63,32        2048    616447    614400  300M fd Linux raid autodetect <br>
/dev/sda2    301,0,1    1023,63,32      616448  30081023  29464576 14.0G fd Linux raid autodetect <br>
<br>
<br>
Disk /dev/sdb: 14 GB, 15401484288 bytes, 30081024 sectors <br>
14688 cylinders, 64 heads, 32 sectors/track
Units: sectors of 1 * 512 = 512 bytes


Device  Boot StartCHS    EndCHS        StartLBA    EndLBA    Sectors  Size Id Type
/dev/sdb1 *  1,0,1      300,63,32        2048    616447    614400  300M fd Linux raid autodetect
/dev/sdb2    301,0,1    1023,63,32      616448  30081023  29464576 14.0G fd Linux raid autodetect
<br>
<br>
Install sfdisk to copy partition table information <br>
TYPE:  apk add sfdisk <br>
<br>
*** Warning*** <br>
*** Warning*** <br>
Before executing the following commands mmcblk0, sda, and sdb must be the exact same size partitons. <br>
Before executing the following commands mmcblk0, sda, and sdb must be the exact same size partitons. <br>
Line 249: Line 314:
Copy mmcblk0 disk partition table to sda and sdb<br>
Copy mmcblk0 disk partition table to sda and sdb<br>


sfdisk -d /dev/mmcblk0 |  sfdisk –force /dev/sda<br>
TYPE:  sfdisk -d /dev/mmcblk0 |  sfdisk --force /dev/sda<br>


sfdisk -d /dev/mmcblk0 |  sfdisk –force /dev/sdb<br>
TYPE:  sfdisk -d /dev/mmcblk0 |  sfdisk --force /dev/sdb<br>
   
   



Revision as of 16:16, 29 July 2023

Title: Alpine Linux install: LVM over Raid1 with a Micro SD spare.

Discussion:

Alpine Linux setup-alpine scripts when executed with two disks and the install medium, if both disks are selected, i.e., sda and sdb, the script will automatically configure a RAID1 installation.
https://wiki.alpinelinux.org/wiki/Setting_up_the_build_environment_on_HDD#Basic_setup

Additionally, LVM with a 'sys' install can be selected during the setup-alpine script.

The Raspberry Pi requires fat 16 / 32 boot partition with boot and LBA flags enabled. The Raspberry PI will boot from the USB or the Micro SD port. By having a Micro SD RAID1 spare, if the primary USB drive fails, the Micro SD should be able to boot the system.

NOTE: A mirrored RAID array (level 1 or 5) protects you against hardware failure. It doesn't protect against rm -rf /, software errors, exploits, earthquakes, fire. Don't rely on RAID as a backup strategy.
https://wiki.alpinelinux.org/wiki/Setting_up_a_software_RAID_array#Advice


LVM requires the Micro SD spare partition to be the same size as USB RAID1 partitions. A larger capacity Micro SD drive 2nd partition can easily resized to match the USB partition. During the install the setup-alpine script will maximize the size of 2nd partition on RAID1 drives

Tech Tip, not all Micro SD and USB drives are the same size.

16GB Drives
MFG / Model Size
SanDisk Industrial Micro SD 14.84GB
SanDisk Ultra Ultra Fit USB 3.1 14.34GB
SanDisk Ultra USB 3.0 14.91GB
SanDisk Cruzer Glide USB 2.0 14.91GB
32GB Drives
MFG / Model Size
Samsung SD Pro Endurance Micro SD 29.81GB
SanDisk Ultra SD 29.72GB
SanDisk Ultra Fit USB 3.1 Gen1 28.67GB
Silicon Power 5 USB 3.2 28.85GB
SanDisk Ultra 3.0 OTG 28.85GB
64GB Drive
MFG / Model Size
Samsung EVO Select Micro SD 59.69GB
Samsung Fit USB 3.1 59.75GB


Requirements:

Raspberry PI 4

Two Identical USB Drives - fit style drives recommended based on physical clearance issues.

One Micro SD Drive with the same or larger capacity then the USB drives

One USB drive for the installation files.

Preparation:

Created the following on the USB RAID disks: sdx1 a 300MB Fat32 Oc Partition, with boot and lba flags as required by Raspberry PI. sdx2 using the rest of the disk with a fd linux raid partition, formatted ext4

mmcblkx, sdx1 a 300MB Fat32 Oc Partition, with boot and lba flags as required by Raspberry PI. sdx2 sized to match USB RAID partition, Linux 83 and formatted Ext4. Do not use Linux Raid.

The USB installation drive single partition fat 32 0c with boot and LBA flags. Extract the contents of alpine-rpi-3.x.x-aarch.tar.gz to sdc1 (spare USB) partition.

The Raspberry Pi eprom must be set to boot USB port first and SD port second.

Installation:

Insert the "sda" USB disk into the bottom USB 3.0 port and the "sdb" USB drive into the upper USB 3.0 port. Power up the system, after the system has failed to boot to the installed USB drives, the screen will change from white and red to black and white text, insert the installation USB (sdc) to start the install process. This will set the drive assignments properly.


After logging in as root. To start the install, TYPE: setup-alpine and PRESS: enter.


At, Select keyboard layout: [none], prompt. TYPE: us and PRESS: enter. At, Select variant (or 'abort'):, prompt. TYPE: us and PRESS: enter.


At, Enter system hostname (fully qualified form, e.g. 'foo.example.org') [localhost] prompt. TYPE: the localhost name, for example, rpi44gb and PRESS: enter.


At, Enter '?' for help on bridges, bonding and vlans. Which one do you want to initialize? (or '?' or 'done' [eth0], prompt. PRESS: enter, to use the default, ethernet0 connection.

Ip address for eth0? (or 'dhcp', 'none', '?') [dhcp], prompt. PRESS: enter to use the default, dhcp.

At the second, Enter '?' for help on bridges, bonding and vlans. Which one do you want to initialize? (or '?' or 'done' [wlan0], prompt. TYPE: done and PRESS: enter.

Then at, Do you want to do and manual network configuration? (y/n) [n], prompt. PRESS enter for the default, [n], for no.


At, Change password for root, prompt. TYPE: the root password, and PRESS: enter. At, Retype password, prompt. TYPE: the root password and PRESS: enter.


At, Which timezone are you in? ('?' for a list) [UTC]. prompt. TYPE: America, with a capital A, and press enter.

At, What sub-timezone of 'America' are you in? ('?' for list), prompt. TYPE: Chicago, with a capital C, and press enter.

At, HTTP/FTP proxy URL? (e.g. /http://proxy:8000', or 'none') [none], prompt. PRESS: enter for the default, none.


At, Which NTP Client to run? ('busybox', 'openntpd', 'chrony' or 'none') [chrony], prompt. PRESS: enter for the default, chrony.


When the list of mirrors stop and at --More--, prompt
PRESS: the letter "r".


r) Add random from the above list
f) Detect and add the fastest mirror from above list
e) Edit /etc/apk/repositories with text editor

At, Enter mirror number (1-72) or URL to add (or r/f/e/done) [1], prompt.
PRESS: enter for the default number 1.


At, Setup a user? (enter a lower-case loginname, or 'no') [no], prompt.
PRESS: enter for the default no.


At, which ssh server? ('openssh', 'dropbear' or 'none'), prompt. TYPE: none and PRESS: enter to continue.
At, Available disks are:

       sda	(15.4 GB USB	SanDisk 3.2Gen1) 
sdb (15.4 GB USB SanDisk 3.2Gen1)

At Which disk(s) would you like to use? (or '?' for help or 'none') [none], prompt.
TYPE: sda sdb and PRESS: enter to continue.


The following disks are selected:

       sda	(15.4 GB USB	SanDisk 3.2Gen1) 
sdb (15.4 GB USB SanDisk 3.2Gen1)

How would you like to use it? ('sys', 'data', 'crypt', 'lvm' or '?' for help) [?], prompt.
TYPE: lvm and PRESS: enter to continue.



The following disks are selected (with LVM):

       sda	(15.4 GB USB	SanDisk 3.2Gen1) 
sdb (15.4 GB USB SanDisk 3.2Gen1)

How would you like to use it? ('sys', 'data', or '?' for help) [?], prompt.
TYPE: sys for system disk and PRESS: enter to continue.


At, WARNING: Erase the above disk(s) and continue? (y/n) [n], prompt.

       sda (15.4 GB USB	SanDisk 3.2Gen1) 
sdb (15.4 GB USB SanDisk 3.2Gen1)


TYPE: y, for yes and PRESS: enter to continue.



Partition #1 contains a vfat signature.
Partition #2 contains a ext4 signature.
Partition #1 contains a vfat signature.
Partition #2 contains a ext4 signature.
Creating file systems
mkfs.fat 4.2 ((2021-01-31)

       Physical volume "/dev/md1" successfully created. 
Logical volume "lv_root" created.
  • service lvm added to runlevel boot

Installing system on /dev/vg0/lv_root"
100% ######################################
=> initframfs: creating /boot/initramfs-rpi4



Installation is complete. Please reboot. DO NOT REBOOT!!!


Alpine installed the boot drive as a FD linux raid autodetect, IT WILL NOT BOOT on a Raspberry Pi. The Raspberry Pi can only boot from fat16 or fat32 partition with boot and lba flags enabled.

TYPE: watch cat /proc/mdstat

Personalities : [raid1] md1 : active raid1 sdb2[1] sda2[0]

         14723072 blocks super 1.2 [2/2] [UU]
         {>....................] resyc - 2.7% (397521/14723072) finish=22.1min speed=8768K/sec

md0 : active raid1 sdb1[1] sda1[0]

         307136 blocks [2/2] [UU] 

The Raid MD1 is still resycing. Take a break, the drives should be finished in 20 to 30 minutes.

PRESS: ctrl + c to exit watch cat /proc/mdtstat


Backup the boot raid partition first
Insert mmcblk0
TYPE: dd if=/dev/sda1 of=/dev/mmcblk0p1 bs=512


Reboot


Unmount the RAID 1 filesystem
TYPE: umount /dev/md0


Stop the madam raid device
TYPE: mdadm --stop /dev/md0


Remove the Superblocks
TYPE: mdadm --zero-superblock /dev/sda1 /dev/sdb1 /dev/mmcblk0p1 (due to dd backup copying)


verify md0 has been removed
TYPE: lsblk and or cat /proc/mdstat


TYPE: apk add nano or use vi to remove RAID /dev/md0 entries by editing /etc/fstab and /etc/mdadm.conf


reboot

Verify partition table sizes are the same on the Micro SD card and USB Drives.

TYPE: fdisk -l (some entries removed for clairification)

Disk /dev/mmcblk0: 15 GB, 15931539456 bytes, 31116288 sectors <--
15193 cylinders, 64 heads, 32 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type
/dev/mmcblk0p1 * 1,0,1 300,63,32 2048 616447 614400 300M c Win95 FAT32 (LBA) ok
/dev/mmcblk0p2 301,0,1 1023,63,32 616448 31116287 30499840 14.5G fd Linux raid autodetect <--


Disk /dev/sda: 14 GB, 15401484288 bytes, 30081024 sectors
14688 cylinders, 64 heads, 32 sectors/track
Units: sectors of 1 * 512 = 512 bytes


Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type
/dev/sda1 * 1,0,1 300,63,32 2048 616447 614400 300M fd Linux raid autodetect ok
/dev/sda2 301,0,1 1023,63,32 616448 30081023 29464576 14.0G fd Linux raid autodetect <--



Disk /dev/sdb: 14 GB, 15401484288 bytes, 30081024 sectors
14688 cylinders, 64 heads, 32 sectors/track
Units: sectors of 1 * 512 = 512 bytes


Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type
/dev/sdb1 * 1,0,1 300,63,32 2048 616447 614400 300M fd Linux raid autodetect ok
/dev/sdb2 301,0,1 1023,63,32 616448 30081023 29464576 14.0G fd Linux raid autodetect <--

The Micro SD card is larger then /dev/sda2 and /dev/sdb2.
Resize the partion before continuing.



Disk /dev/mmcblk0: 15 GB, 15931539456 bytes, 31116288 sectors
15193 cylinders, 64 heads, 32 sectors/track
Units: sectors of 1 * 512 = 512 bytes


Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type
/dev/mmcblk0p1 * 1,0,1 300,63,32 2048 616447 614400 300M c Win95 FAT32 (LBA)
/dev/mmcblk0p2 301,0,1 1023,63,32 616448 30081023 29464576 14.0G fd Linux raid autodetect



Disk /dev/sda: 14 GB, 15401484288 bytes, 30081024 sectors
14688 cylinders, 64 heads, 32 sectors/track
Units: sectors of 1 * 512 = 512 bytes


Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type
/dev/sda1 * 1,0,1 300,63,32 2048 616447 614400 300M fd Linux raid autodetect
/dev/sda2 301,0,1 1023,63,32 616448 30081023 29464576 14.0G fd Linux raid autodetect



Disk /dev/sdb: 14 GB, 15401484288 bytes, 30081024 sectors
14688 cylinders, 64 heads, 32 sectors/track Units: sectors of 1 * 512 = 512 bytes

Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type /dev/sdb1 * 1,0,1 300,63,32 2048 616447 614400 300M fd Linux raid autodetect /dev/sdb2 301,0,1 1023,63,32 616448 30081023 29464576 14.0G fd Linux raid autodetect



Install sfdisk to copy partition table information
TYPE: apk add sfdisk


      • Warning***

Before executing the following commands mmcblk0, sda, and sdb must be the exact same size partitons.


Copy mmcblk0 disk partition table to sda and sdb

TYPE: sfdisk -d /dev/mmcblk0 | sfdisk --force /dev/sda

TYPE: sfdisk -d /dev/mmcblk0 | sfdisk --force /dev/sdb


Copy mmcblk0p1 boot partition to sda1 and sdb1
TYPE: dd if=/dev/mmcblk0p1 of=/dev/sda1 bs=512
TYPE: dd if=/dev/mmcblk0p1 of=/dev/sdb1 bs=512


Add mmcblk0 as a spare drive to RAID /dev/md1
TYPE: madam --add /dev/md1 /dev/mmcblk0p2


View Raid One information
TYPE: mdadm --detail /dev/md1

/dev/md1

                       version : 1.2
         Creation Time        : Sat Jun 24 12:50:56 2023
            Raid Level : raid 1
            Array Size : 14723072 (14.04 GiB 15.08 GB)
         Used Dev Size : 14723072 (14.04 GiB 15.08 GB)
          Raid Devices : 2
         Total Devices : 3
           Persistence : Superblock is persistence
           
           Update Time : Sat Jun 24 14:30:11 2023
                     State : clean
        Active Devices : 2
       Working Devices : 3
        Failed Devices : 0
         Spare Devices : 1

txnintn