How to change grub.conf after adding init=/bin/bash - linux

I added init=/bin/bash in grub.conf file, so my linux system is always entering bash when booted.
Is there a way to change the grub.conf file so that I can boot Linux again.

TLDR; e, remove init=. ctrl+x
One of the options is to temporary change grub entry to fix booting problem, edit grub.conf and update-grub.
Keep shift pressed during boot (if you don't see grub menu)
Press e to edit menu item
Edit to remove init=... phrase
Press ctrl+x to boot
Now you can edit grub.conf
Run update-grub
reboot

After making changes to grub file run :
sudo update-grub
This will update your grub

TLDR; mount -o remount,rw /dev/sda
It's possible that after booting with init=/bin/bash your filesystem is in readonly state. That means you cannot modify any config files.
Try to remount it as read-write (my disk is at /dev/sda). If you don't know the name, use lsblk
mount -o remount,rw /dev/sda
update-grub will not work if /boot is not mounted
mount /boot
Now you can edit grub.conf and run update-grub

Related

How do I edit fstab in emergency mode?

I moved my EFI partition which caused me to enter emergency mode on reboot.
mount -a confirmed fstab had the the UUID of the old partition...it wasn't mounting and that caused emergency mode.
You can't do ANY of the standard remount,rw tricks that normally work... it will always give you an error message the mount doesn't work
Sure, I could start from the USB stick and edit /etc/fstab, but isn't there an easier way?
This question has been around for 10 years and most people answer with a remount as rw, but that always fails.
The clever way is simply mount the / partition on /mnt like:
mount /dev/sda1 /mnt
This mounts it read-write and you just edit /mnt/etc/fstab to change the new UUID for your partition which you can get from either blkid or ls -lha /dev/disk/by-uuid
However, the readonly filesystem will NOT see your changes, so you think you've failed. You'll look at /etc/fstab and it will appear unchanged (at least under btrfs it looks unchanged).
However, when you reboot, you are back in business.
I re-sized my EFI partition down to 260MB, but had to remove it to do that which causes the UUID to change. Just changing the /etc/fstab with the new UUID is all that you need to do so you don't run into trouble. Best to do that when you move the partition, rather than after the fact.
I have RHEL 7.9 installed and here is what I did to edit the fstab after copying from one machine to another using scp.
mount -o remount,rw /dev/sda2 #sda2 is where my root directory is located.
I was then able to open in vim and save the UUID changes I had to make. Worked like a charm.

/proc/cmdline does not updated with update-grub

I am testing kdump functionality based on a ubuntu distribution(ubuntu-14.04.1-desktop-amd64), and found that with the following step, the /proc/cmdline does not get updated:
1: modify /etc/default/grub[1]
2: sudo update-grub
3: reboot
After a reboot, cat /proc/cmdline[3] does not have what I have changed in /etc/default/grub, while the boot cmdline in /boot/grub/grub.cfg[2] do show what I have changed.
Any expert have some idea? Thanks a lot
[1]manually modified in /etc/defaut/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash foo=bar crashkernel=256M"
[2]automatically updated grub.cfg
/boot/vmlinuz-3.13.0-32-generic root=UUID=9e93b3d1-2859-473c-9c1f-204c2bb4e4f5 ro quiet splash foo=bar crashkernel=256M $vt_handoff
[3]cat /proc/cmdline
eric#eric-test-kdump:~$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-3.13.0-32-generic root=UUID=9e93b3d1-2859-473c-9c1f-204c2bb4e4f5 ro quiet splash vt.handoff=7
I had the same problem, are you also on a proxmox KVM? Modified the crashkernel config, ran grub-update and rebooted, still the /proc/cmdline stay's the same.
I called a reset from the proxmox interface and it was updated after that.
Running Proxmox V6.1, I solve this issue by changing the content of:
/etc/kernel/cmdline
and then pushing the change with:
pve-efiboot-tool refresh
Did you reboot? Changes to the GRUB configuration do nothing until a reboot activates them.
The reason why the grub config is not updated is because the sudo update-grub command is outputting the changed file to stdout. You need to update the file in /boot with the -o flag.
sudo update-grub -o /boot/grub/grub.cfg

what causes permission of auto-mount in linaro linux

Sdcard is mounted automatically as root permission.
like this.
/dev/mmcblk1p1 on /media/linaro/11bf7464-471c-42ca-bbc8-d229a43e8fe51 type ext4 (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks2)
/etc/fstab is emtpy like below.
linaro#linaro-alip:/lib/udev$ cat /etc/fstab
# UNCONFIGURED FSTAB FOR BASE SYSTEM
did udisks mount the device? If so, where can I change mount permission option?
Sometimes, it is mounted as a linaro user.
What causes this difference? any idea?
For Gnone to disable Nautilus automount use this command:
gsettings set org.gnome.desktop.media-handling automount false

How to access fstab at reboot phase

How can I access and modify /etc/fstab during reboot (maybe accessing to recovery mode) ?
Why this question :
I have updated the virtualbox guests additions in backtrack 5 (as a Virtualbox VM).
I have modified temporary the fstab file to do that but forgotten to turn it back to initial state, like :
mount /dev/cdrom /cdrom
echo "/dev/cdrom /cdrom0 udf,iso9660 defaults,exec 0 0" >> /etc/fstab
So after the guest additions installed, reboot is blocked on mounting this unexisting point.
Thx
edit: maybe to move to serverfault ?
I see two possible solutions to your problem:
Use the recovery mode (if you don't see that in the grub list, edit the default entry and add the word "single" without quotes to the end of the kernel line)
Mount a random .iso file temporarily
Then remove the offending fstab line.
Another option is to boot a Live OS and mount the root filesystem from there. Then you will be able to edit the fstab file.
Once you have the live OS booted
fdisk -l
-find your root partition (usually in the format sda1, sdc1, sda2, etc)
mkdir /mnt/rootfs
mount /dev/sda2 /mnt/rootfs <--sda2 = root partition found in fdisk
cd /mnt/rootfs/etc
-Fstab file should be in there.

Repairing fstab (read only /)

I had a typo in my fstab and it boots to a commandline but is readonly, I know what the error is but i can't change it because it's mounted as readonly. I want to mount the filesystem and make the changes. I know I can boot a live distro and edit it that way, but i was wondering if there was an easier way to do it.
It's debian lenny by the way.
Yes, if you end up in single-user mode with a readonly root, try:
mount / -o remount,rw
Maybe a -n is necessary, maybe not. That should remount the root fs read/write (assuming there's nothing wrong with it).
I know that question is outdated, but saw it, because nowadays got in the same trouble.
I broke my fstab manually (make a typo in parameter).
That was very easy to correct fstab from readonly mode. We must mount / in read-write mode.
If /etc/fstab is correct, you can simply type:
mount -n -o remount /
But if /etc/fstab is wrong (as it was in my case), you must give the device name and possibly the type, too: e.g.
mount -n -o remount -t extX /dev/hdaX /
Where extX is your filesystem type and /dev/hdaX -- is partition you use for your root mount point.
To see all your available partitions just type ls /dev/[sh]d*.
#mount -n -o remount,rw /
if /dev/sda1 is the real device, then do:
#mount -n -o remount,rw /dev/sda1 /
#troyane saved my hassle by providing
mount -n -o remount -t extX /dev/hdaX /
I was on Orangepi3 EMMC when I had a typo in UUID of root having ext4 filesystem.
The command remounted in read-write mode and I fixed my fstab
mount -n -o remount -t ext4 /dev/mmcblk2p1 /
My kernel command line looks like this:
$ cat /proc/cmdline
root=/dev/sda4 ro
$
Tell grub that it should omit passing "ro" to the kernel when booting (pressing esc, e on the entry you want edit will allow you to edit the arguments given to the kernel), and it will mount your root file system not read only anymore. Then you can change your /etc/fstab and restart.
In my case, in grub2 after pressing "e" I have changed "ro" to "rw init=/bin/bash" then the root filesystem is mounted read and write so I could change the content of /etc/fstab file.
If you have something wrong with your /etc/fstab file. Please follow the following steps.
boot your ubuntu system or restart your computer
since you can not start your system, you will encounter some errors like
“a start job is running for dev-disk-by....
(you may need pressing F2 key to come the linux command terminal to see this)
use command vi /etc/fstab and edit your fstab file
use # to commend out some problems and add something you want put in the fstab file.
finish editing. hit shift+z and save the modification
use command reboot to restart your system
it works again
Please comment here, if you have questions

Resources