Tuesday, March 6, 2012

OpenSUSE on USB (Reloaded)



There are many guides on how to install suse on an external media such as  usb drive including my previous posts. This guide will try to make it as easy as possible so people  that do not have any experience in installing suse on an external drive can cope up with this guide.


Please read the whole tutorial first before you proceed!!!

Things you will need:

External drive or a pendrive  ( at least 5 GB )
Installation media DVD/CD, net-install CD and so on.

Lets get started, insert the installer to its drive or boot from the installer while your usb-drive is inserted to its port and make sure that your machine is set to boot with a usb device!




Start the installation.





Should you choose to update an existing install and use auto configuration this is the best place. For most folks auto config is enough however should you choose to do it manually you can remove the check in the box.







This is where you choose which time and place you reside.




Here you can choose which D.E (Desktop Environment) you need to install. There a lot of options including the two major linux D.E. such as KDE and Gnome.






Click the "other" button and you will find more to choose from, like LXDE etc. You can also install the text mode version which is mostly for servers.






Partitions

This is where the fun starts the installer wants to mount 2 internal disk, the other has an ntfs file system. Choose create partition setup and ignore those disk that you will not use. Go directly to your disk and create your Linux partition and file system and optionally some ntfs file system and partition as well so you can use your disk to store and transfer data across platforms like for example your favorite Windows os.







Click Create Partition Setup.




Choose the Custom Partitioning for Experts. You should see the disk that are available.





Ignore the other disk and go directly to the disk that you want to install openSUSE.





Create your own partitions file systems according to your hearts contents. when your done click the edit button.

Click the Edit button

Choose mount by Device ID

Click the Fstab Option button and make sure that all the disk is mounted by it's ID and as a good practice give it a volume label name. Here since it is the  / partition then we give it the  name  root . You can use the Volume Label  as the mount entry  but if you have the same label on the internal disk this will cause some trouble when you least expected it. since the ID of the disk is unique you are safe from boot error's.




The above setup has an ntfs partition as /dev/sda and most probably has your favorite Windows os installed on it. How ever if you have a Linux os installed on your primary hard drive (sda) the installer will try to add the swap of the existing install to your setup. You can go to that disk and edit it to be able to unmount that swap.




Select Do not mount partition.


 Click finish and that should remove the existing swap to your setup.

Creating new user will be the next.




If you did what i have done then you have an option to set the roots password.





Next will be the final review of the setup you have just did before you can start the installation. If you have not added a boot partition then booting from root is the alternative.

Disable the boot from mbr and enable the boot from / root partition.


Change from this



To this


Click the Booting section.
You will see the bootloader settings section management. Make sure that only the disk you want to install opensuse is in that entry. It will look like the picture below.


Don't worry about deleting other entries in this section because they will not literally deleted but will just be remove from grub.



Now click the bootloader installation section. Make sure that the boot from root partition is checked.




Click the Boot Loader Options button. Then tick the 2 options under Boot Menu.If you want to know what it does there is a help button at the bottom left corner. It may or may not affect your set up at all, but it does not hurt to use it specially if your using a pendrive/ thumbdrive.






Then click Boot Loader Installation Details. Make sure that the only disk  in that entry is the disk you are installing, in this case /dev/sdb2.


Change from this

:
To this



Go back to section management click the Other button at the bottom right corner  and select Edit Configuration Files





                          There are three dropdown menu's in there namely

  1. grub.conf
  2. menu.lst 
  3. device.map

menu.lst 

Here you can edit or add additional  boot parameters such as  nomodeset   and so on. This is the last chance to review your boot settings before you proceed on the installation.




 grub.conf

This is the script that grub uses when it boots your system. Make sure that the entry  (hdX,X)  is the same as with menu.lst.





device.map

This is the very important part if you want to make sure that your usb install will boot without any issues. There will be other entries here as well, just make sure you have the relevant hard disk as the only entry. Again deleting other entries will not delete them physically but will just be remove from grub's memory and It should be always  (hd0) . So i can say that this is the "cream of the crop" or the climax of our tutorial.


