7

I'm new in Linux and just have basic knowledge about it. In the past I've tested to boot into single-user mode in some Linux distribution by just append " single" to the boot command. However, I don't know where should I add it in Ubuntu 14, the boot command is actually a shell script. Can anyone help me please? Below are some snapshots I captured.

enter image description here enter image description here enter image description here

0

2 Answers 2

7

I got the answer. At this line:

linux /vmlinuz-3.13.0-32-generic root=/dev/mapper/ubuntu-vg-root ro

append single and it becomes to

linux /vmlinuz-3.13.0-32-generic root=/dev/mapper/ubuntu-vg-root ro single

Then press Ctrl + x. You will goes into single user mode.


To make this permanent, you need to edit /etc/default/grub and change this line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

to

GRUB_CMDLINE_LINUX_DEFAULT="text"

The details may vary depending on your system. The important bit is setting GRUB_CMDLINE_LINUX_DEFAULT to text. Once you have done this, run sudo update-grub and next time you restart you will boot into text mode.

3
  • Exactly, thanks for posting the answer. Are you interested in making this permanent or did you only want it once?
    – terdon
    Commented Apr 16, 2015 at 17:23
  • I only want to do it once. And I found that the way I added ` single` only works one time. The next time I reboot, the ` single` part just disappeared. Do you know how to make it permanent? Commented Apr 16, 2015 at 17:25
  • 1
    Yup. I just added it to your answer. By the way, please remember to accept this answer once the waiting period is over.
    – terdon
    Commented Apr 16, 2015 at 17:49
1

The above answer describes how to make a Linux/GRUB2 host/box boot to single-user mode as the permanent default option. One can also make this a permanent but {non-default, menu-selectable} option. One procedure for this (that is not stupid, like editing /boot/grub/grub.cfg) is to add a menuentry to /etc/grub.d/40_custom (but see note @ end on menu order):

1. (safety 1st!) Backup your current /etc/grub.d/40_custom . (IIUC, this is part of a default/generic GRUB2 setup.) A real filesystem backup is optimal here, but one can also just use the old backup-to-.0 idiom:

    FP_TO_BACKUP='/etc/grub.d/40_custom'
    BACKUP_FP="${FP_TO_BACKUP}.0"
    sudo ls -al "${FP_TO_BACKUP}*"  # checking that you don't already have one
    cp "${FP_TO_BACKUP}" "${BACKUP_FP}"
    sudo chmod a-wx "${BACKUP_FP}"  # non-executable files not used by GRUB2

2. In your editor of choice, open your current /boot/grub/grub.cfg and /etc/grub.d/40_custom. In Emacs with TRAMP, you can do this from a normal session with the following strings (after C-x C-f or M-x find-file)

    /sudo::/boot/grub/grub.cfg
    /sudo::/etc/grub.d/40_custom

3. Find your current default menuentry in grub.cfg by searching from top-of-file with regexp=^menuentry

4. Copy the entire stanza for that menuentry (including the terminal '}' !) to your 40_custom

5. In your /etc/grub.d/40_custom,

5.1. Give the menuentry a useful title. E.g., append (console) to whatever you already have.

5.2. At least for now, delete most of the code from the original menuentry, keeping only the lines beginning with set root, linux, initrd, and the 2 intervening echo lines. (You might also add an explanatory comment.)

5.3. The important part: in your line beginning linux , replace the code at the end (typically after ro) with single . E.g.

- linux /vmlinuz-3.16.0-4-amd64 root=/dev/mapper/LVM2_crypt-root ro   nomodeset nouveau.modeset=0
+ linux /vmlinuz-3.16.0-4-amd64 root=/dev/mapper/LVM2_crypt-root ro single

This will make your new menuentry something much simpler than its predecessor, like

menuentry 'LMDE 2 Cinnamon 64-bit (console)' {
    set root='hd0,msdos3'
    echo    'Loading Linux 3.16.0-4-amd64 ...'
    linux   /vmlinuz-3.16.0-4-amd64 root=/dev/mapper/LVM2_crypt-root ro single
    echo    'Loading initial ramdisk ...'
    initrd  /initrd.img-3.16.0-4-amd64
}

5.3. Save your 40_custom and exit your editor.

6. Don't forget to sudo update-grub

7. Reboot: you should now see a persistent item/menuentry at the end of your initial GRUB2 bootscreen.

Note on menu order: the new item shows at the end of the generated (by update-grub) GRUB2 boot menu, because this procedure edits (the pre-existing) /etc/grub.d/40_custom. One can change the position of the item in the menu by changing the numeric prefix of the file. A generic GRUB2 /etc/grub.d/ will contain filenames like

  • 00_header which you probably don't want to edit
  • ... followed by themes and other menu decorations
  • 10_linux
  • ... followed by Linux-related menuentries
  • 30_os-prober
  • ... followed by non-Linux OSs to boot (e.g., Windows)
  • 40_custom
  • ... followed by custom menuentries which don't fall into either previous functionality bins

But one can subvert the above schema at will. E.g.,

  • to have your custom menuentry show above all the others, give it a numeric prefix < 10. E.g., create a new file 09_custom
  • to have your custom menuentry show after your Linux menuentries but before those for your Windows ones, give it a 10 < numeric prefix < 30. E.g., create a new file 29_custom

Note that

  • the exact numeric-prefix values you must use to achieve a given position will depend on the values already in use on your host/box, so remember to ls -al /etc/grub.d/
  • if you create a new file, you must make it executable before you update-grub

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .