Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Thursday, 17 May 2012

Triple OS on MacBook Pro8 2 -- missing operating system

Today I am trying to install Windows 7 64bit OS and Ubuntu 12.04 LTS 64bit OS on my Macbook pro (later 2011), I followed this link (http://lifehacker.com/5531037/how-to-triple+boot-your-mac-with-windows-and-linux-no-boot-camp-required) to install these extra two OS.

Everything goes well until I restart the computer to launch Ubuntu through rEFIt. When I restarted my Mac after installing windows and ubuntu, I can see three OS icon and I shift to ubuntu. After a screen flash, it pop up a black screen with one sentence on the top, say, missing operating system.

Initial guess is that Linux GRUB boot loader does not install properly, it might be corrupted by Windows MBR boot loader. Therefore a new boot loader should be created to make all OS can be detectable.

After several searching on google, I found this link (http://ubuntuforums.org/showthread.php?t=1908210) which solved my problem.  As this link addressed the whole installation procedure, given that we have already installed three operating systems, we only need to regenerate a boot loader if something is wrong when we start up computer.  I summarise them as following:

1) Download gdisk from here(http://sourceforge.net/projects/gptfdisk/)
2) Log in Mac OS
3) Open the "Terminal" in Mac OS (lauchpad->utility->terminal, or search from spotlight)
4) Run "sudo gdisk /dev/disk0"
5) Type 'r' and then 'p' to print out the partitions
6) Then type 'h' to create hmbr
7) Type in the partition number corresponding to different OS, for example, #2 for mac, #5 for windows and # 7 for ubuntu, you should type 2 5 7
8) Next select 'y' to place EFI partition first
9) Type in MBR hex code for each partition, usually 'AF' for lion, '07' for Windows and '83' for linux. You might notice that in your machine, the hex code for windows and linux are the same '07', it cause one system is missing which cannot be detected by current boot loader. Note that do not set any of the bootable flag.
10) Finally type 'w' and 'y' to update the MBR

Now when you restart your system, each OS should be working.

Good luck.

Monday, 12 March 2012

Requires installation of untrusted packages

Today I am trying to install Skype on my Ubuntu 10.10 (Maverick), it gives me the error like "Requires installation of untrusted packages" even though I install from Ubuntu Software Center which I assume everything there should be authenticated and have trusted Key.

When I googled on the web, people suggested two ways to fix this.
1) Open a terminal, and then use "sudo apt-get install YOUR_PACKAGE" or download deb file from somewhere.

2) Run "sudo apt-get update" in the console and then fetch the package from Ubuntu Software Center.

Sometimes Ubuntu just lost the sound for some reason

Sometimes, you might lost the sound output in Ubuntu. One way is worth to try is to open the sound management from System-> Preferences, and then choose analog output as a connector in the output menu.

Sunday, 11 March 2012

How to solve GPG error when you run apt-get update your source list?

In computers based on a Debian operating system that uses Linux kernel, error messages may come up like 'NO_PUBKEY'.This happens while using the Apt-Get command line tool and this error is associated with the tool's update feature. The new feature in the Apt-Get package management toolguarantees the authenticity of the server before updating the Debian OS. That's why the error 'NO_PUBKEY' pops up. This problem can be solved by keying in the appropriate commands. 

Here I found a really helpful solution from this link.

When you add a repository in your /etc/apt/sources.list and run a apt-update you'll get the update of the newly added repository but also a warning about a GPG key like the following one:



Hit http://ppa.launchpad.net intrepid/main Sources
Hit http://fr.archive.ubuntu.com intrepid-proposed/universe Packages
Hit http://ppa.launchpad.net intrepid/main Packages
Fetched 309B in 0s (519B/s)
Reading package lists... Done
W: GPG error: http://ppa.launchpad.net intrepid Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY D702BF6B8C6C1EFD


Running again apt-update won't solve the issue.
This warning can be safely ignored, but I don't like to leave warning when there is a solution to get rid of it... because when something is going wrong, it would complicate to sort out what is safe to be ignored and what tells about a real issue.

So, to get rid of this warning here is the two command you need to execute :

Expand this zonegpg --keyserver subkeys.pgp.net --recv D702BF6B8C6C1EFD
gpg --export --armor D702BF6B8C6C1EFD  | sudo apt-key add -
sudo apt-get update


which will give this output :


