Tuesday, May 20, 2014

Ram disk creation on Linux

Ramdisks are very useful in the case of web servers for some heavily accessing contents.

The steps for crating Ramdisk is as follows,
Step 1: 

Edit the file /boot/grub/grub.cfg and add the entry "ramdisk_size={size in  KB}". For example if you need to crate 4GB of RAM disk, the entry should look like,


 ### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.32-21-server' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod ext2
    set root='(hd0,1)'
    search --no-floppy --fs-uuid --set ab3827ac-8003-4bed-81c0-9248d64362b0
    linux    /vmlinuz-2.6.32-21-server root=UUID=bbfccfa9-f878-4c42-83c1-0d82c3b2f44b ro quiet  ramdisk_size=4194304
    initrd    /initrd.img-2.6.32-21-server


Make sure the above entry made is in end of the linux kernel entry and it should be in a single line.

Once you done this, do a reboot and make the kernel read the parameter while next boot.

Step 2:

You can create the ramdisk using the following command,
      mkfs -q /dev/ram1 {size of ramdisk to me created in KB}
Create a folder to act as the mount point for above created ramdisk.
      mkdir -p /ramcache 
Mount the ramdisk to /ramcache
      mount /dev/ram1 /ramcache 
Following command will display the mounted partitions including the ramdisk.
      df -H 

Grub 2 Boot Order in Debian and Ubuntu servers

Grub2 is entirely different than the older version in terms of configuration and file system hierarchy. In the version 1 of Grub, changing the boot order can be accomplished by a single file editing. But in Grub2 which need to be done in another way, we are going to describe that here.

Here are the steps to follow:

1- To edit the grub file open terminal and type the following command :
 
    sudo gedit /etc/default/grub

You will got something like this :

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”
GRUB_CMDLINE_LINUX=””
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo’
#GRUB_GFXMODE=640×480
# Uncomment if you don’t want GRUB to pass “root=UUID=xxx” parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entrys
#GRUB_DISABLE_LINUX_RECOVERY=”true”
 
Now to change the boot order, you need to change the GRUB_DEFAULT Entry, for example you have  windows7 in the 3rd position and you want to set it as default,  edit the entry as below

       GRUB_DEFAULT=3

2- Now update Grub using the command:
 
       sudo update-grub 

Once you run the above command, the grub configuration files will get regenerated and in the file /boot/grub/grub.cfg, you can find an entry as set default = "3"