Sunday, March 16, 2014

Dual boot Fedora/Windows, LVM management

Problem: create dual boot Fedora/Windows system.

Initial state: Fedora 17. LVM: /boot, /root, /home, /swap. Unallocated space - 0.
Finish state: Fedora 17 + Windows 7. LVM: /boot, /root, /home, /swap; NTFS: C:\. Unallocated space - 0.
What we need to get it: cd/dvd/usb images of Fedora X live cd, desired windows pack and GParted

If your fedora partition scheme was automatical as in my case and you don't know how labeled your lvm volume groups and logical volumes you can use system-config-lvm tool to get extensive knowledge about your filesystem. As far as I know it exists in fedora repositories of version 17. To resolve this problem first of all we need to repartition our initial system, so we will have some unallocated space for NTFS. The easiest way to do this is to use GParted live usb/cd/dvd to boot debian live and deactivated your main vg_group (in my case it is looked like similar to this screenshot):



In my case this is a bit different picture where I have /boot on /dev/sda1 and /vg_myvg-group on /dev/sda2.
When you deactivate your partition click resize and free some space (if you have it) for your windows system (~60GB). If you see an error that gparted can't shrink your disk because of /boot part allocated at the last sectors, reallocate doing the following steps:

The error sounds smth like this "... cannot resize extents to ... as later ones are allocated ...". To resolve this error I followed steps from this link

a. to see what extents are currently allocated (find range) open terminal and type (in my case this sectors was /boot located at /dev/sda1):

$:pvs -v --segments /dev/sda


b. use 'pmove' command to reallocate extents to the beginning of your drive:

$:sudo pvmove --alloc anywhere /dev/device:"extents_range_from - extents_range_to"


Ok, now you have enough unallocated space for your windows distro and you can start installation. Burn distro with .iso image to your cd/dvd/USB using Unetbootin or other burning tools and setup your windows NTFS file system.
If you get windows installed you might notice at booting that only one available system in bootloader frame exists. Your Grub config was rewritten by new OS and now we need to make new config for dual booting bootloader. Here is a documentation about Grub2. Detailed instruction how to do this you can read here or do the following steps:

1. create dir where you mount you /root and /boot

$:mkdir /mnt/sysimage


2. Find what is the name of your logical volume /root by using any of these two commands, also check where your /boot placed it is usually 500Mb size separate physical disk, in my case it /dev/sda1 and my volume group with /root and /home on /dev/sda2:

$:lvdisplay
$:fdisk -l


3. Mount your /root logical volume to these mount point:

$:mount /dev/mapper/vg_groupName_lv-root /mnt/sysimage


4. Mount your /boot linux disk:

$:mount /dev/sda1 /mnt/sysimage/boot


On this step a possible error is "unknown filesystem type 'LVM2_member". If you can't list your /boot with lvdisplay one of the possible reasons it was corrupted and need to be recovered. To do this follow the next steps (this thread was helpful, /dev/sdaX - /boot location):

$:dd if=/dev/sdaX bs=1 skip=512 count=512 | od -cb
$:dumpe2fs /dev/sd | grep superblock
$:dd if=/dev/zero bs=1 seek=512 count=512 of=/dev/sdaX
$:fsck -y -b "block number from step 2" /dev/sdaX


If you didn't get superblock number after grep command, write last command as this one:
$:fsck -y /dev/sdaX

5. Mount critical unix directories:

$:mount -o bind /dev /mnt/dev
$:mount -o bind /proc /mnt/proc
$:mount -o bind /sys /mnt/sys
$:mount -t tmpfs /mnt/tmpfs /mnt/tmp


6. Chroot to your system image and reconfigure your grub2 config, where /dev/sdX your /boot, in my case /dev/sda1. Or you can reinstall on physical drive as a whole /dev/sda:

$:grub2-install /dev/sdaX
$:grub2-mkconfig -o /boot/grub2/grub.cfg
$:exit
$:reboot


Sunday, October 21, 2012

Adobe Reader for Linux

I remember that one time I saw somewhere that folks wrote about absence of sterling pdf reader for Linux, but here you are. Install Adobe Reader on your Linux machine and feel like a boss: Fedora system guide (use your repositories)
Configure repository, and install through yum:
$ sudo rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
$ sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
$ sudo yum install AdobeReader_enu

Have stolen from here

Tuesday, August 21, 2012

Problem with libnpjp2.so

If you can't "locate" libnpjp2.so or find it in the system, plugin already linked but java applets don't work in your browser yet so probably you have the same problem as me and the solution is the following:

%su - updatedb
%exit

And now system will see libnpjp2.so and link in plugins folder start to work correctly.

Monday, August 6, 2012

Information about memory modules in Linux

Recently I needed to check my memory modules info cause I wanted to add few GB's in my laptop. If you work under Linux (in my case Fedora) and need to get information about installed modules of a memory you can check it using following command under the root:

%dmidecode -t 17

If you've got an error like "command not found", install dmidecode package in your system using an distribution package manager. For RedHat unix systems this should look like:

%yum install dmidecode

What actually can dmidecode do you can find out by typing:

%man dmidecode

Wednesday, July 18, 2012

Bouncing ball.

This is a code snippet of a loop from "bouncing ball" problem, I have used acm.* library package. PAUSE_TIME (how often refreshed screen) is a named constant, in this example equals 1 (humans eyes don't see refresh rate less than 50), from this value as from dx, dy values depended ball's speed. Algorithm actually isn't complicated, all you need is to describe process of touching canvas borders mathematically but easy to forget change initial x, y coordinates for the next ball move. "ball" in that case graphical object GOval.

while (true) {
   if ((x > getWidth() - BALL_SIZE) || (x < 0))    dx = -dx; 
   if ((y > getHeight() - BALL_SIZE) || (y < 0))   dy = -dy;
   x += dx; y += dy; 
   ball.move(dx, dy); 
   pause(PAUSE_TIME); 
   }
Download ACM.JAR  (don't forget to click advertising :) and TUTORIAL HOW TO USE.

Sunday, July 15, 2012

[Java] - Applet viewer size


Hi.
    Recently I had a problem to change an applet viewer size in the Eclipse. If you have the same obstacle to test your program fully or just aesthetically wish to see the result in a properly sized window, so use this code   in your class body:

public void init() {

    setSize(width,height);

 } 

Saturday, June 30, 2012

"Karel the robot" in Linux.

How to get works "Karel the robot" program on linux from Stanford University course Programming methodology.

It will work on Eclipse SDK classic from eclipse site but if you want stanford's version you can take "edu.stanford.cs106_1.0.0.jar" file from "Eclipse for Windows" version from CS (programming methodology course) site, unzip, find folder called "plugins" and put it to your directory */eclipse/plugins. (or you can download this file somewhere, use search engine). After running Eclipse you will see additional Stanford's icons on panel and their menu.  

What you necessarily need is a java version 6 you can download it HERE (to have possibility to download from ORACLES archive you should be authorized, its free). Otherwise "Karel" won't work.

Ok, when you've got it and run eclipse make the following steps:
Project>Properties>Java Compiler> check "Enable project specific settings", Compiler compliance level choose 1.6.

Run Karel. Hope it's helpful for you. Have fun.

P.S. If you haven't installed stanford's panel or have problems with programs running. Use menu Run->Run Configurations -> choose appropriate (the same as your class name) Java Application on the left side of window and push RUN button.

jre-6u2-linux-i586-rpm.bin