
A work colleague was reading a blog and in one of the comments was a statement saying that if you append init=/bin/bash to the grub boot line e.g. linux /vmlinuz-3.2.0-2-amd64 root=UUID=26585ddb-7dde-4a7e-b2c7-e32330bb4cc8 ro splash quiet init=/bin/bash you end up ia a shell with root privileges. So we had go at it and it works. We even tried booting with a USB tick in place to see if you could copy stuff to it and you can. The question that arose was what about network access? Do you have it? i.e. is there a tcp/ip stack running and if not how would you load one etc? -- Colin Fee tfeccles@gmail.com

A work colleague was reading a blog and in one of the comments was a statement saying that if you append
init=/bin/bash
to the grub boot line e.g.
linux /vmlinuz-3.2.0-2-amd64 root=UUID=26585ddb-7dde-4a7e-b2c7-e32330bb4cc8 ro splash quiet init=/bin/bash
you end up ia a shell with root privileges.
*shh* Don't tell everyone :) Actually, this is a "not uncommon" way to reset root's password in case it has been forgotten... All the best, Lev

Colin Fee <tfeccles@gmail.com> wrote:
The question that arose was what about network access? Do you have it? i.e. is there a tcp/ip stack running and if not how would you load one etc?
What happens if you run ifconfig eth0 or a similar command? I can't think of a good reason why you couldn't run ip, ifconfig, etc in that situation. You might have to load the required kernel module if udev isn't working.

On Fri, May 18, 2012 at 06:32:34PM +1000, Jason White wrote:
Colin Fee <tfeccles@gmail.com> wrote:
The question that arose was what about network access? Do you have it? i.e. is there a tcp/ip stack running and if not how would you load one etc?
What happens if you run ifconfig eth0 or a similar command?
I can't think of a good reason why you couldn't run ip, ifconfig, etc in that situation.
you can. i've done exactly that countless times so that i can do stuff like: - run wget or whatever to fetch files from the net - run an apt-get install or upgrade - scp or rsync files in or out of the machine - ssh in from a remote host
You might have to load the required kernel module if udev isn't working.
true. also, the environment and console isn't set up quite right (e.g. ^C wont kill an app) so you'll need to set it up with stty. and the rootfs will be mounted read-only so you'll need to remount it RW in order to make any changes, and you also get only one VT, so if you need more you'll need to run them with openvt (aka "open", depending on version or distro) or just run screen. booting with 'init=/bin/bash' is useful in an emergency and still occasionally neccessary, but these days i find it less hassle and more useful to just pxeboot a rescue system (i tend to use clonezilla, it makes an excellent command-line rescue system once you exit the cz backup/restore menu) and mount the host's filesystem(s) under /mnt. and 'chroot /mnt' if necessary. I have a gparted ISO available in my pxeboot menu too, in case i need to do major partition shuffling/resizing etc, but I prefer to use clonezilla for everything else. i also have cz configured on my pxeboot server so that it starts up sshd and sets up a few useful things like the following alias in case i need to do something like grub-install while in the chroot: alias prepare-chroot-mnt='for i in proc dev sys ; do mount -o bind /$i /mnt/$i ; done' BTW, it's possible to use memdisk from syslinux to boot clonezilla or any other hd, floppy, or ISO image from the grub menu, so you can do this without setting up a pxeboot server. i've used memdisk to boot up freedos floppy images for BIOS updates etc. and recent ipxe packages in debian can optionally add an ipxe entry to the grub menu so you can still netboot in case you're not fast enough to press F8 or F12 or whatever to get the BIOS boot selection menu. useful. e.g. my grub boot menu on my main machine at home currently looks like this: # grub-list-kernels.pl 0 Debian GNU/Linux, with Linux 3.2.0-2-amd64 1 Debian GNU/Linux, with Linux 3.2.0-2-amd64 (recovery mode) 2 Debian GNU/Linux, with Linux 3.2.0-1-amd64 3 Debian GNU/Linux, with Linux 3.2.0-1-amd64 (recovery mode) 4 Network boot (iPXE) 5 Bootable floppy: LSI 6 Bootable floppy: freedos-bare Default: 0 Debian GNU/Linux, with Linux 3.2.0-2-amd64 craig ps: for the OP - if you every wondered why grub has the option for setting a password, then disabling the ability to edit the boot command line is one of the main reasons...useful in, e.g., a computer lab at a university, but anyone who has physical access to the machine can defeat simple security measures like this. -- craig sanders <cas@taz.net.au> BOFH excuse #30: positron router malfunction

