Difference between revisions of "Pidora-Headless-Mode"

From CDOT Wiki
Jump to: navigation, search
(Enabling headless mode on Pidora)
(Known Bugs and Features)
 
(32 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{Pidora}}[[Category:Pidora 18 (Raspberry Pi Fedora Remix)]]
 
{{Pidora}}[[Category:Pidora 18 (Raspberry Pi Fedora Remix)]]
  
{{Admon/important | Notice |Headless mode is currently a experimental feature, updates to headless mode and current issues can be found below}}
+
= What is headless mode? =
  
== What is headless mode? ==
+
{{Admon/important| Security Warning! | If you are going to use headless mode it is critical that you change the root password as soon as possible, because Pidora is set with a default root password that is publicized.}}
  
 
Headless mode is a system configuration which enables access to a raspberry pi, through ssh on a network, without the use of a monitor or keyboard plugged into the raspberry pi. This mode does require another computer to ssh into the raspberry pi. When this feature is enabled, [[Pidora 18 Firstboot|firstboot]] is bypassed and disabled.
 
Headless mode is a system configuration which enables access to a raspberry pi, through ssh on a network, without the use of a monitor or keyboard plugged into the raspberry pi. This mode does require another computer to ssh into the raspberry pi. When this feature is enabled, [[Pidora 18 Firstboot|firstboot]] is bypassed and disabled.
  
 +
Additionally, Headless Mode will enable services to read your IP Address through plugged in speakers or headphones. It will also flash the IP Address to you on the Raspberry Pi LEDs.
  
{{Admon/important| Security Warning! | If you are going to use headless mode it is critical that you change the root password as soon as possible, because Pidora is set with a default root password that is publicized.}}
+
= Enabling Headless Mode on Pidora =
  
== Enabling Headless Mode on Pidora ==
+
To enable Headless Mode, create a file named "headless" inside the boot file system on the Raspberry Pi's SD card. Create this "headless" file before you boot your Raspberry Pi.
  
To enable Headless Mode, a file should be created in the boot file system. This file should be named "headless"(the first file found that starts with "headless" will be used).
+
== Enable Headless Mode On Linux ==
  
 +
Tutorial Video: http://youtu.be/ALUAmw6Mz_o
  
{{Admon/important| Note | This file should be created ''before'' you boot your Raspberry Pi, for Headless Mode to take effect and enable the correct mode of networking.}}
+
Insert the SD card into your system, and create a file named "headless" in the filesystem labelled "boot".
  
 +
