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