Menu Close

Handling SD card Image files

General Notes about the provided SD card images.
All Images are as small as possible. That means, usually they fit onto a relatively small SD card. To copy the image onto a SD card, you need some image writing software. On the other hand, the images have only little space left, so after writing the image to an SD card, you need to maximize the file system size to the maximum size of your SD card after installation.

Youn need: 
1. A SD card with a minimum size of at least  the size of the image file. 
2. SD card Adapter/hardware so the SD card can be acessed by your Operating system.

Writing a SD card image to a SD card on Linux: 
1. List the /dev directory of your system without connected SD card
2. Connect the SD card to the System
3. List the /dev directory again and compare for differences. 
4. Typically you see at least two additional devices for example: /dev/sdc, and eventually /dev/sdc1 and possibly /dev/sdc2 
5. Make sure you found your sd card devices by disconnect the SD card again and check the /dev again
6. Once you are sure which are the devices of your SD card, you may write the image file to your SD card
7. Use dd: dd if=<Path to your SD card image file>  bs=1M of=<major device you just found - for example /dev/sdc> status=progress :
    So a real command could look like: 
    dd if=/home/data/raspi3b_bechele_raspbian.img bs=2M of=/dev/sdc status=progress
8. After writing the image, disconnect it from the adapter and put it into your mini computer.

Writing a SD card on Windows:
Here you need a image software, such as Win32DiskImager. Please read the instructions for the imager software you use.
Be careful: Windows tends to detect SD cards automatically and if recognized as unformatted, it will ask persistantly for formatting. 
!!!!!!  DO NOT FORMAT the SD CARD !!!!!!! The format comes along with the image. Also after writing, sometimes Windows tends to ask again, because the format on the SD is unknown to Windows.  !!!!!! Remove the card immediately after writing, otherwise you take risk Windows spoils ther content !!!!!!  (happened several times to me though I never answered the formatting question positively) 

Booting your mini computer (RASPI or OrangePI):
After inserting the SD card, just power up your mini computer.
If you connected a LAN cable and you have a DHCP server in your network, the OS will aks for an IP address and you may afterwards connect via SSH directy from remote. (If you have a router, check with the router software, which IP has been given to the minicomputer) 
Since all of the provided images are prepared to work "Headless" means you do not need Monitor and keyboard, the SSH Daemon on the Minicomputer is already active.
Though standard distributions do not do this any more for security reasons, I take the security risk as minimal, since practically all networks are protected by NAT or a fireWall. 
The risk we have is, that if an attacker knows the default login and password for this system, he might login and install some backdoors quicker than you can to change the password and thererfore take over control. 
However if you are in doubt, do not connect a network initially, but connect keyboard and monitor and change the password after the first login. After that you are safe.

Login: rolf
Password: bechele

Canging the password to somewhat more safe:
passwd rolf - then follow the screen info  - This step is a must - if you omit, others may guess your login !!!

Changing the file system size, so it uses the whole SD card space:
The Image for OrangePi-PC has only one file system on the SD ( that later takes the whole SD card), but the Raspi images contain two file systems, where the second takes later the rest of the SD card. 
1. check the existing file system(s): 

df -h (orangePi)
Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
udev            427M       0  427M    0% /dev
tmpfs           100M    2,0M   98M    3% /run
>>>>> /dev/mmcblk0p1  2,2G    1,6G  621M   72% /   <<<<< the interesting one
tmpfs           499M       0  499M    0% /dev/shm
tmpfs           5,0M       0  5,0M    0% /run/lock
tmpfs           499M       0  499M    0% /tmp
/dev/zram1       47M    3,2M   41M    8% /var/log
tmpfs           100M       0  100M    0% /run/user/1000

df -h (Raspberry Pi)
Filesystem      Size  Used Avail Use% Mounted on
udev            319M     0  319M   0% /dev
tmpfs            91M  988K   90M   2% /run
>>>>> /dev/mmcblk0p2  3.0G  2.3G  473M  84% /   <<<<< the interesting one
tmpfs           455M     0  455M   0% /dev/shm
tmpfs           5.0M   12K  5.0M   1% /run/lock
/dev/mmcblk0p1  510M   61M  450M  12% /boot/firmware
tmpfs            91M     0   91M   0% /run/user/1000

The following steps need to be done with care !! - failing here may render the SD card unusable and might require to write the image again.
All subsequent steps require Administator (root) permission

Deleting the Parition to extend (though we delete, the content remains):
sudo fdisk /dev/mmcblk0
Though we get a warning - we do not respect:

p   -print the partition table

On RaspberryPi:
Device         Boot   Start     End Sectors  Size Id Type
/dev/mmcblk0p1         8192 1056767 1048576  512M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      1056768 7396684 6339917    3G 83 Linux

Note the start number for  /dev/mmcblk0p2

On OrangePi:
Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk0p1       8192 4738460 4730269  2,3G 83 Linux

Note the start number for  /dev/mmcblk0p1

d   -deletes a partition
On Orangepi you get the info "Partition1 has been deleted"
On RaspberryPi you will be asked "Partition number (1,2, default 2):" - just hit enter

n   -creates a new partition
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p):  - just hit enter

Partition number (2-4, default 2):  - just hit enter (on Orangepi the default is 1)

First sector (2048-61067263, default 2048): < enter here the start number you noted before > (1056768 on a raspberryPi and 8192 on a OrangePi)
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1056768-61067263, default 61067263): just hit enter for the default

Created a new partition 2 of type 'Linux' and of size 28.6 GiB.  (of course this is depending on your SD card)
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: enter "n" (we don't want to delete the signature)

p    -to show the new partition table

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p1         8192  1056767  1048576  512M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      1056768 61067263 60010496 28.6G 83 Linux

If the start number of the changed partition is like before you may save with:

w  -to write the new created partition table

q  -to quit

Now we are back in the command prompt and we might resize the file system (mmcblk0p2 on RasperryPi and mmcblk0p1 on Orangepi

sudo resize2fs /dev/mmcblk0p2
At the end of the resizing it will tell you the new size.

with df -h you may see the new "gained" space.

Filesystem      Size  Used Avail Use% Mounted on
udev             82M     0   82M   0% /dev
tmpfs            43M  940K   42M   3% /run
/dev/mmcblk0p2   29G  2.3G   25G   9% /
tmpfs           215M     0  215M   0% /dev/shm
tmpfs           5.0M   12K  5.0M   1% /run/lock
/dev/mmcblk0p1  510M   93M  418M  19% /boot/firmware
tmpfs            43M     0   43M   0% /run/user/1000