четвъртък, 30 юни 2016 г.

How to resize partition in virtual machine

First, find the directory where your  *.qcow2 file resides.
$ ls -la *.qcow2
should show the file you're looking for
Then use qemu to resize the file.
$sudo qemu-img resize X*.qcow2 +10GB
will add 10GB to your file. Make sure not to add more GBs than you'd like the file to have, because then you cannot shrink it back to less. I found it out the hard way :)
All this is done with the virtual machine turned off.
Then comes the complicated part.
You need to convince you're virtual OS that it has more space. So this is what I did (following source):
So start your virtual machine, start a terminal and work there.
 First, check your current partition table:
$df -h
and make sure you're working on the correct partition. In my case, I had to work on /dev/sda.
Then delete the last partition on /dev/sda
$su
$fdisk /dev/sda
$p
to print the current partition table.
I had
/dev/sda1 -> primary, root partition
/dev/sda2 -> extended
/dev/sda5 -> SWAP.
Obviously different situation from the instructions, so I decided to delete /dev/sda2 and work from there.
So to delete /dev/sda2
$d
$2
$w
This finalizes the destruction.
Then I had the space in the end of my virtual hard empty. I created a new partition
$fdisk /dev/sda
$n
$p
all else was the default ones, just make sure the final cylinder is indeed the final of the "disk", because for me, the first time, it wasn't.
After that you finish with $w and exit.
Then you need to reboot to finalize.
$sudo reboot
In the better case, you could use
$resize2fs /dev/sda1

to expand your root hard. It didn't work for me, so I started gparted
$sudo gparted
and deleted the new partition, because resize2fs gave me some error with cylinders.
After deleting, I created a new ext4 partition and I hit "Apply". The idea was to fix the error I got previously.
Then when it was ready, I deleted the new partition, clicked on /dev/sda1 and told it to resize to the end (or almost) of the now unformatted region. I left little space in the end which I formatted as swap, just so that I have some. Then I clicked Apply and gparted did the magic.
Now I have 20GB bigger virtual hard, which is 10GB more than I planned for, but still, it all seems to work fine.
Yay!

вторник, 17 май 2016 г.

wallet files not opening

So, after my fresh installation, I wanted to port my wallet files. But for some very strange reason, it kept on telling me my password is incorrect. Which is simply not true. So anyway, I found this howto and it worked as a charm.
Basically, you need to disable your wallet from System, then paste the old .kwl and .salt files into the appropriate folders:
~/.local/share/kwalletd/
 ~/.kde4/share/apps/kwallet/
 and then to enable the wallet from System Settings. This time, my wallet worked.
So wallet panic is happily over and problem is solved.

сряда, 11 май 2016 г.

juniper (pulse secure) under gentoo. Finally!

Woah, that was one of the craziest thing I needed to do. It took me forever to find how to convince the company's server that I'm connecting with Pulse Secure. But after days of me wanting to rip my head off, I finally made it.
The problem is that the app which Pulse Secure provides is not a native 64x library and it's not a native Gentoo app, which makes it a nightmare to install it. In the end you can extract the deb package and put it where it belongs (/usr/local/pulse), you can connect /bin/ifconfig with /usr/sbin/ifconfig), but that won't help much since the whole thing is totally messed up and pulsesvc is a compiled file so you can't change PATHs and what's worst, you don't know the PATHs inside and so you don't get an error, you don't get anything to work with.

 After days of trying everything, here is what worked for me.
I followed this guide (for a while at least).
0. You need to start the "tun" module. 
$ sudo modprobe tun
$ sudo echo "tun" > /etc/modules-load.d/VPN.conf  - this one turned out not to be necessary
If you get an error on modprobe tun try $sudo modprobe --force tun
it worked for me. But this step is key, otherwise, openconnect cannot set up the connection.
1. Get you certificate  (from here):
Log into your vpn trough Firefox. Go to Tools->Page Info -> Security->View Certificate -> Details -> Export
Save the file as .DER (for Juniper's client) or .PEM (for OpenConnect)
2. Download stuff:
sudo equo install vpnc
sudo chmod a+x+r -R /etc/vpnc
sudo equo install libxml2 libxml2-dev gettext make libssl-dev pkg-config libtool autoconf git pip net-tools libgnutls-dev 
Most of those don't exist in Gentoo but still I post them here becaues maybe something helped :)
3.
sudo equo install openconnect
sudo pip install mechanize
git clone https://github.com/russdill/juniper-vpn-py
cd juniper-vpn-py
/if it doesn't exist,first $mkdir juniper-vpn-py/
sed -i '/ssl._create_default_https_context = ssl._create_unverified_context/d' ./juniper-vpn.py
sed -i '/ssl._create_default_https_context = ssl._create_unverified_context/d' ./tncc.py
sudo mkdir -p /run/resolvconf/interface
sudo cp /etc/resolv.conf /run/resolvconf/resolv.conf
sudo mv /etc/resolv.conf /run/resolvconf/interface/mlan0
sudo ln -s /run/resolvconf/resolv.conf /etc/resolv.conf
sudo resolvconf --enable-updates
/that gives me errors so probably wasn't very important/
4. Finally, I created this file:
$nano tun.sh
with the content:
#!/bin/bash

if (ip tuntap add dev tun0 mode tun)
then
  echo "New tun Created Successfully"
  sleep 4
else
  echo "Old tun Exists, Need to Cleanup"
  ifconfig tun0 down
  ip tuntap del dev tun0 mode tun
  sleep 4
  ip tuntap add dev tun0 mode tun
  sleep 4
fi

if(ifconfig tun0 up)
then
  echo "Interface tun0 is up"
else
  echo "Something went wrong, exiting..."
  exit;
fi

export LD_LIBRARY_PATH="/usr/local/lib"

5. $sudo sh tun.sh
This will set up the tun interface and make sure it is fresh and ok. You may add to the script
 $modprobe tun
6. For me the python script didn't work for some unknown reason which I don't have time to research right now. So to connect I did:
$ sudo openconnect --cafile ~/cert_file.pem --juniper VPN_host -u USER_name
 where cert_file is the name you gave to your certificate, VPN_host is the name of your host's VPN, USER_name is your login username for the VPN.
When it connects, it will also ask you for the password.

Then when it says "ESP session established with server"  you're good to go and do whatever you need to do with your vpn, in my case, use perforce.

7. You stop the connection with CTRL+C and $sudo ifconfig tun0 down


I'm soooo happy I managed to do that. It seems simple once it's done, but it took me days to find the howto that works for me and also, I tried to install the Pulse Secure app on Sabayon, Ubuntu x64, Fedora x32 and LUbuntu x32. It didn't work anywhere! So this is really a success.

Btw, if you don't feel like filling in the password each time, you can make a simple script:
#!/bin/bash
username="user_name"
password="vpn_pass"
url="vpn_url"
cert="your_certificate"
echo "$password" |  sudo openconnect --cafile $cert --juniper $url -u $username --passwd-on-stdin

And then to run it like sh script.sh
This way, you'll have to fill only your sudo password :)

Some links where you can find many howtos, maybe they will woro for you, they didn't for me.
ArchLinux, Short VPN guide, AnotherOneDownloadPage, GentooHowto,

Explanation how to install in Ubuntu x64. I couldn't make it work. Some more explanations + download links for Mac, Win and Linux.

This should tell you if you have TUN:
$ grep CONFIG_TUN /usr/src/linux/.config
CONFIG_TUN=y

From Sabayon wiki:
$ cd /sbin
$ sudo ln -s /bin/ifconfig ifconfig
$ sudo ln -s /bin/route route
I don't know how much the last step helped.