28 November, 2010

How to share /home directory between two linux installations

            Frequent re-installations of operating system due to crashes  is always been a problem for many of the linux users, and my case is also the same.... Everytime i start with doing something like trying some new commands or editing some configuration files and finally ends up with an 'OS crash' and a fresh installation thereafter. Now it's been a very usual matter that i may have to install a fresh copy of linux distro probably once in a month. Sometimes the crash may occur due to installation of a new theme (last week editing some theme files manually after it's installation made my 10.04box stand on nails...), sometimes the crash may be the by-product of installation of an incompatible version of application etc...

While fighting with all these crashes and re-installations the major problem is related to backing up of the data and personal files stored in the /home folder. Usually the contents of the /home contains files and directories including apache's root directory, downloads, files received over bluetooth, joomla/html/php projects etc. So it's very important to back up data all the time Ubuntu is reinstalled.

Solution

One of the best solution to avoid this kind of frequent backup-restore problem is separate the /home directory from the root directory during the installation. The advantages of this separation comes in two ways

1. When a crash occurs to the OS the /home directory remains intact because it is a separate disk partition. So on reinstalling after the crash we can map the old /home partition of the crashed one as the /home of the new linux. This makes it possible to access the files as if before the crash occured.

2. It's easy to share the /home folder between any no of linux distributions installed parellely on your machine. During installation of each of the distro, we can select the partition to be shared as its /home. Better keep the filesystem type (eg:- ext4) same while selecting the /home of other distro as it's new /home. This can be useful even with linux distributions of different architecture using similar filesystem types(Ubuntu and fedora can share a common /home if the /home is mounted as ext4).

On the ground...


Select the manual partitioning options


Setting up the root partition 


Selecting the /home partition of the previously crashed or parellelly installed linux.


 
Mounting the /home partition of old linux as /home of new linux. Don't check the format box. If mistaken you may lose all the data due to disk format
Read rest of entry

23 June, 2010

How to recover Grub 2 in Ubuntu

The new versions of Ubuntu from 9.10 are preloaded with the new version of the Grub ie. Grub 2 as the default boot loader. Grub 2 has many modification over the previous versions. It is driven by a group of scripts in different directories in /boot and /etc. I have already blogged about configuring grub 2 to change the appearence, adding a background image etc... on to the boot loader menu in a previous post. This post is all about restoring the grub 2 in an occasion where you lost your current grub 2 boot loader overwritten by some other boot loader installation. This possibly occurs when you install multiple operating systems on a machine, and especially when some other OS after the Ubuntu. This is a simple and working tip, try it.



U should need following tools for this . . 

1. An Ubuntu Live CD (9.10 or any later versions)
2. The partition where your Ubuntu resides (that u are going to 
     restore), It should be something like /dev/sda12

 Follow the steps

Take the terminal and follow the steps 

$ sudo fdisk -l
  • Now, you need to remember which device listed is your linux distribution, for reference, /dev/sda1 will be used. Now weneed to mount the filesystem to/mnt
 $ sudo mount /dev/sda1 /mnt
  • If you have /boot on a separate partition, that need's to be mounted as well. For example /dev/sda2 is used here.
$ sudo mount /dev/sda2 /mnt/boot  

     Now mount the rest of your devices 

  $ sudo mount --bind /dev /mnt/dev
  • Now chroot into your system 
 $ sudo chroot /mnt

      You should be chroot'd into your system as root, you can now
       run commands as root, without the need for sudo.
  • Now edit the /etc/default/grub file to fit your system 
 $ nano /etc/default/grub
  • When that is done you need to run update-grub to create the configuration file. 
$ update-grub
  • Now install GRUB 2 to the MBR as follows
$ grub-install /dev/sda
  • If you encounter any errors, try 
    $ grub-install --recheck /dev/sda
  • Press Ctrl+D to exit out of the chroot.
  • Once you exit back to your regular console, undo all the mounting,
$ sudo umount /mnt/dev
$ sudo umount /mnt

(But if you have a separate boot partition which you mounted earlier, you have to unmount this first, or you will get a "device busy" error message.)
  • That's all you have to do with your Live CD. Exit the terminal and restart your machine.  
If you had alternate OS entries, update-grub might say "Cannot find list of partitions!". Ignore it and continue...
When rebooted the grub 2 boot loader will be ready for you. Don't worry if you don't see other operating systems that are already installed in your system. Once you can boot into your linux installation,  rerun update-grub and grub-install /dev/sda as root. This will add the entries of the other operating systems in to the current boot loader.



 


Read rest of entry

12 May, 2010

How to Mount Your Partitions Permanently in Ubuntu

                                    Linux machines are very much aware in the case of security, but this extra security may sometimes become a headache for simple linux users. For example, if u have separate partitions or hard drives (for your backup, music collection or photo collection), every time you boot up, you have to mount those when required, providing a password which is sometimes very much irritating. The time-saving solution is to mount such media permanently. There are two steps in this process. Firstly to tell Ubuntu where to find the mount and where you want it mounted. Secondly, to create the folder within Ubuntu's recognised file structure to house the mounted media. After you perform this configuration, your backup folder on a secondary disk can be accessed from within your /home/username folder.

Tell Ubuntu Mount & Local Associated Folder Locations 
Open the fstab file that controls your mounts:-
 
sudo gedit /etc/fstab

Find out the name of partition that you are planning to mount  by issueing the following command. It lists recognized partition tables

sudo fdisk -l 

At the bottom of the file, for each partition or drive you wish to mount forever, paste:-
 
/dev/sdb1 /mnt/mydrives 
ext3  users,noatime,auto,rw, nodev,exec,nosuid 0 0

Read man page of mount for more details
 
• /dev/sdb1 - media to mount
• /mnt/mydrives - location to mount to with a friendly name
• ext3 - filesystem
• users - allow all users, alternatively use user
• noatime - don't waste resources recording last access time or, if you  
                                                                          want this info, change to atime
• auto - mount on boot
• rw - read write access
• nodev - prevents unauthorized device mounts
• exec - execute programmes from disk
• nosuid - do not allow set-user-identifier
• 0 - dunno, probably should though
• 0 - ditto
 
Save the file when you’re done. Check out the figure if you have doubts

 

 
Create the Local Folder to House Mounted Media

Now create the folder location for the mount. So, in this example:-

sudo mkdir /mnt/mydrives

Reboot your system to see the Ubuntu automatically mounting the device @ boot time... In Nautilus look for /mnt/mydrives. You can create a launcher for easier access if needed.
 
Symbolic Link to Permanent Mounted Partition

Here's an optional third step for simplifying the navigation. Rather than having to navigate each time to your /mnt folder to find your media, you can shortcut to there from, say, your /home/username folder. An easy way to do this is to open nautilus twice, once navigating to your /mnt folder and, with the other, to your /home folder.
Now, holding down the Ctrl and Shift keys, simply drag the newly mounted media file accross to your /home/username folder which you can see in your /home folder. From now on, when you navigate to your /home/username folder, click on that symlink to  jump  to the contents of the mounted partition. If you delete a file from a symlink in your /home/username folder, you really really do delete the original file.


Read rest of entry

27 April, 2010

Quick tips : Ubuntu / Linux

The simplest way to install the packages
 If you feels the package installation as a head ache in Ubuntu Linux, just try http://www.appnr.com . It has a wide categorized collection of packages with short description, what you need is only a mouse to begin installation.


Separate /home partition when you install Linux
 
Try to make separate partition for the /home when you install linux, and show this partion as the home for any linux that you install later in your system. It has the advantage that if you have more linux with same home then you can share files easily in spite of difference in operating system. Also you can avoid losing your data during an OS crash.


Read rest of entry
 

Terminal Diary | techblog Copyright © 2009 Gadget Blog is Designed by jintu jacob Powered by Blogger