Expand this zone !
thomas@daisybox:~$ gpg --keyserver subkeys.pgp.net --recv D702BF6B8C6C1EFD                                                                                                                                                                                
gpg: directory `/home/thomas/.gnupg' created                                                                                                                                                                                                              
gpg: new configuration file `/home/thomas/.gnupg/gpg.conf' created                                                                                                                                                                                        
gpg: WARNING: options in `/home/thomas/.gnupg/gpg.conf' are not yet active during this run                                                                                                                                                                
gpg: keyring `/home/thomas/.gnupg/secring.gpg' created                                                                                                                                                                                                    
gpg: keyring `/home/thomas/.gnupg/pubring.gpg' created                                                                                                                                                                                                    
gpg: requesting key 8C6C1EFD from hkp server subkeys.pgp.net                                                                                                                                                                                              
gpg: /home/thomas/.gnupg/trustdb.gpg: trustdb created                                                                                                                                                                                                     
gpg: key 8C6C1EFD: public key "Launchpad PPA for Bazaar Developers" imported                                                                                                                                                                              
gpg: Total number processed: 1                                                                                                                                                                                                                            
gpg:               imported: 1  (RSA: 1)                                                                                                                                                                                                                  
thomas@daisybox:~$ gpg --export --armor D702BF6B8C6C1EFD  | sudo apt-key add -
OK                                                                            
thomas@daisybox:~$ sudo apt-get update
Hit http://fr.archive.ubuntu.com intrepid Release.gpg
....
Hit http://packages.medibuntu.org intrepid/free Sources
Hit http://packages.medibuntu.org intrepid/non-free Sources
Fetched 309B in 0s (478B/s)
Reading package lists... Done

Friday, 3 February 2012

Remove linux redundant kernel header files

On Ubuntu, every time when you update kernel modules,  the previous kernel modules will be still kept in system. There is an annoy list(I reckon at least :p) which contains several different kernel systems when boot via GRUB. In order to make system clean and concise, we can remove those outdated files.

(http://ubuntugenius.wordpress.com/2011/01/08/ubuntu-cleanup-how-to-remove-all-unused-linux-kernel-headers-images-and-modules/)


Unless you have a totally fresh install of Ubuntu, you have probably noticed that each time you boot up, the GRUB boot menu lists a bunch of previous Linux kernels which you can boot into. While this can occasionally come in handy – like if you can’t boot into the new kernel after an upgrade – those previous kernels, images and modules are usually just wasting space.
While you can go into Synaptic, search for all the bits and pieces of previous kernels, and mark them for removal, here is a much easier method. In a terminal, simply paste the following command, and it will remove all but the current kernel (if you’ve upgraded your system, or had an update with a new kernel, please reboot your machine before running this):
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
You will see some info about what is going on:
The following packages will be REMOVED:
linux-headers-2.6.35-22* linux-headers-2.6.35-22-generic*
linux-headers-2.6.35-23* linux-headers-2.6.35-23-generic*
linux-image-2.6.32-25-generic* linux-image-2.6.35-22-generic*
linux-image-2.6.35-23-generic*
0 upgraded, 0 newly installed, 7 to remove and 13 not upgraded.
After this operation, 586MB disk space will be freed.
(Reading database … 261863 files and directories currently installed.)
Removing linux-headers-2.6.35-22-generic …
Removing linux-headers-2.6.35-22 …
Removing linux-headers-2.6.35-23-generic …
Removing linux-headers-2.6.35-23 …
Removing linux-image-2.6.32-25-generic …
It will then go on to generate a new GRUB menu, and when you reboot, you’ll see only the current kernel is listed.

How to compile linux kernal modules and overwrite the current one

This is one the essential and important task. Many time we upgrade our kernel and some precompiled drivers won't work with Linux. Especially if you have weird hardware; then vendor may send you driver code aka C files to compile. Or even you can write your own Linux kernel driver. Compiling kernel driver is easy. Kernel 2.6.xx makes it even much more easier. Following steps are required to compile driver as module:
1) You need running kernel source code; if you don't have a source code download it fromkernel.org. Untar kernel source code (tar ball) in /usr/src using tar command:
$ tar -zxvf kernel* -C /usr/src
To be frank kernel headers are more than sufficient to compile kernel modules / drivers. See how to install kernel headers under Debian / Ubuntu Linux or RHEL / CentOS / Fedora Linux.
2) Next go to your kernel module source code directory and simply create the Makefile file as follows (assuming your kernel module name is foo):
$ vi Makefile
3) Add following text to it:
obj-m = foo.o
KVERSION = $(shell uname -r)
all:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
4) Compile module using make command (module build can be done by any user) :
$ make
It will finally creates the foo.ko module in current directory. You can see all actual compile command stored in .foo* files in same directory.
5) Once module compiled successfully, load it using insmod or modprobe command. You need to be root user or privileged user to run insmod:
# insmod foo.ko

Example: hello.c module

1) hello.c C source code. Copy following code and save to hello.c
$ mkdir demo; cd demo
$ vi hello.c
2)Add following c source code to it:
#include <linux/module.h>       /* Needed by all modules */
#include <linux/kernel.h>       /* Needed for KERN_INFO */
#include <linux/init.h>         /* Needed for the macros */
static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}
static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr.\n");
}
module_init(hello_start);
module_exit(hello_end);
This is an example modified from original source for demonstration purpose.
3) Save the file. Create new Makefile as follows:
$ vi Makefile
Append following make commands:
obj-m = hello.o
KVERSION = $(shell uname -r)
all:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
4) Save and close the file.
5) Compile hello.c module:
$ make
6) Become a root user (use su or sudo) and load the module:
$ su -
# insmod hello.ko
Note you can see message on screen if you are logged in as root under run level 3.
7) Verify that module loaded:
# lsmod | less
8) See message in /var/log/message file:
# tail -f /var/log/message
9) Unload the module:
# rmmod hello
10) Load module when Linux system comes up. File /etc/modules use to load kernel boot time. This file should contain the names of kernel modules that are to be loaded at boot time, one per line. First copy your module to /lib/modules/$(uname -r)/kernel/drivers. Following are suggested steps:
(a) Create directory for hello module:
# mkdir -p /lib/modules/$(uname -r)/kernel/drivers/hello
(b) Copy module:
# cp hello.ko /lib/modules/$(uname -r)/kernel/drivers/hello/
(c) Edit /etc/modules file under Debian Linux:
# vi /etc/modules
(d) Add following line to it:
hello
(e) Reboot to see changes. Use lsmod or dmesg command to verify module loaded or not.
# cat /proc/modules
OR
# lsmod | less

File structure in the Linux operation system

Compare with file system on window, linux has its own hierarchy, which has top level directory /root and following all other subdirectories.

Here I just summarize the basic linux file hierarchy (cite from http://www.ubuntugeek.com/linux-or-ubuntu-directory-structure.html)



  • /bin - binary applications (most of your executable files)
  • /boot - files required to boot (such as the kernel, etc)
  • /dev - your devices (everything from drives to displays)
  • /etc - just about every configuration file for your system
  • /etc/profile.d - contains scripts that are run by /etc/profile upon login.
  • /etc/rc.d - contains a number of shell scripts that are run on bootup at different run levels. There is also typically an rc.inet1 script to set up networking (in Slackwar), an rc.modules script to load modular device drivers, and an rc.local script that can be edited to run commands desired by the administrator, along the lines of autoexec.bat in DOS.


  • /etc/rc.d/init.d - contains most of the initialization scripts themselves on an rpm-based system.
  • /etc/rc.d/rc*.d - where “*” is a number corresponding to the default run level. Contains files for services to be started and stopped at that run level. On rpm-based systems, these files are symbolic links to the initialization scripts themselves, which are in /etc/rc.d/init.d.
  • /etc/skel - directory containing several example or skeleton initialization shells. Often contains subdirectories and files used to populate a new user’s home directory.
  • /etc/X11 - configuration files for the X Window system
  • /home - locally stored user files and folders
  • /lib - system libraries (similar to Program Files)
  • /lost+found - lost and found for lost files
  • /media - mounted (or loaded) devices such as cdroms, digital cameras, etc.
  • /mnt - mounted file systems
  • /opt - location for “optionally” installed programs
  • /proc - dynamic directory including information about and listing of processes
  • /root - “home” folder for the root user
  • /sbin - system-only binaries (see /bin)
  • /sys - contains information about the system
  • /tmp - temporary files
  • /usr - applications mainly for regular users
  • /var - mainly logs, databases, etc.
  • /usr/local/bin - the place to put your own programs. They will not be overwritten with upgrades.
  • /usr/share/doc - documentation.