Difference between revisions of "Raspberry Pi Fedora Remix Administration"

From CDOT Wiki
Jump to: navigation, search
(Root Privilege: root, consolehelper, su, and sudo)
(Adding Swap Space)
 
(3 intermediate revisions by the same user not shown)
Line 71: Line 71:
  
 
* Add a user:
 
* Add a user:
** <code>useradd ''name''</code> # The -m option required on some systems is not needed - the user's home directory will be created automatically.1
+
** <code>useradd ''name''</code> # The -m option required on some systems is not needed - the user's home directory will be created automatically.
 
** <code>useradd -c "''Full Name''" ''username''</code>
 
** <code>useradd -c "''Full Name''" ''username''</code>
 
* Set a password:
 
* Set a password:
Line 85: Line 85:
 
== Adding Swap Space ==
 
== Adding Swap Space ==
  
The Raspberry Pi Fedora Remix doesn't provision swap space by default, since the advisability of swapping to SD is debated.
+
The Raspberry Pi Fedora Remix 14 doesn't provision swap space by default.
  
 
If you wish to add swap space, you can easily do so:
 
If you wish to add swap space, you can easily do so:
Line 102: Line 102:
  
 
To make the card resize the second partition the first time the new card is booted:
 
To make the card resize the second partition the first time the new card is booted:
# Mount the second partition: <code>mkdir /mnt/sd-partition-2; mount /dev/sda2 /mnt/sd-p2</code>
+
# Mount the second partition: <code>mkdir /mnt/sd-p2; mount /dev/sda2 /mnt/sd-p2</code>
 
# Create the empty file <code>/.autoresize</code>: <code>touch /mnt/sd-p2/.autoresize</code>
 
# Create the empty file <code>/.autoresize</code>: <code>touch /mnt/sd-p2/.autoresize</code>
 
# Unmount the partition: <code>umount /mnt/sd-p2</code>
 
# Unmount the partition: <code>umount /mnt/sd-p2</code>
Line 112: Line 112:
 
== Changing the Memory Mix ==
 
== Changing the Memory Mix ==
  
The Raspberry Pi (model B) ships with 256M of memory. This memory is split between the ARM and GPU halves of the System-on-a-Chip (SOC). You can change the memory allocation by selecting a different start.elf program:
+
The Raspberry Pi (model A or B) ships with 256M of memory. This memory is split between the ARM and GPU halves of the System-on-a-Chip (SOC). You can change the memory allocation by selecting a different start.elf program:
  
 
* For a 128M ARM / 128M GPU split (heavy graphics): <code>cp /boot/arm128_start.elf /boot/start.elf</code>
 
* For a 128M ARM / 128M GPU split (heavy graphics): <code>cp /boot/arm128_start.elf /boot/start.elf</code>

Latest revision as of 12:44, 18 September 2012

width=100

Fedora-Style System Administration

The Raspberry Pi Fedora Remix is managed in the same way as most Linux systems (specifically, like a Fedora system, since most of the software packages in the Remix come from Fedora ARM).

If you're new to Linux system administration or are coming from another distribution (such as Ubuntu), here are some quick tips on Fedora Remix system administration:

Root Privilege: root, consolehelper, su, and sudo

Linux is designed for use by multiple users. Most users do not have access (privilege) to perform system administration operations or to read other users' files, unless specifically granted permission. This security division also makes it harder for malicious web or e-mail content to exploit a bug to attack the core of the operating system.

The "root" user has full privilege -- she can do anything. There are four ways to gain root privilege:

  1. Login as "root" and enter the root password. This is useful when you can't log in as any other user. It is unwise to run applications as root unnecessarily -- for example, if you run a web browser as root, and a remote site exploits a security bug in the browser, then running the browser as root could enable the remote attacker could add or remove software or perform other administrative tasks.
  2. Use an application that is hooked into the consolehelper system, such as system-config-network. You will be prompted for a password (either the user password or the root password, depending on the application configuration) and then the application will run with enhanced privilege. Most of the applications on the Administration menu in the graphical interface work this way.
  3. Use the "su" command to switch users (by default, it will switch to the root user). Type su and press enter, and enter the root password when prompted. This is useful when you have a number of system administration commands you want to run in a row. However, you must remember to switch back to your regular user account as soon as you no longer require privilege -- to do so, type exit or press Ctrl-D (for "Done"!).
  4. Use the sudo command to switch users for the duration of one command.
    • To enable use of the sudo command:
      1. Run visudo as root to edit the sudo configuration file.
      2. Remove the "#" character at the front of the line that reads: %wheel ALL=(ALL) ALL
      3. Save the file and exit.
      4. Add each user who should have sudo access to the wheel group: usermod -aG wheel NameOfUser
    • To execute a command as root, just write "sudo" in front of the command. For example: sudo yum install inkscape

Updating, Adding, and Removing Software

The Remix uses RPM packages with the YUM package manager. This provides a database of all of the software installed on the system, a way to install/remove/update software packages without breaking software dependencies, and network access to remote software repositories.

Adding/removing software with YUM requires an Internet connection.

Package Management from the Command Line

