https://wiki.pine64.org/api.php?action=feedcontributions&user=Nerdcore&feedformat=atomPINE64 - User contributions [en]2024-03-29T07:35:36ZUser contributionsMediaWiki 1.37.1https://wiki.pine64.org/index.php?title=PinePhone_Installation_Instructions&diff=11948PinePhone Installation Instructions2021-12-08T15:12:04Z<p>Nerdcore: /* Using Parted */</p>
<hr />
<div>This section has generic installation instructions. Please see the [[PinePhone Software Releases]] section for specific installation instructions for each distribution.<br />
<br />
== Boot priority ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
Note: Booting from USB is not supported by the hardware, a live USB stick will not boot.<br />
<br />
== Installation to the microSD ==<br />
[[Image:Pinephone_backside.png|thumb|The microSD belongs in the upper slot, the micro SIM in the lower slot.]]<br />
<br />
To install an image to the microSD card:<br />
<br />
# Download your chosen image from [[PinePhone Software Releases]]<br />
# Extract the compressed file<br />
# Write the image to your SD card, see below<br />
# Plug SD card into phone (make sure to use the top slot. NOT the bottom one)<br />
# Boot phone<br />
<br />
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.<br />
<br />
=== Flashing the microSD ===<br />
==== Using dd ====<br />
Make sure to select the correct device using <code>lsblk</code>. Then run <code>dd</code> with the correct device:<br />
<br />
<pre><br />
sudo dd if=pine.img of=/dev/[DEVICE] bs=1M status=progress conv=fsync<br />
</pre><br />
<br />
==== Using bmaptool ====<br />
Make sure to select the correct device using <code>lsblk</code>. Then run bmaptool with the correct device:<br />
<br />
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.<br />
<br />
==== Using graphical tools ====<br />
GUI applications such as Etcher and GNOME Disks can be used to flash the MicroSD too.<br />
<br />
== Installation to the eMMC ==<br />
=== Using JumpDrive ===<br />
<br />
[[File:jumpdrive.jpg|400px|thumb|right|Jumpdrive running on the PinePhone]]<br />
The internal eMMC flash storage can be flashed using the Jumpdrive utility by Danct12 and Martijn from postmarketOS.<br />
This utility boots from micro SD and exposes the internal eMMC flash storage when the PinePhone is connected to a computer.<br />
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.<br />
<br />
Latest Jumpdrive can be found [https://github.com/dreemurrs-embedded/Jumpdrive/releases/ here].<br />
<br />
# Download and extract [https://github.com/dreemurrs-embedded/Jumpdrive/releases the Jumpdrive image]<br />
# Flash the Jumpdrive image to a micro SD card<br />
# Boot the PinePhone from the Jumpdrive micro SD card<br />
# Connect the PinePhone to your computer using USB-A -> USB-C cable<br />
# 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<br />
# Once the flashing process is complete, disconnect the PinePhone from your PC, power it down and remove the Jumpdrive SD card<br />
# The process is now finished, and you can boot from eMMC<br />
<br />
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!<br />
<br />
=== From the booted microSD OS ===<br />
<br />
# Flash an OS to the SD card (and optionally resize the partition, see below)<br />
# Insert SD card and boot the phone<br />
# Download the desired OS' image on the booted OS or transfer it to the SD card<br />
# Extract the image file if it is archived<br />
# 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. <br />
# Turn off phone, remove SD card and then turn on the phone.<br />
<br />
=== From the booted microSD OS (risky) ===<br />
<br />
{{Warning|This copies a mounted filesystem, which can lead to instability, erratic behavior, and data corruption.}}<br />
<br />
# Prepare a new SD card, flash desired OS to the SD card<br />
# Boot the phone with your new SD card image<br />
# 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.<br />
# Turn off phone, take out SD card, and try booting the phone which should load up the new OS from eMMC.<br />
# Open terminal and resize partition to fill up entire disk (see below).<br />
<br />
=== SD to eMMC via installer ===<br />
<br />
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.<br />
<br />
== Resize partition to fit disk space ==<br />
<br />
{{Hint|Many OSes already include a script, which is resizing the partition on first boot, where this step is not required.}}<br />
<br />
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.<br />
<br />
=== Resize SD card's partition using computer ===<br />
<br />
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:<br />
<br />
====Using Growpart ====<br />
<br />
Install <i>growpart</i> and run:<br />
growpart /dev/mmcblkX Y<br />
resize2fs /dev/mmcblkXpY<br />
where X is the storage device and Y is the partition number (viewable from <code>lsblk</code>).<br />
<br />
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>.<br />
<br />
====Using Parted ====<br />
<br />
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.<br />
<br />
sudo parted /dev/<your_sd_card_device><br />
(parted) resizepart 2 100%<br />
(parted) quit<br />
sudo resize2fs /dev/<the_second_sd_card_PARTITION><br />
<br />
=== Resize from within PinePhone ===<br />
<br />
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. <br />
<br />
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.<br />
<br />
== Reuse SD card for data storage on system booting from eMMC==<br />
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.<br />
<br />
This can be done as follows on any linux system:<br />
lsblk<br />
to check the device of your SD card – as an example lets assume it is /dev/mmcblk0<br />
then<br />
sudo dd if=/dev/zero of=/dev/<your_sd_card_device> bs=8k seek=1 count=4<br />
will clear the relevant sectors of your card.<br />
<br />
== Web resources ==<br />
<br />
* [https://www.youtube.com/watch?v=7HMkU43P9hw Youtube video on how to flash OS images on the Pinephone (SD or eMMC) by Tech Pills]<br />
* [https://www.youtube.com/watch?v=u65dofYFAPY Youtube video on How to install different OSes On the PinePhone plus an Mobian overview by Elatronion]<br />
<br />
<br />
[[Category:PinePhone]][[Category:Guide]]</div>Nerdcore