Wednesday, August 14, 2013

Creating an ISO Image from CD/DVD in Ubuntu using terminal

First of all, know where your CD Drive is mounted. You can run the following command to do the same:

shehbaz@Augustus:~$ mount | grep sr
 
/dev/sr0 on /media/UDF Volume type udf (ro,nosuid,nodev,uid=1000,gid=1000,iocharset=utf8,
umask=0077,dmode=0500,uhelper=udisks)

The CD / DVD is mounted in /dev filesystem in linux. running the mount command itself could help you to figure out the location where CD / DVD is mounted.

Next, you could do the following

cat /dev/sr0 > dumb.iso

which, as the name suggests, is a dumb way of creating the iso file.

why you ask? because, there is no error checking while reading from the Disk (/dev/iso) and writing to our iso image file. Here, I introduce before you the command

readom

Which stands for read - optical - media : your disk.

This command is available in the package wodim and can be installed using

sudo apt-get install wodim

readom not only creates a new, error-free iso image, but also retries reading from the cd drive in case the drive is busy / error occoured in copying a specific block/sector.

readom dev=/dev/sr0  f=smart.iso

Note : If you get the following error:

shehbaz@Augustus:~$ readom dev=/dev/sr0 f=smart.iso
Error trying to open /dev/sr0 exclusively (Device or resource busy)... retrying in 1 second.
just eject the CD Drive, and reinsert it, and close any auto msg boxes that pop up.

readom will ensure that the final CD/DVD iso image that is created is authentic, which would help you save lot of time playing around with erroneous iso image files.

Wednesday, August 7, 2013

How to Kill the Init Process (And recover from It)

What happens when we kill the init process?

Question 1 : Why the hell would you kill an init process?
Answer 1: To know what happens if someone,anyone tries to kill the init process
Answer 2: Inquisitiveness (My case!)

To see for yourself, please try the following:

1. Open a terminal
2. Type kill -9 [pid of init process]

The pid (or process id) of the init process can easily be obtained using the

top

command, or the following command

ps -afx | grep init

I think it is 1 for all the processes, but try the above two commands just to be sure.

Now, after killing the init process, reboot your system.

Rebooting will cause a kernel panic!

Cause :

Kernel panics because it tries to initialize the init process after initializing the kernel processes. However, it is unable to do so (because during previous shutdown, init process did not comprehensively free all user applications, which would lead to clearing all kernel data structures)

Note that some of these data structures would be maintained in the swap space (in the disk), also, the super block (in your bootable device i.e. disk) may get corrupted due to improper shutdown in the previous boot.  

Solution to rectify this problem :



In my case, using a live USB, I performed a memory check and a disk check. Ubuntu Live USB showed me two files in the superblock in the bootable device [HDD /dev/sda8] had been corrupted. In order to rectify these files, I did the following

sudo fsck /dev/sda8

A simple filesystem check was sufficient to recover my bootable device, without any data loss.

To check my file systems normal operation, I mounted the filesystem (/dev/sda8) using the Live USB itself. And it worked like a charm.

Rebooted the system, removed the USB, and my HDD was able to successfully boot my laptop. :)