Difference between revisions of "PinePhone Installation Instructions"

From PINE64
Jump to navigation Jump to search
(→‎Web resources: language)
m (category)
(14 intermediate revisions by 3 users not shown)
Line 19: Line 19:
=== Flashing the microSD ===
=== Flashing the microSD ===
==== Using dd ====
==== Using dd ====
Make sure to select the correct device using <code>lsblk</code>. Then run dd with the correct device:
Make sure to select the correct device using <code>lsblk</code>. Then run <code>dd</code> with the correct device:


<code>sudo dd if=pine.img of=/dev/[DEVICE] bs=1M status=progress conv=fsync</code>
<pre>
sudo dd if=pine.img of=/dev/[DEVICE] bs=1M status=progress conv=fsync
</pre>


==== Using bmaptool ====
==== Using bmaptool ====
Line 34: Line 36:
=== Using JumpDrive ===
=== Using JumpDrive ===


# download and extract [https://github.com/dreemurrs-embedded/Jumpdrive/releases the Jumpdrive image]
[[File:jumpdrive.jpg|400px|thumb|right|Jumpdrive running on the PinePhone]]
# flash the Jumpdrive image to a SD card
The internal eMMC flash storage can be flashed using the Jumpdrive utility by Danct12 and Martijn from postmarketOS.
# boot from the SD card
This utility boots from micro SD and exposes the internal eMMC flash storage when the PinePhone is connected to a computer.
# connect the PinePhone to your computer using USB-A -> USB-C cable.
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.
# flash the exposed (mounted) PinePhone drive with a chosen OS image as you'd flash any SD card, and resize partitions (optional, see below)
# disconnect the PinePhone from your PC, power it down and remove the Jumpdrive SD card
# boot into your OS of choice on 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.
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]
# Flash the Jumpdrive image to a micro SD card
# Boot the PinePhone from the Jumpdrive micro SD card
# 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
# Once the flashing process is complete, disconnect the PinePhone from your PC, power it down and remove the Jumpdrive SD card
# 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!


=== From the booted microSD OS ===
=== From the booted microSD OS ===


# Prepare a formatted SD card, flash desired OS to the SD card, and (optionally) resize the partition (see below)
# Flash an OS to the SD card (and optionally resize the partition, see below)
# Insert SD card and boot the phone
# Insert SD card and boot the phone
# Open terminal and <code>git clone [url]</code> your desired project OR: Open web browser and download the desired OS image file.
# Download the desired OS' image on the booted OS or transfer it to the SD card
# Build the OS (Optional)
# Extract the image file if it is archived
# Flash the resulting image file you got by downloading or by building, to eMMC, using <code>dd if=new-pinephone-image.img of=/dev/mmcblkY bs=1M status=progress</code> where X is the number label of the SD card, and Y is the number label of the eMMC. 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. Then, resize partition to fill up entire disk (see below).
# 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. Turn on phone.
# Turn off phone, remove SD card and then turn on the phone.


=== From the booted microSD OS (risky) ===
=== From the booted microSD OS (risky) ===


{{Warning|This copies a mounted filesystem, which can lead to instability, erratic behavior, and data corruption. Do not use long term.}}
{{Warning|This copies a mounted filesystem, which can lead to instability, erratic behavior, and data corruption.}}


# Prepare a new SD card, flash desired OS to the SD card
# Prepare a new SD card, flash desired OS to the SD card
Line 68: Line 77:


== 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.}}


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 SD card or eMMC storage, you may also need to expand the partition to fill all the available space.
Line 77: Line 88:
====Using Growpart ====
====Using Growpart ====


Locate growpart (<code>apt-cache search growpart</code> and install the package in the search results) 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 lsblk).
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 apt-cache search to find and install the needed software. Also don't forget to use sudo.
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 ====
Line 97: Line 108:
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 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.  


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.
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.


== Reuse SD card for data storage on system booting from eMMC==
== Reuse SD card for data storage on system booting from eMMC==
Line 106: Line 117:
to check the device of your SD card – as an example lets assume it is /dev/mmcblk0
to check the device of your SD card – as an example lets assume it is /dev/mmcblk0
then
then
  sudo dd if=/dev/zero of=/dev/mmcblk0 bs=8k seek=1 count=4
  sudo dd if=/dev/zero of=/dev/<your_sd_card_device> bs=8k seek=1 count=4
will clear the relevant sectors of your card.
will clear the relevant sectors of your card.


Line 115: Line 126:




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

Revision as of 07:33, 19 June 2021

This section has generic installation instructions. Please see the PinePhone Software Releases section for specific installation instructions for each distribution.

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.

Installation to the microSD

To install an image to the microSD card:

  1. Download your chosen image from PinePhone Software Releases
  2. Extract the compressed file
  3. Write the image to your SD card, see below
  4. Plug SD card into phone
  5. Boot phone

If you need step-by-step instructions for writing an image to an SD card, check the NOOB guide, then return to this page.

Flashing the microSD

Using dd

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

sudo dd if=pine.img of=/dev/[DEVICE] bs=1M status=progress conv=fsync

Using bmaptool

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

Download the .img.xz and the .img.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 graphical tools

GUI applications such as Etcher and GNOME Disks can be used to flash the MicroSD too.

Installation to the eMMC

Using JumpDrive

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 SD 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 micro SD card
  3. Boot the PinePhone from the Jumpdrive micro SD 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 SD card
  7. 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!

From the booted microSD OS

  1. Flash an OS to the SD card (and optionally resize the partition, see below)
  2. Insert SD card and boot the phone
  3. Download the desired OS' image on the booted OS or transfer it to the SD card
  4. Extract the image file if it is archived
  5. Flash the image file to eMMC using dd if=new-pinephone-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 SD 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 SD card and then turn on the phone.

From the booted microSD OS (risky)

Warning: This copies a mounted filesystem, which can lead to instability, erratic behavior, and data corruption.
  1. Prepare a new SD card, flash desired OS to the SD card
  2. Boot the phone with your new SD card image
  3. 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.
  4. Turn off phone, take out SD card, and try booting the phone which should load up the new OS from eMMC.
  5. Open terminal and resize partition to fill up entire disk (see below).

SD to eMMC via installer

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 calamares-extensions#7), so other distributions might adopt this in the future.

Resize partition to fit disk space

Many OSes 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.

Resize SD card's partition using 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:

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 SD 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 resize /dev/<the_second_sd_card_PARTITION>

Resize from within 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.

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.

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.

This can be done as follows on any linux system:

lsblk

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

sudo dd if=/dev/zero of=/dev/<your_sd_card_device> bs=8k seek=1 count=4

will clear the relevant sectors of your card.

Web resources