When you have done those things you will be brought back to the final review of your setup before you can proceed with the installation. Make no mistake here because once you have click the install button there will be no turning back!





                                                         Now you can start the installation.






The first thing you need to do after the installation and manage to log-in either via cli or with X server running is to check you if have the correct bootable flag set. you need to run   fdisk -l  as root so as to confirm that you have it. In this case    /dev/sda2   is the root partition. The   *   should be in the / partition.



If its not in the right place then you can use the command  fdisk  as root to set it. Run   fdisk /dev/sdX   where  sdX  is the correct disk and follow the prompt its not that hard to set it imo. Some explanation in this  link.



Final thoughts:

As i have mentioned from the beginning there are a lot tutorial's out there that will tell you howto install opensuse on an external drive such as usb and flash.

There is susestudio.com which requires  an account and you must have a decent internet bandwith because everything will be done online from building to testing and downloading your appliance.

There is kiwi  which mostly be done via cli or command line interface. You should have a basic knowledge of how to edit xml files and some dependencies of your appliance that you are trying to build.

There is unetbootin which does not support OpenSuSE officially

Some folks might tell you to remove your internal disk so you can install directly in an external drive. You can do that in VBox so no need to remove your drive! :-) check this one out if your seriously planning to remove your internal disk.
http://jason.ferrer.com.ph/2010/02/my-suse-persistent-usb-install.html

And last but not least this tutorial which does not require anything out of the ordinary installation. All you have to do is read understand and be able to adopt your set up to this tutorial.

The only setback about the above alternatives  namely susestudio and kiwi will have you build your own appliance and then copy or install it on your usb drive. My procedure is just installing directly like usual.


Trouble shooting! :-)

Most of the folks who tried using different tools to make a persistent usb install and failed would probably ended up having their usb disk borked, since some part of the iso images were copied to the disk. Then they will come and  try out this method as the last resort out of desperation :-), it is doom to fail. So dont blame my guide if you got some errors about not being able to write to the disk during the installation! Enough said so  what is the solution?

If you are a Windows user the safest option would be using a virtualization client like VirtualBox which support usb devices. Plug in your usb disk then boot from any live media ie cd, dvd and such inside VirtualBox without any (virtual) internal hard disk attached, When you log in open up a console or a command prompt like in Windows and type as a root user.
         
      dd if=/dev/zero of=/dev/sda bs=4M & pid=$! 

      while (( pid )); do kill -SIGUSR1 "${pid}" || break; sleep 10; done  

This will give you an idea about how much time will it finish.Now this may take much time since you are using a virtual client but it is 100% safe compared to the other option below. If you know what you are doing then you can use your pc and boot from the live media then plug in your usb disk. first check your disk as normal user run
         

      ls -l /dev/disk/by-id/usb* | sed 's|.*\(/usb\)|\1|' 

      ls -l /dev/disk/by-id/ata* | sed 's|.*\(/ata\)|\1|' 
 
This should tell you which disk is your target, another trick is to use hwinfo (thanks to the liveusb page of opensuse wiki) as a normal user run:

     su root -c'grep -Ff <(hwinfo --disk --short) <(hwinfo --usb --short)' 


      su root -c 'blkid -o list -c /dev/null'  

 And make sure you only have one usb disk inserted just to clear things out. Be very careful when running dd  command since it literally means "Destroy Data" if you pointed it to the wrong disk then all of the files in that disk or partition is history. If you are really sure which disk is your target then run the command:

     su root -c 'dd if=/dev/zero of=/dev/sdX bs=4M & pid=$!' 

         while (( pid )); do kill -SIGUSR1 "${pid}" || break; sleep 10; done  

     
Just replace the    X     with the correct value which you got from fdisk and hwinfo.I will not be responsible for the damage and lost of your files if you made a mistake about the above procedure, use it at your own risk! If you have a running linux system (does not need to be opensuse) you can install the package dd_rescue or ddrescue the name vary from distro to distro. When you have it installed run:

      dd_rescue /dev/zero /dev/sdX 


Where  /dev/sdbX  is your target disk. Again at your own risk!!! When your done with clearing your usb disk then you can proceed with the installation.


That's all folks.


No comments:

Post a Comment