Difference between revisions of "PinePhone Installation Instructions"

From PINE64
Jump to navigation Jump to search
m (category)
 
(27 intermediate revisions by 7 users not shown)
Line 1: Line 1:
This section has generic installation instructions. Please see the [[PinePhone Software Releases]] section for specific installation instructions for each distribution.
This section has generic installation instructions.  
 
For specific installation instructions for each distribution please see the software releases pages:
 
* for the '''PinePhone''': [[PinePhone Software Releases]]
* for the '''PinePhone Pro''': [[PinePhone Pro Software Releases]]


== Boot priority ==
== Boot priority ==


The default PinePhone boot priority is first the SD card and then the eMMC so inserting your own SD card with your preferred release will result in the phone booting your image.
=== PinePhone Pro ===
 
For details regarding the boot priority on the PinePhone Pro see [[PinePhone Pro#Boot order]].
 
=== PinePhone ===
 
The PinePhone always boots from the microSD card first. It is therefore recommended to have a microSD card handy. It is '''not''' possible to lock themself out of the phone when the installation on the internal storage (the eMMC) fails, as a correctly flashed microSD card will always boot. Note: Booting from USB is not supported by the hardware, a live USB stick will not boot.
 
The phone will also try to boot from microSD cards, which were previously flashed with an OS and formatted later, causing the phone to fail to boot. See [[#Reuse SD card for data storage on system booting from eMMC|reuse SD card]] on how to format the microSD card properly, including wiping the residues of u-boot.


== Installation to the microSD ==
== Installation to the microSD ==
[[File:Pinephone slots.png|600px|thumb|right|none|The microSD belongs in the upper slot, the micro-SIM in the lower slot.]]
For this installation method you need a '''microSD card''', a '''microSD card reader''' and a '''compatible device''', such as a computer or a laptop with Linux, iOS, Windows or similar (Note: ChromeOS is not supported).


To install an image to the microSD card:
To install an image to the microSD card:


# Download your chosen image from [[PinePhone Software Releases]]
# Download your chosen image from [[PinePhone Software Releases]] for the regular '''PinePhone''' and [[PinePhone Pro Software Releases]] for the '''PinePhone Pro'''
# Extract the compressed file
# Extract the compressed file
# Write the image to your SD card, see below
# Write ("flash") the image to your microSD card, see the section [[#Flashing the microSD|Flashing the microSD]] below
# Plug SD card into phone
# Plug microSD card into phone (make sure to use the top slot, not the bottom slot)
# Boot phone
# '''On the PinePhone Pro''': The eMMC might have to be overruled to boot from the microSD card, see [[PinePhone Pro#Boot order]]
# Boot up the phone
 
=== Flashing the microSD ===
 
==== Using Balena Etcher ====
 
Using the graphical application ''Balena Etcher'' to flash the microSD card is '''recommended''' for new or inexperienced users.
 
Download: https://etcher.balena.io/#download-etcher
 
Install the application and start it.
 
Click the button ''Flash from file'':
 
[[File:Etcher1.png|600px|none]]


If you need step-by-step instructions for writing an image to an SD card, check [[NOOB#Step-by-Step_Instructions_to_Flashing_MicroSD_Cards|the NOOB guide]], then return to this page.
Select the downloaded image and make sure that you downloaded the correct one. Images for the PinePhone and the PinePhone Pro are '''not compatible''' with each other. Images for the PinePhone typically have the word "PinePhone" in the filename, while images for the PinePhone Pro typically have "PinePhone Pro" in their filename.
 
{{Info|At this the image file does not have to be extracted from the archive format. Balena Etcher handles the extracting automatically.}}
 
Then click on ''Select target'':
 
[[File:Etcher3.png|600px|none]]
 
{{Info|Make sure to select the correct target by comparing the name and the disk capacity with the label on the microSD card.}}
 
Then click on ''Flash!'':
 
[[File:Etcher4.png|600px|none]]
 
That's it! Now follow the further instructions above.


=== Flashing the microSD ===
==== Using dd ====
==== Using dd ====
Make sure to select the correct device using <code>lsblk</code>. Then run <code>dd</code> with the correct device:


<pre>
Make sure to select the correct device using <code>lsblk</code>. Then run <code>dd</code> with the selected device:
sudo dd if=pine.img of=/dev/[DEVICE] bs=1M status=progress conv=fsync
 
</pre>
sudo dd if='''IMAGE.img''' of=/dev/'''[DEVICE]''' bs=1M status=progress conv=fsync
 
{{Info|The image needs to be written to the whole device, not to partition 1. Make sure you're NOT selecting ''/dev/sda1'' or ''/dev/mmcblk0p1'' as target.}}


==== Using bmaptool ====
==== Using bmaptool ====
Make sure to select the correct device using <code>lsblk</code>. Then run bmaptool with the correct device:
Make sure to select the correct device using <code>lsblk</code>. Then run bmaptool with the correct device:


Download the .img.xz and the .img.bmap files, then run <code>bmaptool copy --bmap image.bmap image.xz /dev/[DEVICE]</code>. This takes around 2.5 minutes to flash a 4 Gb file.
Download the ''IMAGE.xz'' and the ''IMAGE.bmap'' files, then run <code>bmaptool copy --bmap '''IMAGE.bmap''' '''IMAGE.xz''' /dev/'''[DEVICE]'''</code>. This takes around 2.5 minutes to flash a 4 Gb file.


==== Using graphical tools ====
==== Using Gnome Disks ====
GUI applications such as Etcher and GNOME Disks can be used to flash the MicroSD too.
 
Gnome Disks can be used to flash the microSD card. To do so, select the correct device in the left device selection, then click on the three dot menu and select ''Restore Disk Image...'' and follow the on-screen instructions.


== Installation to the eMMC ==
== Installation to the eMMC ==
An operating system can also be booted from the internal memory of the PinePhone ("eMMC"). There are multiple methods to flash the eMMC as explained below.
=== From the booted microSD OS ===
# Flash an OS to the microSD card (and optionally resize the partition, see below)
# Insert microSD card and boot the phone
# Download the desired OS' image on the booted OS or transfer it to the microSD card
# Extract the image file if it is archived
# Flash the image file to eMMC using <code>dd if='''IMAGE.img''' of=/dev/'''mmcblkX''' bs=1M status=progress conv=fsync</code> where X is the number label of the eMMC (of the disk, not the partition!). Use the command <code>lsblk</code> to check your devices: typically with the current kernel the microSD card is ''/dev/mmcblk0'' and the eMMC is ''/dev/mmcblk2'' but as always with ''dd'' be extremely cautious to get the devices correct.
# Turn off phone, remove microSD card and then turn on the phone.
=== Using JumpDrive ===
=== Using JumpDrive ===
{{Info|This only applies to the regular '''PinePhone''', not the '''PinePhone Pro'''.}}


[[File:jumpdrive.jpg|400px|thumb|right|Jumpdrive running on the PinePhone]]
[[File:jumpdrive.jpg|400px|thumb|right|Jumpdrive running on the PinePhone]]
The internal eMMC flash storage can be flashed using the Jumpdrive utility by Danct12 and Martijn from postmarketOS.
The internal eMMC flash storage can be flashed using the Jumpdrive utility by Danct12 and Martijn from postmarketOS.
This utility boots from micro SD and exposes the internal eMMC flash storage when the PinePhone is connected to a computer.
This utility boots from micro SD and exposes the internal eMMC flash storage when the PinePhone is connected to a computer.
The process of flashing an OS to the exposed and mounted eMMC is identical to that of any other storage medium - e.g. a SD card. You can use the <i>dd</i> command or a utility such as Etcher or Gnome Disks, etc.
The process of flashing an OS to the exposed and mounted eMMC is identical to that of any other storage medium - e.g. a microSD card. You can use the <i>dd</i> command or a utility such as Etcher or Gnome Disks, etc.


Latest Jumpdrive can be found [https://github.com/dreemurrs-embedded/Jumpdrive/releases/ here].
Latest Jumpdrive can be found [https://github.com/dreemurrs-embedded/Jumpdrive/releases/ here].


# Download and extract [https://github.com/dreemurrs-embedded/Jumpdrive/releases the Jumpdrive image]
# Download and extract [https://github.com/dreemurrs-embedded/Jumpdrive/releases the Jumpdrive image]
# Flash the Jumpdrive image to a micro SD card
# Flash the Jumpdrive image to a microSD card
# Boot the PinePhone from the Jumpdrive micro SD card
# Boot the PinePhone from the Jumpdrive microSD card
# Connect the PinePhone to your computer using USB-A -> USB-C cable
# Connect the PinePhone to your computer using USB-A -> USB-C cable
# Flash the exposed PinePhone drive (e.g. /dev/mm..., check for the right device in dmesg, GNOME disks, or similar, and make sure it's unmounted) with your chosen OS image
# Flash the exposed PinePhone drive (e.g. ''/dev/mm...'', check for the right device in <code>dmesg</code>, GNOME disks, or similar, and make sure it's unmounted) with your chosen OS image
# Once the flashing process is complete, disconnect the PinePhone from your PC, power it down and remove the Jumpdrive SD card
# Once the flashing process is complete, disconnect the PinePhone from your PC, power it down and remove the Jumpdrive microSD card
# The process is now finished, and you can boot from eMMC
# The process is now finished, and you can boot from eMMC


The Jumpdrive image is smaller than 50MB. You can keep an SD card specifically for using Jumpdrive, and there are 64MB micro SD cards sold cheaply that will suffice. Jumpdrive also acts as a rescue image in case if you messed up your installation. To do so, you can telnet to '''172.16.42.1''', mount rootfs and fix it!
The Jumpdrive image is smaller than 50MB. You can keep an microSD card specifically for using Jumpdrive, and there are 64MB microSD cards sold cheaply that will suffice. Jumpdrive also acts as a rescue image in case if you messed up your installation. To do so, you can telnet to '''172.16.42.1''', mount rootfs and fix it!


=== From the booted microSD OS ===
=== SD to eMMC via installer ===


# Flash an OS to the SD card (and optionally resize the partition, see below)
An special installer image booted from the microSD card can be used to flash the eMMC as well. Mobian and postmarketOS installer images booted from microSD card will simply ask the user if they want to install to eMMC. The feature lives in the distribution-agnostic calamares-extensions repository (see [https://github.com/calamares/calamares-extensions/pull/7 calamares-extensions#7]), so other distributions might adopt this in the future.
# Insert SD card and boot the phone
# Download the desired OS' image on the booted OS or transfer it to the SD card
# Extract the image file if it is archived
# Flash the image file to eMMC using <code>dd if=new-pinephone-image.img of=/dev/mmcblkX bs=1M status=progress conv=fsync</code> where X is the number label of the eMMC (of the disk, not the partition!). Use the command ''lsblk'' to check your devices: typically with the current kernel the SD card is /dev/mmcblk0 and the eMMC is /dev/mmcblk2 but as always with ''dd'' be extremely cautious to get the devices correct.
# Turn off phone, remove SD card and then turn on the phone.


=== From the booted microSD OS (risky) ===
=== Using Tow-Boot ===


{{Warning|This copies a mounted filesystem, which can lead to instability, erratic behavior, and data corruption.}}
Tow-Boot is an opinionated distribution of the U-Boot bootloader. It includes an USB Mass Storage Mode, which exposes the flash drive(s) to a computer connected to the phone via USB-C. The Tow-Boot bootloader has to be installed if it is not pre-installed already. For instructions see the following links:


# Prepare a new SD card, flash desired OS to the SD card
* '''PinePhone:''' https://tow-boot.org/devices/pine64-pinephoneA64.html
# Boot the phone with your new SD card image
* '''PinePhone Pro:''' https://tow-boot.org/devices/pine64-pinephonePro.html
# Within the booted OS, flash/clone the running OS to eMMC, e.g. using dd. It will take about 15 minutes (depending on the speed of your card), and in the end it may show an error about not enough space - just ignore it.
# Turn off phone, take out SD card, and try booting the phone which should load up the new OS from eMMC.
# Open terminal and resize partition to fill up entire disk (see below).


=== SD to eMMC via installer ===
If Tow-Boot is installed the phone can be started into USB Mass Storage Mode by holding the ''volume up'' key on startup.


postmarketOS installer images booted from SD card will simply ask the user, if they want to install to eMMC. The feature lives in the distro-agnostic calamares-extensions repository (see [https://github.com/calamares/calamares-extensions/pull/7 calamares-extensions#7]), so other distributions might adopt this in the future.
The steps of flashing an operating system to the phone after booting Tow-Boot's USB Mass Storage Mode and connecting the phone to a computer is identical to that of any other storage medium - e.g. a microSD card. You can use the <i>dd</i> command or a utility such as Etcher or Gnome Disks from the computer the phone is connected to.


== Resize partition to fit disk space ==
== Resize partition to fit disk space ==


{{Hint|Many OSes already include a script, which is resizing the partition on first boot, where this step is not required.}}
{{Info|Many operating systems already include a script, which is resizing the partition on first boot, where this step is not required.}}


Once you've flashed the OS to your SD card or eMMC storage, you may also need to expand the partition to fill all the available space.
Once you've flashed the OS to your microSD card or eMMC storage, you may also need to expand the partition to fill all the available space.


=== Resize SD card's partition using computer ===
=== Resize SD card's partition using a computer ===


For SD cards, insert the SD card and resize the partitions through the computer. For eMMC, insert the phone cable and use Jumpdrive to access the eMMC directly, and resize the partition after flashing the image. To do the flashing you have two options:
For microSD cards, insert the microSD card and resize the partitions through the computer. For eMMC, insert the phone cable and use Jumpdrive to access the eMMC directly, and resize the partition after flashing the image. To do the flashing you have two options:


====Using Growpart ====
==== Using Growpart ====


Install <i>growpart</i> and run:
Install <i>growpart</i> and run:
  growpart /dev/mmcblkX Y
  growpart /dev/'''mmcblkX''' '''Y'''
  resize2fs /dev/mmcblkXpY
  resize2fs /dev/'''mmcblkXpY'''
where X is the storage device and Y is the partition number (viewable from <code>lsblk</code>).
where ''X'' is the storage device and ''Y'' is the partition number (viewable from <code>lsblk</code>).


If you get any errors about missing or unknown commands, use <code>apt-cache search</code> to find and install the needed software. Also don't forget to use <code>sudo</code>.
If you get any errors about missing or unknown commands, use <code>apt-cache search</code> to find and install the needed software. Also don't forget to use <code>sudo</code>.


====Using Parted ====
==== Using Parted ====


Parted's interactive mode and resize work well together. Do this before you put your SD card into the PinePhone for the first time for best results.
Parted's interactive mode and resize work well together. Do this before you put your microSD card into the PinePhone for the first time for best results.


  sudo parted /dev/<your_sd_card_device>
  sudo parted /dev/'''<your_sd_card_device>'''
  (parted) resizepart 2 100%
  (parted) resizepart 2 100%
  (parted) quit
  (parted) quit
  sudo resize /dev/<the_second_sd_card_PARTITION>
  sudo resize2fs /dev/'''<the_second_sd_card_PARTITION>'''


=== Resize from within PinePhone ===
=== Resize from within the PinePhone ===


eMMC: you would need to resize the partition on eMMC (flashed with the operating system) by booting another image from the SD card: that way, the eMMC will be unmounted. It is '''not recommended''' to resize eMMC while booted from eMMC! Resizing a currently mounted partition can have weird results. If you booted from the SD card, you can follow the above guidelines on how to resize from a computer.  
eMMC: you would need to resize the partition on eMMC (flashed with the operating system) by booting another image from the microSD card: that way, the eMMC will be unmounted. It is '''not recommended''' to resize eMMC while booted from eMMC! Resizing a currently mounted partition can have weird results. If you booted from the microSD card, you can follow the above guidelines on how to resize from a computer.  


SD card: It is generally not possible to boot from eMMC to partition the unmounted SD card, because of the boot order - you would have to write the image to the empty SD card first, then resize partition, all without rebooting. It is also '''not recommended''' to resize the SD card while booted from SD card! Resizing a currently mounted partition can have weird results.
MicroSD card: It is generally not possible to boot from eMMC to partition the unmounted microSD card, because of the boot order - you would have to write the image to the empty microSD card first, then resize partition, all without rebooting. It is also '''not recommended''' to resize the microSD card while booted from microSD card! Resizing a currently mounted partition can have weird results.


== Reuse SD card for data storage on system booting from eMMC==
== Reuse SD card for data storage on system booting from eMMC==
Once you have installed your release of choice to eMMC, you may wish to use an SD card for data storage. If you choose to re-use a card you have previously used to boot from, you will find your phone will not boot if you just reformat the card and insert it. This is because the Allwinner firmware in the PinePhone uses some (normally) unused space at the front of the SD card to store boot software, which you need to clear.
Once you have installed your release of choice to eMMC, you may wish to use an microSD card for data storage. If you choose to re-use a card you have previously used to boot from, you will find your phone will not boot if you just reformat the card and insert it. This is because the Allwinner firmware in the PinePhone uses some (normally) unused space at the front of the microSD card to store boot software, which you need to clear.


This can be done as follows on any linux system:
This can be done as follows on any Linux system:
  lsblk
  lsblk
to check the device of your SD card – as an example lets assume it is /dev/mmcblk0
to check the device of your microSD card – as an example lets assume it is /dev/mmcblk0
then
then
  sudo dd if=/dev/zero of=/dev/<your_sd_card_device> bs=8k seek=1 count=4
  sudo dd if=/dev/zero of=/dev/'''[DEVICE]''' bs=8k seek=1 count=4
will clear the relevant sectors of your card.
will clear the relevant sectors of your card.
Since Danctnix (arch) switched to a gpt partition table from mbr in May of 2022 it installs u-boot at an offset of 128k instead of 8k, which means this command must be used instead
sudo dd if=/dev/zero of=/dev/'''[DEVICE]''' bs=32k seek=4 count=1


== Web resources ==
== Web resources ==


* [https://www.youtube.com/watch?v=7HMkU43P9hw Youtube video on how to flash OS images on the Pinephone (SD or eMMC) by Tech Pills]
* [https://www.youtube.com/watch?v=7HMkU43P9hw Youtube video on how to flash OS images on the Pinephone (SD or eMMC) by Tech Pills]
* [https://www.youtube.com/watch?v=u65dofYFAPY Youtube video on How to install different OSes On the PinePhone plus an Mobian overview by Elatronion]
* [https://www.youtube.com/watch?v=u65dofYFAPY Youtube video on How to install different operating systems on the PinePhone plus an Mobian overview by Elatronion]




[[Category:PinePhone]][[Category:Guide]]
[[Category:PinePhone]][[Category:Guide]]

Latest revision as of 14:50, 12 August 2023

This section has generic installation instructions.

For specific installation instructions for each distribution please see the software releases pages:

Boot priority

PinePhone Pro

For details regarding the boot priority on the PinePhone Pro see PinePhone Pro#Boot order.

PinePhone

The PinePhone always boots from the microSD card first. It is therefore recommended to have a microSD card handy. It is not possible to lock themself out of the phone when the installation on the internal storage (the eMMC) fails, as a correctly flashed microSD card will always boot. Note: Booting from USB is not supported by the hardware, a live USB stick will not boot.

The phone will also try to boot from microSD cards, which were previously flashed with an OS and formatted later, causing the phone to fail to boot. See reuse SD card on how to format the microSD card properly, including wiping the residues of u-boot.

Installation to the microSD

The microSD belongs in the upper slot, the micro-SIM in the lower slot.

For this installation method you need a microSD card, a microSD card reader and a compatible device, such as a computer or a laptop with Linux, iOS, Windows or similar (Note: ChromeOS is not supported).

To install an image to the microSD card:

  1. Download your chosen image from PinePhone Software Releases for the regular PinePhone and PinePhone Pro Software Releases for the PinePhone Pro
  2. Extract the compressed file
  3. Write ("flash") the image to your microSD card, see the section Flashing the microSD below
  4. Plug microSD card into phone (make sure to use the top slot, not the bottom slot)
  5. On the PinePhone Pro: The eMMC might have to be overruled to boot from the microSD card, see PinePhone Pro#Boot order
  6. Boot up the phone

Flashing the microSD

Using Balena Etcher

Using the graphical application Balena Etcher to flash the microSD card is recommended for new or inexperienced users.

Download: https://etcher.balena.io/#download-etcher

Install the application and start it.

Click the button Flash from file:

Etcher1.png

Select the downloaded image and make sure that you downloaded the correct one. Images for the PinePhone and the PinePhone Pro are not compatible with each other. Images for the PinePhone typically have the word "PinePhone" in the filename, while images for the PinePhone Pro typically have "PinePhone Pro" in their filename.

Note: At this the image file does not have to be extracted from the archive format. Balena Etcher handles the extracting automatically.

Then click on Select target:

Etcher3.png
Note: Make sure to select the correct target by comparing the name and the disk capacity with the label on the microSD card.

Then click on Flash!:

Etcher4.png

That's it! Now follow the further instructions above.

Using dd

Make sure to select the correct device using lsblk. Then run dd with the selected device:

sudo dd if=IMAGE.img of=/dev/[DEVICE] bs=1M status=progress conv=fsync
Note: The image needs to be written to the whole device, not to partition 1. Make sure you're NOT selecting /dev/sda1 or /dev/mmcblk0p1 as target.

Using bmaptool

Make sure to select the correct device using lsblk. Then run bmaptool with the correct device:

Download the IMAGE.xz and the IMAGE.bmap files, then run bmaptool copy --bmap IMAGE.bmap IMAGE.xz /dev/[DEVICE]. This takes around 2.5 minutes to flash a 4 Gb file.

Using Gnome Disks

Gnome Disks can be used to flash the microSD card. To do so, select the correct device in the left device selection, then click on the three dot menu and select Restore Disk Image... and follow the on-screen instructions.

Installation to the eMMC

An operating system can also be booted from the internal memory of the PinePhone ("eMMC"). There are multiple methods to flash the eMMC as explained below.

From the booted microSD OS

  1. Flash an OS to the microSD card (and optionally resize the partition, see below)
  2. Insert microSD card and boot the phone
  3. Download the desired OS' image on the booted OS or transfer it to the microSD card
  4. Extract the image file if it is archived
  5. Flash the image file to eMMC using dd if=IMAGE.img of=/dev/mmcblkX bs=1M status=progress conv=fsync where X is the number label of the eMMC (of the disk, not the partition!). Use the command lsblk to check your devices: typically with the current kernel the microSD card is /dev/mmcblk0 and the eMMC is /dev/mmcblk2 but as always with dd be extremely cautious to get the devices correct.
  6. Turn off phone, remove microSD card and then turn on the phone.

Using JumpDrive

Note: This only applies to the regular PinePhone, not the PinePhone Pro.
Jumpdrive running on the PinePhone

The internal eMMC flash storage can be flashed using the Jumpdrive utility by Danct12 and Martijn from postmarketOS. This utility boots from micro SD and exposes the internal eMMC flash storage when the PinePhone is connected to a computer. The process of flashing an OS to the exposed and mounted eMMC is identical to that of any other storage medium - e.g. a microSD card. You can use the dd command or a utility such as Etcher or Gnome Disks, etc.

Latest Jumpdrive can be found here.

  1. Download and extract the Jumpdrive image
  2. Flash the Jumpdrive image to a microSD card
  3. Boot the PinePhone from the Jumpdrive microSD card
  4. Connect the PinePhone to your computer using USB-A -> USB-C cable
  5. Flash the exposed PinePhone drive (e.g. /dev/mm..., check for the right device in dmesg, GNOME disks, or similar, and make sure it's unmounted) with your chosen OS image
  6. Once the flashing process is complete, disconnect the PinePhone from your PC, power it down and remove the Jumpdrive microSD card
  7. The process is now finished, and you can boot from eMMC

The Jumpdrive image is smaller than 50MB. You can keep an microSD card specifically for using Jumpdrive, and there are 64MB microSD cards sold cheaply that will suffice. Jumpdrive also acts as a rescue image in case if you messed up your installation. To do so, you can telnet to 172.16.42.1, mount rootfs and fix it!

SD to eMMC via installer

An special installer image booted from the microSD card can be used to flash the eMMC as well. Mobian and postmarketOS installer images booted from microSD card will simply ask the user if they want to install to eMMC. The feature lives in the distribution-agnostic calamares-extensions repository (see calamares-extensions#7), so other distributions might adopt this in the future.

Using Tow-Boot

Tow-Boot is an opinionated distribution of the U-Boot bootloader. It includes an USB Mass Storage Mode, which exposes the flash drive(s) to a computer connected to the phone via USB-C. The Tow-Boot bootloader has to be installed if it is not pre-installed already. For instructions see the following links:

If Tow-Boot is installed the phone can be started into USB Mass Storage Mode by holding the volume up key on startup.

The steps of flashing an operating system to the phone after booting Tow-Boot's USB Mass Storage Mode and connecting the phone to a computer is identical to that of any other storage medium - e.g. a microSD card. You can use the dd command or a utility such as Etcher or Gnome Disks from the computer the phone is connected to.

Resize partition to fit disk space

Note: Many operating systems already include a script, which is resizing the partition on first boot, where this step is not required.

Once you've flashed the OS to your microSD card or eMMC storage, you may also need to expand the partition to fill all the available space.

Resize SD card's partition using a computer

For microSD cards, insert the microSD card and resize the partitions through the computer. For eMMC, insert the phone cable and use Jumpdrive to access the eMMC directly, and resize the partition after flashing the image. To do the flashing you have two options:

Using Growpart

Install growpart and run:

growpart /dev/mmcblkX Y
resize2fs /dev/mmcblkXpY

where X is the storage device and Y is the partition number (viewable from lsblk).

If you get any errors about missing or unknown commands, use apt-cache search to find and install the needed software. Also don't forget to use sudo.

Using Parted

Parted's interactive mode and resize work well together. Do this before you put your microSD card into the PinePhone for the first time for best results.

sudo parted /dev/<your_sd_card_device>
(parted) resizepart 2 100%
(parted) quit
sudo resize2fs /dev/<the_second_sd_card_PARTITION>

Resize from within the PinePhone

eMMC: you would need to resize the partition on eMMC (flashed with the operating system) by booting another image from the microSD card: that way, the eMMC will be unmounted. It is not recommended to resize eMMC while booted from eMMC! Resizing a currently mounted partition can have weird results. If you booted from the microSD card, you can follow the above guidelines on how to resize from a computer.

MicroSD card: It is generally not possible to boot from eMMC to partition the unmounted microSD card, because of the boot order - you would have to write the image to the empty microSD card first, then resize partition, all without rebooting. It is also not recommended to resize the microSD card while booted from microSD card! Resizing a currently mounted partition can have weird results.

Reuse SD card for data storage on system booting from eMMC

Once you have installed your release of choice to eMMC, you may wish to use an microSD card for data storage. If you choose to re-use a card you have previously used to boot from, you will find your phone will not boot if you just reformat the card and insert it. This is because the Allwinner firmware in the PinePhone uses some (normally) unused space at the front of the microSD card to store boot software, which you need to clear.

This can be done as follows on any Linux system:

lsblk

to check the device of your microSD card – as an example lets assume it is /dev/mmcblk0 then

sudo dd if=/dev/zero of=/dev/[DEVICE] bs=8k seek=1 count=4

will clear the relevant sectors of your card.

Since Danctnix (arch) switched to a gpt partition table from mbr in May of 2022 it installs u-boot at an offset of 128k instead of 8k, which means this command must be used instead

sudo dd if=/dev/zero of=/dev/[DEVICE] bs=32k seek=4 count=1

Web resources