Boot your (bootable) USB directly from grub

Long time, and I hit across this one scenario, and yay – we have this blog post here!

Pretty old machine with a Linux installed, and working grub, and I wanted to install another Linux variant! I got my bootable USB drive ready, but the stupid machine was not detecting it during boot-time I guess, as it never had mind to boot from it.

Similar situation can come up when you forgot the BIOS password, making it difficult for you to change the boot order. So here you go!

Let me put in steps, so that easy for someone (or even myself) to copy later!

  1. Insert your USB drive, boot normally, go to Grub command line – This might be probably a click of ‘c’ from the Grub menu! You will be in somewhere like
  2. Type in ls and find out the correct USB drive notation and partition. In my case, it was (hd1, msdos1) You can simply find the correct one by typing in ls (hdx,msdosy)/ or similar
  3. Now we have the partition, lets try booting from it! This is the tricky step, and here you go!
    set root=(hd1,msdos1)
    linux /casper/vmlinuz.efi boot=casper noprompt noeject root=/dev/sdb1
    initrd /casper/initrd.lz
  4. TADA! Here you go! If you see a prompt like

    You have done something seriously wrong 🙂 Take time to go all the way from top till down again, and if it still dont work out, kindly comment!

Get your Windows 8.xx OEM key from linux terminal

Laptop came with original windows, you did something tricky to install linux – and resulted in removing your entire windows.

Boot into your Linux OS. If you dont have one, try making a linux bootable USB stick. In terminal,

sudo hd /sys/firmware/acpi/tables/MSDM

This would give your key on the right side of the hex-dump! Enjoy 🙂
Courtesy :

[SOLVED] Fedora boots into tty after replacing GDM with KDM

This one gave me enough worries – but somehow got the right link to sort this one out. First things first:
GDM = Gnome Desktop Manager
KDM = KDE Desktop Manager
tty = Teletype Terminals ( You get it usually with Ctrl+Alt+F1 )
You removed gdm – and installed kdm – but Fedora boots only to a tty shell. You login there and give kdm – the KDE boots up.
You want to skip the tty steps 🙂

$ sudo systemctl disable gdm
$ sudo systemctl enable kdm

on the next boot, fedora boots up directly to KDE! Yay!
That would do 🙂

File copy program using pipe between parent and child process in C

Starting the Operating Systems ‘category’ with this program.
Problem statement:-
Design a file copying program named FileCopy using ordinary pipes. This program will be passed two parameters : the first is the name of the file to be copied and the second is the name of the copied file. The program will then create an ordinary pipe and write the contents of the file to be copied to the pipe. The child process will read this file from the pipe and write it to the destination file.
For example, if we invoke the program as follows
FileCopy input.txt copy.txt


int main( int argc, char* argv[] ) {
	int fdone[2];
	pid_t childid;

	char readBuff[50];
	char writeBuff[50];
	int readCounter;

	pipe( fdone );

	if( argc < 3 ) {
	    printf( "Atleast need 2 params " );

	int fileOpen = open( argv[1], 0 );
	int targetFile = open( argv[2], 0666 );
	if ( fileOpen == -1 || targetFile == -1 ) {
	    printf( "Opening file failed " );
	childid = fork();

	if( childid == 0 ) {
	    // inside the child prcocess
	    close( fdone[1] );

	    read( fdone[0], readBuff, sizeof( readBuff ) );
	    printf( "The recived string is : %s", readBuff );

	    //Writing to the target fileOpen
	    write( targetFile, readBuff, strlen( readBuff ) + 1 );
	} else {
	    // inside the parent process
	    close( fdone[0] );
	    // code to read from a text file

	    while( (readCounter = read( fileOpen, readBuff, sizeof( readBuff ) ) > 0 ) )  {
		write( fdone[1], readBuff, sizeof( readBuff ) );
	    close( fdone[1] );

Yay! Hope it gets someone in need.