These are the most common YUM commands:

  • Update software:
    • yum update packagename # Updates just the one package.
    • yum update # Updates all packages
  • Search for a package by name:
    • yum list packagename # Will match only packagename.
    • yum list "*partialname*" # Will match any package with partialname in the package name.
  • Search for a package by name or description:
    • yum search text
  • Display information about a package:
    • yum info packagename
  • Install a package:
    • yum install packagename # More than one packagename may be given.
  • Install a package group:
    • yum groupinstall "groupname"
    • yum install "@groupname" # Useful if you want to install some individual packages and a group at the same time.
  • List package groups:
    • yum grouplist
  • List the packages in a group:
    • yum groupinfo "groupname"
  • Remove a package:
    • yum remove "packagename" # Beware! This will also remove packages which depend on what you're removing. Read the list of packages to be removed carefully before approving it.
  • Remove a package group:
    • yum groupremove "groupname"<code>
    • <code>yum remove "@groupname" # Useful if you want to remove some individual packages and a group at the same time.

For more information, see the manpage for yum.

Package Management Using the Graphical User Interface

To update software graphically, use the menu option Administration > Software Update

To add/remove software graphically, use the menu option Administration > Add and Remove Software

Adding and removing Users

User Management from the Command Line

  • Add a user:
    • useradd name # The -m option required on some systems is not needed - the user's home directory will be created automatically.
    • useradd -c "Full Name" username
  • Set a password:
    • passwd username
  • Delete a user:
    • userdel username
    • userdel -r username # Caution! This deletes the user's files as well.

User Management from the Graphical User Interface

To manage users graphically, use the menu option Administration > Users and Groups

Adding Swap Space

The Raspberry Pi Fedora Remix 14 doesn't provision swap space by default.

If you wish to add swap space, you can easily do so:

  • Create an empty file using the dd (device-to-device copy) command: dd if=/dev/zero of=/swap0 bs=1M count=512 # This is for a 512 MB swap space.
  • Format the file for use as swap: mkswap /swap0
  • Add the swap file to the system configuration: echo "/swap0 swap swap" >>/etc/fstab
  • Activate the swap space: swapon -a

Moving to a Larger SD Card

You can copy the contents of the SD card to a larger card using the dd command, either on the Raspberry Pi (using an external USB SD card reader/writer) or on another computer. To do this on the Pi itself (assuming that the USB card reader is the only USB-attached storage device and therefore identified as /dev/sda):

  1. Copy the data: dd if=/dev/mmcblk0 of=/dev/sda
  2. Force the data to be written to the SD card (flush the buffers): sync
  3. Remove and reinsert the SD card.
  4. Since the SD card was copied while the system was in use, the filesystems will be marked as "dirty". Check and clean the filesystems: fsck -f /dev/sda1; fsck -f /dev/sda2

To make the card resize the second partition the first time the new card is booted:

  1. Mount the second partition: mkdir /mnt/sd-p2; mount /dev/sda2 /mnt/sd-p2
  2. Create the empty file /.autoresize: touch /mnt/sd-p2/.autoresize
  3. Unmount the partition: umount /mnt/sd-p2

Raspberry Pi-Specific Configuration

The first (FAT) partition on the SD card is mounted as /boot. There are a couple of things specific to the Raspberry Pi that can be done in this partition.

Changing the Memory Mix

The Raspberry Pi (model A or B) ships with 256M of memory. This memory is split between the ARM and GPU halves of the System-on-a-Chip (SOC). You can change the memory allocation by selecting a different start.elf program:

  • For a 128M ARM / 128M GPU split (heavy graphics): cp /boot/arm128_start.elf /boot/start.elf
  • For a 192M ARM / 64M GPU split (general computing): cp /boot/arm192_start.elf /boot/start.elf
  • For a 224M ARM / 32M GPU split (simple display): cp /boot/arm224_start.elf /boot/start.elf

Then reboot the system.

Altering the Kernel Command Line

The file /boot/cmdline.txt contains the kernel command line. The default contents are:

dwc_otg.lpm_enable=0 console=ttyAMAO,115200 kgdboc=ttyAMAO,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait

Reducing Kernel Messages

The number of kernel messages produced can be reduced by adding "quiet" to the command line.

Using a USB Drive for Storage

Although the boot files must be on the SD card, the Linux filesystem may be on an external drive. To use such an external drive:

  1. Obtain a USB disk drive and attach it to your Raspberry Pi.
  2. Create a partition at least as large as the second partition on the SD card using the fdisk command. In this example, it's assumed that this partition is the first one on the USB disk (/dev/sda1).
  3. Copy the contents of the second SD card partition to the disk drive: dd if=/dev/mmcblk0p2 of=/dev/sda1
  4. Since the copy was made of the SD card while it was in use, the filesystem copy on the hard disk will be marked as "dirty". Use the filesystem check command to check and clean it: fsck -y -f /dev/sda1
  5. Edit /boot/cmdline.txt to change the root device: root=/dev/sda1
  6. You should now be able to boot to your USB disk drive.
Idea.png
SD Card is Only Used for Booting
If you're using a root filesystem on a USB drive, once the system has booted, you can remove the SD card! You can then use the SD reader to load photos from a camera card, make another SD card for your Raspberry Pi, or backup your SD card to another one.