On 19/05/2012, at 9:20 AM, Craig Sanders <cas@taz.net.au> wrote:
e.g. my grub boot menu on my main machine at home currently looks like this:
# grub-list-kernels.pl 0 Debian GNU/Linux, with Linux 3.2.0-2-amd64 1 Debian GNU/Linux, with Linux 3.2.0-2-amd64 (recovery mode) 2 Debian GNU/Linux, with Linux 3.2.0-1-amd64 3 Debian GNU/Linux, with Linux 3.2.0-1-amd64 (recovery mode) 4 Network boot (iPXE) 5 Bootable floppy: LSI 6 Bootable floppy: freedos-bare
Default: 0 Debian GNU/Linux, with Linux 3.2.0-2-amd64
craig
ps: for the OP - if you every wondered why grub has the option for setting a password, then disabling the ability to edit the boot command line is one of the main reasons...useful in, e.g., a computer lab at a university, but anyone who has physical access to the machine can defeat simple security measures like this.
Agreed. That's essentially the discussion we were having when where mucking around with grub; that to make that kind of edit you needed physical access and so any measures like grub passwords were superfluous. In your grub menu example above do the bootable floppy options point to a floppy image e.g. an iso, or to a real device? Colin.

On Sat, May 19, 2012 at 03:09:37PM +1000, Colin Fee wrote:
Agreed. That's essentially the discussion we were having when where mucking around with grub; that to make that kind of edit you needed physical access and so any measures like grub passwords were superfluous.
not exactly superfluous, just fairly easy to defeat if you have unsupervised physical access to the machine. same as a BIOS password can be cleared by opening the case and removing the CMOS battery for a few minutes (or some motherboards have a CMOS erase button)
In your grub menu example above do the bootable floppy options point to a floppy image e.g. an iso, or to a real device?
both are 1.44MB freedos floppy images. i can't remember the last time i had an actual floppy drive installed in a computer (i still have a few lying around but i stopped bothering to install them years ago) craig -- craig sanders <cas@taz.net.au>

Craig Sanders wrote:
also, the environment and console isn't set up quite right (e.g. ^C wont kill an app) so you'll need to set it up with stty.
If you have a one-liner to enable job control in pid 1, please share it. atm I use open (as you mentioned) as a workaround.
and recent ipxe packages in debian can optionally add an ipxe entry to the grub menu so you can still netboot in case you're not fast enough to press F8 or F12 or whatever to get the BIOS boot selection menu. useful.
Got an opinion on ipxe vs. gpxe?
ps: for the OP - if you every wondered why grub has the option for setting a password, then disabling the ability to edit the boot command line is one of the main reasons...useful in, e.g., a computer lab at a university, but anyone who has physical access to the machine can defeat simple security measures like this.
...hence the tamper-detection reed switches in e.g. Dells. (Not that it helps much IMO)

On Mon, May 21, 2012 at 12:33:41PM +1000, Trent W. Buck wrote:
Craig Sanders wrote:
also, the environment and console isn't set up quite right (e.g. ^C wont kill an app) so you'll need to set it up with stty.
If you have a one-liner to enable job control in pid 1, please share it.
not really. IIRC i set stty intr, and a few other things, but even then i never got the console set up perfectly - just good enough to do basic repairs. which is one of the reasons why it's far less hassle to just boot a rescue system.
Got an opinion on ipxe vs. gpxe?
still undecided. i think ipxe will be the clearly superior choice in a year or so, but at the moment there are pros and cons to both. overall, though, i prefer ipxe. i switched to it over a year ago. i can't even remember what reason i had for thinking gpxe could still be a better choice in some situations...but my brain's not working properly due to a cold or flu or something (despite the duuuuhhhh symptom this is probably not the start of the zombie apocalypse). IIRC, ipxe forked from gpxe because one of the main gpxe devs was not accepting patches, not making new releases, and generally exercising way too much control over the project. so the other devs forked it and it has been actively developed ever since. craig -- craig sanders <cas@taz.net.au> BOFH excuse #2: solar flares

Craig Sanders wrote:
Got an opinion on ipxe vs. gpxe?
still undecided. i think ipxe will be the clearly superior choice in a year or so, but at the moment there are pros and cons to both.
Sounds like what I remember when I looked.
overall, though, i prefer ipxe. i switched to it over a year ago.
I haven't cared enough; I use the intel pxe rom when it's available.
i can't even remember what reason i had for thinking gpxe could still be a better choice in some situations...but my brain's not working properly due to a cold or flu or something (despite the duuuuhhhh symptom this is probably not the start of the zombie apocalypse).
IIRC better hw support in gpxe for now -- unless I'm mixing up gpxe/ipxe with uboot/<whatever the uboot fork is called>...

It has always been this way since before grub was written. You can run modprobe and ifconfig commands to get networking going or you can use openvt to start bash on a different VC before running "exec /sbin/init" to have the matching boot in a normal way. -- Sent from my Samsung Galaxy S Android phone with K-9 Mail.

On Fri, May 18, 2012 at 04:28:59PM +1000, Colin Fee wrote:
The question that arose was what about network access? Do you have it? i.e. is there a tcp/ip stack running and if not how would you load one etc?
Because you started a shell in place of init, absolutely nothing is configured. To get, for instance, network connectivity, you need to run at least the relevant scripts in /etc/rc.d or wherever. Cheers ... Duncan.
participants (7)
-
Colin Fee
-
Craig Sanders
-
Duncan Roe
-
Jason White
-
lev@levlafayette.com
-
Russell Coker
-
Trent W. Buck