Gentoo Wiki ArchivesGentoo Wiki

TIP_Booting_into_single_user_mode

This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other

Contents

Introduction

When things go awry on your system, you'll sometimes need to boot into a minimal environment (something akin to the Windows Safe Mode). If you don't want to keep a liveCD on you at all times, then you'll want to use single user mode.

On gentoo, single user mode skips all the startup scripts from the 'default' runlevel, presenting you with a text login prompt and no networking.

'single' doesn't work

People familiar with other distributions may be a bit confused when they try to access single user mode.

Traditionally, you append 'single' or 'S' to the end of the kernel line in GRUB or LILO. However, Gentoo now uses a different method of selecting runlevel, so if you just append 'single' you'll find yourself booting up to the default runlevel anyway.

While 'single' doesn't work like on other systems, you can specify the runlevel on just about any linux system, so appending '1' will work on Gentoo. Instead of '1' (specifying runlevel 1), you can also use 'softlevel=single'. Softlevel is a Gentoo specific option.

There is a slight difference between '1' and 'softlevel=single'. While '1' halts at runlevel 1, 'softlevel=single' actually enters runlevel 3 and then adjusts the running services.

If you're using genkernel with initramfs

If you've used genkernel to build a kernel that boots using initramfs, the kernel option you need to add is 'init_opts=1'. (Whatever is specified in the 'init_opts' kernel option will be passed to 'init' when the initramfs startup scripts finally get around to running 'init'.)

Manually entering single user mode

Note: When appending these options to the kernel, there needs to be a space separating them from the existing line. So don't forget, its actually ' 1' not just '1'.

GRUB

When your GRUB menu comes up, select the kernel you want to boot and hit 'e' to edit the line. Select the kernel line and hit 'e' again. Now add '1' or 'softlevel=single' to the end of the line, and press enter and then 'b' to boot.

LILO

When the LILO menu comes up, press Ctrl-X to access the command line (this may not be necessary depending on the style of your boot menu), then type the name of the kernel followed by '1' or 'softlevel=single' (e.g. 'linux softlevel=single' or 'gentoo 1').

Creating a single user mode bootloader option

You may find it easier to create a bootloader option for single user mode.

These are examples, you need to edit them for your own disk/kernel.

GRUB

title  gentoo-single
root (hd0,0)
kernel /vmlinuz root=/dev/sda2 1

or

title  gentoo-single
root (hd0,0)
kernel /vmlinuz root=/dev/sda2 softlevel=single

LILO

image=/boot/vmlinuz
  label=gentoo-single
  read-only
  root=/dev/hda3
  append="1"

Need root password

Single user mode on Gentoo does prompt for username and password, so this is not the answer for a lost root password. If you do need to reset your root password try appending 'init=/bin/bash' instead and then 'mount -o remount,rw /' to give you a writable file system. Don't forget to 'sync' any changes to disk before rebooting.

Need networking

Starting networking:

/etc/init.d/net.eth0 start

Where eth0 is the interface required.

Retrieved from "http://www.gentoo-wiki.info/TIP_Booting_into_single_user_mode"

Last modified: Sun, 28 Sep 2008 17:22:00 +1000 Hits: 44,560

Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.