== Enable Headless Mode On Windows ==
 +
{{Admon/important| Note | If you are using a Windows OS you will need to remove the .txt file extension on the headless file.
 +
[http://www.ehow.com/how_6394953_create-file-extension.html More information on removing file extensions on eHow]}}
 +
Insert the SD card into your system. Only the boot filesystem will be made available, because Windows will not be able to read other partitions on the card. Create a file named "headless" on that partition
  
'''On Linux''':
+
There are two possible configurations for Headless Mode "DHCP" configuration and "Static" configuration.
  
Tutorial Video: http://youtu.be/ALUAmw6Mz_o
+
== DHCP Configuration ==
  
Insert the SD card into your system, and create a file named "headless" in the filesystem labelled "boot".
+
If you would like to configure the Raspberry Pi to use DHCP, ''leave the "headless" file empty'',  and the Raspberry Pi should be assigned an IP Address dynamically.
  
'''On Windows:'''
+
====Optional Configuration====
 +
If "RESIZE" is in the "headless" file, the root filesystem will be expanded to the maximum size of the sd card via the service rootfs-resize. If "SWAP"(requires the value in megabytes) exists in the "headless" file, a swap file will be created of the specified size, and then activated.
  
Insert the SD card into your system. Only the boot filesystem will be made available, because Windows will not be able to read other partitions on the card. Create a file named "headless" on that partition
+
RESIZE
 
+
SWAP=[Size of swap in megabytes]
{{Admon/important| Note | If you are using a Windows OS you will need to remove the .txt file extension on the headless file.
 
[http://www.ehow.com/how_6394953_create-file-extension.html More information on removing file extensions on eHow]}}
 
  
There are two possible configurations for Headless Mode "DHCP" configuration and "Static" configuration.
+
====How do I find my IP Address? ====
  
=== DHCP Configuration ===
+
Once Headless Mode has been Enabled, and the Raspberry Pi has finished booting, the IP Address of the Raspberry Pi will be read out through the speakers or headphones that are connected to the Raspberry Pi. Additionally, the IP Address will be flashed through the LED on the Raspberry Pi soon after the IP Address is read through the speakers.
  
If you would like to obtain an ip address dynamically via DHCP, leave the "headless" file empty.
+
1 - 9 short flashes indicate the digits 1 - 9
 +
10 short flashes indicate the digit 0
 +
a long flash indicates an octet separator (dot)
 +
a brief pause separates digits
  
If you would like to configure the Raspberry Pi to use DHCP, ''leave the "headless" file empty'',  and the Raspberry Pi should be assigned an IP Address dynamically.
+
[https://github.com/ctyler/ip-info/blob/master/README.md For more information about IP Address reading and IP Address flashing, click here]
  
=== Static Configuration ===
+
== Static Configuration ==
  
 
If you would like to set a static, non-changing, IP Address on your Raspberry Pi, you will need to modify the "headless" file, adding an IP Address, Gateway, and Netmask, to the file for the configurations to work properly(see samples configs below).
 
If you would like to set a static, non-changing, IP Address on your Raspberry Pi, you will need to modify the "headless" file, adding an IP Address, Gateway, and Netmask, to the file for the configurations to work properly(see samples configs below).
  
'''Static Configuration:'''
+
====Required Configuration====
Required parameters for a Headless Mode static configuration.
 
  
IPADDR=[IP Address of Raspberry Pi]
+
IPADDR=[IP Address of Raspberry Pi]
NETMASK=[Mask to define network subnet]
+
NETMASK=[Mask to define network subnet]
GATEWAY=[IP Address of router/gateway]
+
GATEWAY=[IP Address of router/gateway]
  
'''Optional Configuration:'''
+
====Optional Configuration====
 
If "RESIZE" is in the "headless" file, the root filesystem will be expanded to the maximum size of the sd card via the service rootfs-resize. If "SWAP"(requires the value in megabytes) exists in the "headless" file, a swap file will be created of the specified size, and then activated.
 
If "RESIZE" is in the "headless" file, the root filesystem will be expanded to the maximum size of the sd card via the service rootfs-resize. If "SWAP"(requires the value in megabytes) exists in the "headless" file, a swap file will be created of the specified size, and then activated.
  
RESIZE
+
RESIZE
SWAP=[Size of swap in megabytes]
+
SWAP=[Size of swap in megabytes]
 +
 
 +
= Sample Headless Mode Configurations =
  
=== Sample Headless Mode Static Configuration ===
+
Below are sample configurations, they may require you to enter valid ip information specific to the network you are running it on.
  
Static Configuration(without rootfs resizing or swap creation):
+
====Static Configuration(without rootfs resizing or swap creation)====
 
  IPADDR=192.168.1.105
 
  IPADDR=192.168.1.105
 
  NETMASK=255.255.255.0
 
  NETMASK=255.255.255.0
 
  GATEWAY=192.168.1.1
 
  GATEWAY=192.168.1.1
  
Static Configuration(with rootfs resizing and swap creation):
+
====Static Configuration(with rootfs resizing and swap creation)====
 
  IPADDR=192.168.1.105
 
  IPADDR=192.168.1.105
 
  NETMASK=255.255.255.0
 
  NETMASK=255.255.255.0
Line 70: Line 79:
 
  SWAP=512
 
  SWAP=512
  
== Headless Mode is enable with DHCP -- How do I find out my ip-address? ==
+
====Dynamic Configuration(with rootfs resizing and swap creation)====
 +
RESIZE
 +
SWAP=512
 +
 
 +
= SSH to The Headless Pi =
  
After you have enabled headless mode with either the DHCP configuration or Static IP configuration, the ip address that has been assigned to Raspberry Pi will be played through the speakers '''2 minutes''' after you have powered the Raspberry Pi, and '''30 seconds''' later it will also flash your ip address through Pi's OK/ACT LED.
+
Default User: root
 +
Default Password: raspberrypi
 +
ssh root@{ip_address}
  
[https://github.com/ctyler/ip-info/blob/master/README.md More information about ip-read and ip-flash]
+
= Known Bugs and Features =
  
== Headless Mode Script Update ==
+
====Two IP Addresses====
Initially there were a few issues with dchp and headless mode since our release the headless script has been updated. It has not been officially added to the updates repo yet but, if you are interested in trying this mode out now you can copy and replace the old headon script with the updated one located at /usr/bin/headon
+
When switching in between Headless Mode Configuration states, static ip to dynamic ip, or dynamic ip to static ip, both IP Addresses from each configuration will be active for the single boot, until a reboot takes place.
  
#!/bin/bash
+
====Graphical Mode Not Disabled====
headless=`ls /boot/headless* 2> /dev/null | head -n 1`
+
Headless Mode does not disable X, and can run in both Run Level 3 or 5. This means that if you are not planning on using X while in Headless Mode, you should switch to Run Level 3 to save memory.
echo "Headless Mode Enabled"
 
if [ -e "$headless" ]
 
then
 
      systemctl enable sshd.service
 
      systemctl start sshd.service
 
      systemctl stop firstboot-graphical.service
 
      systemctl disable firstboot-graphical.service
 
 
      headtext=`grep '[0-9]' "$headless"`
 
      if [ "$headtext"  != "" ]
 
      then
 
 
              ip_address=$(sed -n 's/IPADDR=//p' $headless)
 
              ip_netmask=$(sed -n 's/NETMASK=//p' $headless)
 
              ip_gateway=$(sed -n 's/GATEWAY=//p' $headless)
 
              swap_size=$(sed -n 's/SWAP=//p' $headless)
 
 
              cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
 
DEVICE=eth0
 
IPADDR=$ip_address
 
NETMASK=$ip_netmask
 
GATEWAY=$ip_gateway
 
BOOTPROTO=static
 
ONBOOT=yes
 
NM_CONTROLLED=yes
 
EOF
 
 
              systemctl restart NetworkManager.service
 
 
      else
 
 
              cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
 
DEVICE=eth0
 
BOOTPROTO=dhcp
 
ONBOOT=yes
 
NM_CONTROLLED=yes
 
EOF
 
 
      fi
 
else
 
      systemctl stop headless-mode.service
 
      systemctl disable headless-mode.service
 
fi
 
 
#Check headless file for resize option
 
 
#Check headless file for resize and swap option
 
grep -iE 'resize|swap' $headless
 
 
if [ $? -eq 0 -a ! -f /.resized ]
 
then
 
        touch /.rootfs-repartition
 
        touch /.resized
 
    echo $swap | grep -o '[0-9]*' > /.swap
 
        reboot
 
else
 
#resized already remove resize flag if it exists
 
        rm -f /.rootfs-repartition
 
    rm -f /.swap
 
fi
 
 
#read ip address
 
systemctl start ip-read.service
 
#flashing ip address
 
systemctl start ip-flash.service
 
  
== SSH to the headless Pi ==
+
[https://fedoraproject.org/wiki/Systemd#How_do_I_change_the_target_.28runlevel.29_.3F For more information about changing Run Levels on Pidora, click here.]
  
ssh root@{ip_address}
+
====Slower Boot====
Default user: root/raspberrypi
+
When running headless mode, the speed of the boot is slowed down, this is due to a network change during boot.

Latest revision as of 15:50, 29 April 2014

Pidora-horizontal.png

What is headless mode?

Important.png
Security Warning!
If you are going to use headless mode it is critical that you change the root password as soon as possible, because Pidora is set with a default root password that is publicized.

Headless mode is a system configuration which enables access to a raspberry pi, through ssh on a network, without the use of a monitor or keyboard plugged into the raspberry pi. This mode does require another computer to ssh into the raspberry pi. When this feature is enabled, firstboot is bypassed and disabled.

Additionally, Headless Mode will enable services to read your IP Address through plugged in speakers or headphones. It will also flash the IP Address to you on the Raspberry Pi LEDs.

Enabling Headless Mode on Pidora

To enable Headless Mode, create a file named "headless" inside the boot file system on the Raspberry Pi's SD card. Create this "headless" file before you boot your Raspberry Pi.

Enable Headless Mode On Linux

Tutorial Video: http://youtu.be/ALUAmw6Mz_o

Insert the SD card into your system, and create a file named "headless" in the filesystem labelled "boot".

Enable Headless Mode On Windows

Important.png
Note
If you are using a Windows OS you will need to remove the .txt file extension on the headless file. More information on removing file extensions on eHow

Insert the SD card into your system. Only the boot filesystem will be made available, because Windows will not be able to read other partitions on the card. Create a file named "headless" on that partition

There are two possible configurations for Headless Mode "DHCP" configuration and "Static" configuration.

DHCP Configuration

If you would like to configure the Raspberry Pi to use DHCP, leave the "headless" file empty, and the Raspberry Pi should be assigned an IP Address dynamically.

Optional Configuration

If "RESIZE" is in the "headless" file, the root filesystem will be expanded to the maximum size of the sd card via the service rootfs-resize. If "SWAP"(requires the value in megabytes) exists in the "headless" file, a swap file will be created of the specified size, and then activated.

RESIZE
SWAP=[Size of swap in megabytes]

How do I find my IP Address?

Once Headless Mode has been Enabled, and the Raspberry Pi has finished booting, the IP Address of the Raspberry Pi will be read out through the speakers or headphones that are connected to the Raspberry Pi. Additionally, the IP Address will be flashed through the LED on the Raspberry Pi soon after the IP Address is read through the speakers.

1 - 9 short flashes indicate the digits 1 - 9
10 short flashes indicate the digit 0
a long flash indicates an octet separator (dot)
a brief pause separates digits

For more information about IP Address reading and IP Address flashing, click here

Static Configuration

If you would like to set a static, non-changing, IP Address on your Raspberry Pi, you will need to modify the "headless" file, adding an IP Address, Gateway, and Netmask, to the file for the configurations to work properly(see samples configs below).

Required Configuration

IPADDR=[IP Address of Raspberry Pi]
NETMASK=[Mask to define network subnet]
GATEWAY=[IP Address of router/gateway]

Optional Configuration

If "RESIZE" is in the "headless" file, the root filesystem will be expanded to the maximum size of the sd card via the service rootfs-resize. If "SWAP"(requires the value in megabytes) exists in the "headless" file, a swap file will be created of the specified size, and then activated.

RESIZE
SWAP=[Size of swap in megabytes]

Sample Headless Mode Configurations

Below are sample configurations, they may require you to enter valid ip information specific to the network you are running it on.

Static Configuration(without rootfs resizing or swap creation)

IPADDR=192.168.1.105
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

Static Configuration(with rootfs resizing and swap creation)

IPADDR=192.168.1.105
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
RESIZE
SWAP=512

Dynamic Configuration(with rootfs resizing and swap creation)

RESIZE
SWAP=512

SSH to The Headless Pi

Default User: root
Default Password: raspberrypi
ssh root@{ip_address}

Known Bugs and Features

Two IP Addresses

When switching in between Headless Mode Configuration states, static ip to dynamic ip, or dynamic ip to static ip, both IP Addresses from each configuration will be active for the single boot, until a reboot takes place.

Graphical Mode Not Disabled

Headless Mode does not disable X, and can run in both Run Level 3 or 5. This means that if you are not planning on using X while in Headless Mode, you should switch to Run Level 3 to save memory.

For more information about changing Run Levels on Pidora, click here.

Slower Boot

When running headless mode, the speed of the boot is slowed down, this is due to a network change during boot.