Friday, January 28, 2011

Getting a VM to work...the hard way


What am I talking about? I still don't really understand the concept of a computer running inside a computer. And I don't mean a laptop running inside a desktop case! I'm talking about Virtual-Machines. Loading an OS from a recently acquired image and then making it run in the background of an already running OS. Sounds like I might need a faster computer. Or get some liquid N2 and just frost up the bottom of my laptop. At least my palms wouldn't get hot. It does sound like a bit much.

Kernel-based Virtual Manager looks like a decent package. A bare bones kind of software that hopefully won't weigh down the running system. Problem is that I don't know how to use it, and I think that it runs from a command-line, which is what I want. There is an ever-so-useful HowTo at there site, and I'm testing that the procedures do work as I type this. I should go to bed.

Install the packages below as a start.
sudo apt-get -y install kvm qemu bridge-utils uml-utilities
sudo modprobe kvm
sudo apt-get -y install libvirt-bin
sudo apt-get -y install virt-manager

The last one is meant to be some sort of GUI but I have no idea how to use it, yet. The modprobe line reloads KVM without having to restart your computer, even though I've restarted mine several times before even getting this far.

Next, is you'll want to create a disk image for the guest-image, or in other words, a place where the virtual machine will live/sleep. From what I gather, Qcow2 is some sort of tool which creates a standalone image from a cluster of memory which is then scanned by the header when it needs to be read. I don't know. It's a thing. Create one like this:

/path/on/computer/where/it/will/live create -f qcow2 imagename.img 10G

Qcow2 will do it's thing, the last paramater is the size of the image, 10G -- I haven't played around with this much. When you have finally downloaded your Free and Open Source Linux distro that you so desire, just go ahead and install it.

sudo qemu-system-x86_64 -hda imagename.img -cdrom /path/where/.iso/is -m 512

There is meant to be some sort of read error and the host os will be unable to determine if the system you are installing is 32 or 64 bit, so by assigning qemu-system-x86_64 as the pathway, no one gets confused. Although, it might actually be part of the command, not sure. The final -m tells qemu how much RAM you want to allocate to the VM. I'm finding out now that maybe I should have used -m 1024, 36mins57s remaining...uhg!

1:29:40AM - Still waiting...

1:34:46AM - Meanwhile, test that the printer works

1:49:05AM - Printer works, going to bed, check the install in the morning.

5:35:19AM - Still going, stupid WINS param...

8:54:24AM - Yay! It's working! I'm now running Debian 2.22.3

Lastly, when you need to start up the VM from scratch, it is a simple call of the OS file created and the image memory, or whatever you want to call it. As you will probably find out, it's much simpler to create a directory and store both of these files there, that's what I did.
qemu-system-x86_64 -hda /path/to/imagename.img

So that's it. The system seems to be working fine. I have somehow lost track of where the KVM functionality is taking place, as Qemu seems to be doing all the work. My understanding of KVM has been rewritten, again - I must have missed something.

Sunday, January 2, 2011

Creating an autorun script for when a specific USB device is plugged into your Computer

Much of my information came from this thread, very helpful: http://ubuntuforums.org/showthread.php?t=502864

Several steps are involved and several locations will be accessed heavily. These are:
/etc/udev/rules.d - where the .rules file will be kept for the computer to access when the USB device of choice is plugged in, this ultimately points to the script file below
/usr/local - or wherever your script file is located.
/home/... - any other places where script files that will be used are stored, python, C etc

/etc/udev/rules.d
A README file is available in this folder and it is helpful to read. You will need to create a file here which will be picked up by your computer and read when an action occurs.

The file must begin with two digits followed by a - and end with .rules, 70-filename.rules. It will contain the following script:

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0d49", ATTRS{idProduct}=="7350", RUN+="/usr/local/script_file.sh", SYMLINK+="my_device"

If you are lost, just take a look at the files in /etc/udev/rules.d and make a similar filename.

To make it work for a specific device, with the device plugged in, run lsusb in a terminal and find the device Vendor and Product numbers. For the Kodak Co. device below, Vendor is 040a and the Product is 0576:
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 040a:0576 Kodak Co.
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000

The RUN+= is the location of your script file. It is very important that this file has user executable permission as well as for all other .py files etc that will be used by the script. To do this, go to the directory with the file and run:

$ sudo chmod u+x filename

and check the permissions with

$ ls -all

It should be: -rwxr--r--
These are the permissions that work for me, I'm not sure if this is across all platforms.
The location of the script file is not important, but make it an easy place to remember. SYMLINK+= is a feature I'm not familiar as yet, however it does allocate the device to the variable given to a spot in the /dev folder, /dev/Maxtor.
The ATTRS before {idVendor} and {idProduct} can be changed to SYSFS if the device is not being recognised once plugged in. This can only be tested by you and your product, although there may be better explainations about this.

The SUBSYSTEM variable can be left out completely, however it does give useful information to the computer. Other variables such as usb_device and pci... exist but usb is the one that works for me.

At first, it is advised to make the script file a simple copy code like a cp command of a file you know to a place you know. If after you plug in the device, you find that the file has been copied to the new destination, you can be sure that the .rules file has been successfully read. This is definately the hardest part of the setup of this 'autorun' script.

Before I wrap things up, I did want to add a work-around for the .sh file, the file pointed to by the .rules file. I had problems when plugging in my device because the .sh file would read first, and then any other code already on the computer would read last. This was a problem because I wanted to point to a folder on the device but the device hadn't been mounted yet. I could have mounted it myself but I ran into a dead end. An alternative was using the sleep command followed by my code, inside some curly braces {}, looking like this:
{

sleep 5
cp -ar /a/folder/on/my/computer /folder/on/device

} &

The {} tells the interpreter to read to code, but run it in the background. With the sleep command, there is a 5 second pause while the computer runs it's usual code of mounting the device. After the 5 seconds it now copies the folder to the location on the device.

If you have a know fix for mounting a device manually using the /dev location, I'd be happy to hear. I'm now using this method to auto update my Uni files on my external HD whenever I plug it in. This is my first How-To so enjoy, rate, comment.

Thursday, December 30, 2010

Healthy Choices

After viewing several health sites and talking with some work friends about the conundrums of eating healthy, exercising and sticking to the goal...I have realised that it may be difficult, if I let it be. The "goal" calculator above was put together by a well known vlogger Scooby1961 who can be found on YouTube. I won't provide a link to his websites since it may come across as bad publicity to him...I'm sure you'll be able to find him. This post, I hope to outline some problems with having a busy work-life and trying to put on muscles, which requires an intake of plenty of healthy foods and protein.

So what seems to be one of the difficulties with maintaining a healthy diet to assist a complete body workout and to gain muscle, is sticking to the plan. What I believe needs to be taken into account when making a health plan is your situation. Firstly, the hours of work you do and the time that you are there can be critical: day-shit, afternoon-shift, graveyard-shift. The type of work, doesn't really matter I guess. If you are a student, then the schedule for the semester should be known. Work and Uni are similar in that they both follow a schedule and workout sessions must be planned around these two.

Next, is the workouts. As mentioned above, these need to be planned around all the stuff that keeps you busy. I've heard from many people that a workout in the morning is the best but some of us, including me, it cannot be achieved. Therefore, an afternoon workout is the only other option. What ever the case, workouts should be done in between meals. If you are using certain powders to assist muscle gain, i.e. creatine, then workout session need to be at least 1hr after taking a dose, and/or finish 30mins before taking a dose. It ain't rocket science, but it's no fun working out on an empty stomach, and the same for when you are full up from a meal, it just sloshes around and makes you sick.

Finally, hobbies and interests or study. Personally, I'm starting to read more, news sites like the Guardian or the Courier Mail make keeping up-to-date easy. Australasian Science is a good Australian monthly with articles that range from Astrology to Geological finds in Australia and these often tie in with my studies so it isn't a complete waste of time. Playing guitar is good also for me and very relaxing. It doesn't matter what you do to kill time, but you must always know what part of the day you are at and what is next on the health-agenda. What I mean, is always know what is next, protein shake, travel to work, morning tea, toilet time etc - and drink lots of water. So even though you may be just watching TV or checking flight prices for your winter holiday, in the back of your mind you should know what part of you day is next, food, water or workout. If you just focus too hard on the goal and the diet, you may find that even just thinking about it will become a drag and you will lose interest. Have a break. Think of something else. The only part when you should be thinking about your muscles is when you are at the gym concentrating of your form and your breathing. As soon as you leave, your body does the rest.

Now, add all that together and we have three activities that must be considered when planning a diet: Work/Uni, the Workouts, the Free-Time/Study. If you can draw up all the time slots for these activities, then you will be able to see the time in the week that is free. As a general rule, I keep the weekend free, gives me something to look forward to that I haven't planned. With this free time during the week, you need to be clever, because chances are you will not have much time to prepare food. A big time saver for me is, from Sunday - Thursday, cook a nice dinner and cook extra, enough for lunch tomorrow. That way, all you have to do is pack it in a lunch box, and you have a big lunch for tomorrow. Examples could be, Ginger and Lime Fried Chicken with steamed veges and rice, Thin sliced rump in a garlic soy sauce with rice or spaghetti bolognese (I love pasta).
     The night time is the only time of the day when I can use a stove top so I utilize this time and make something nice, something hot. I actually enjoy cooking (wouldn't mind if someone else did the cooking) and eating and if all the fun and enjoyment is taken away because of a diet, then it might be a little bit harder to reach your goal.
      Another problem may be if you like junk food, and I know that there are those people out there. All I can suggest here is to avoid junk-food outlets. Yes they are an easy option. Yes they appear cheap. Yes they can be convenient. But you can avoid this if you just do some clever planning. Find the times of the day that you have free, and prepare something that will be quick and filling. If you are wanting to gain muscle, you will know that you will need to eat 6 protein packed meals over the whole day. But no one ever said how long you need to eat for. Eating 23g of protein in 2 minutes is probably going to have the same affect as eating 23g of protein in 15minutes. Although you might get sick if you eat too quick...
      If your timetable doesn't coincide with lunch at 12PM, then unfortunately you will have to swap it in for one of the quick meals, i.e. protein shake, and have the bigger lunch a bit later on when you have more time. Once you have mastered your eating times, you will no longer even need to think about it, and you can do more of what you want, finish that novel, finish that assignment!

Dieting is hard. I know. I'm an amateur. What I'm finding is that it is getting easier. I'm learning more about the food that I eat, and I'm picking up tips on foods I don't eat that are a quick and healthy option, Walnuts for instance. I've only been watching what I eat for the last three months and I hope that I can continue this for longer. My goal is simple, put on muscle. Therefore, keep it simple and enjoy it as much I can.

Sunday, November 14, 2010

2 Isolated Upper Body Workouts

Since I am rather new to the muscle-gain thing, I thought it might be easier to type up the two workouts that I'm doing at the moment. I'm really wanting to focus on my chest and shoulders with the idea that other muscles like the biceps and triceps will grow accordingly - I can focus on them at another time when there are enough support muscles in place. It would be silly to have big biceps but no chest, that would be weird.

I will say it now that I accept comments and criticism but just know that I'm teaching myself how to put on muscle since I don't have enough money for a personal trainer or the gym.

So first up here is my chest workout. The workout template came from here but has been modified slightly for gaining not toning. Modifications were also made if equipment was not available.
WarmUp - PushUps, Upright dumbbell press, Bench Press
Arnold Press       - 5 @ 8 + 2 Upright Press
Bench Press       - 5 @ 8
Dumbbell Flyes  - 5 @ 10
Pullover             - 5 @ 8

And this is my shoulder workout, template taken from here. This workout had to be modified a fair bit since I don't have a machine.
WarmUp - PushUps, Front Barbell Raise, Bent Over Dumbbell Raise
Barbell Front Raise                       - 5 @ 8
Dumbbell Front Raise                   - 2 @ 10
Standing Dumbbell Side Raise     - 5 @ 8
Seated Rear Dumbbell Lat Raise - 4 @ 8
Bentover Row                               - 2 @ 8
Dumbbell Shrug                            - 5 @ 12

Now, I'm not really sure why I've decided to make the reps per set so different for each exercise but I hope it works. I'll probably use this as a personal guide since I can't remember all the exercises...

Saturday, November 6, 2010

Creatine Loading

Fitness training is an important part of maintaining a healthy lifestyle. Sure, you can get away with a walk to the bus stop as your daily/weekly exercise. But if you have a slow metabolism, you will more often than not, need to raise the heart rate more than just what it is at walking pace to keep a good figure - if that's what you want of course.

Being skinny for so long, I've made several weak attempts to gain weight but no noticeable changes have occurred. I'm almost certain that I have one of those fast metabolisms. One where I can eat 2 cups of rice for dinner with a generous serving of peppered steak, and be hungry about 3 hours later before I go to bed. I've never understood how this works or if it is actually my metabolism which is the reason for me never gaining weight. Growing up and being served with rice as the side of choice to my steamed veges and meat, is it possible that my body has just become efficient at breaking down these carbohydrates?

This time, I will try something different. Using some YouTube advice from InstructionalFitness and a little bit of the old fashioned just eating more, I'm hoping to put on some pounds. I've had 1kg of Creatine Monohydrate lying around for a few months and I'm using the destructions on the back as a guide as how I should use it with my muscle program. I've tested it out a few times but I've never done the proper 'loading' and then uptake after training schedule.

Today is the 6th day of the loading program which entails 1 heaped teaspoon mixed into juice, 4 times a day for 1 week. I've been training this last week and have noticed some maximum muscle push increase which is what it's meant to do. 95% of Creatine in the body is in skeletal muscles and it increases the formation of Adenosine triphosphate. ATP is required for some very important, energy intensive, cellular function. Have a look at Wiki if you want to know more. Warnings on the label and on the web do say to be careful though as administering it at the wrong time could cause diarrhoea and other displeasing effects.

There are suggestions that it is not suited to persons who have asthma or bad liver, but I am unsure how this has been tested. I have been mainly focusing my training on the upper body - chest, arms, and shoulders. If I were to set a goal for now, it would be to be able to bench 50kg for at least 8 reps, this sounds reasonable. Long term goal is just to keep fit in case I need to do some work on a farm for some work experience. Best to be prepared than not at all. 

Thursday, October 14, 2010

Casual coffee

Walking, listening, thinking, breathing, needing - always needing, all is needing. If its' not needing to be somewhere, it's needing to take a minute and get a few of those deeper breaths that would all do the body a little good. There's is no compromise in regard to getting a good coffee. I particularly like the Al Pacino coffee ad for Vittoria Coffee. Sadly, the advertising worked and I went and tried their coffee (advertising deserves it's own post - relating to how much I loathe and admire it).

Not really knowing a good coffee, my premature palate has yet to grow. There is no line to set those good from those bad. Deciding to have a coffee grew like an instinct - the notion that "If I don't have this coffee, I'll probably write right off the end of the page.", and fall asleep before I can go back to the next line. I don't like cold coffee. Making a coffee (back when all I knew was instant) and then letting it sit on the table beside me until it's so cold that it almost has its' own microclimate, is not understood. Iced coffees are good, but on the same token, how can it be enjoyed if it's completely different from when it was made? I know, there are always exceptions.

What I'm finding out is that maybe coffee does have a taste. Maybe there is a reason that the woman with the purple and white scarf always goes to the coffee shop on the corner. Maybe there is a reason why Chris walks in at about 8:00AM -+5min and grabs a smile and a coffee from the barista at the register, several doors up from scarf-ladies shop, I'll call her Annie. My reason is that I enjoy the taste.

Someone once told me never to wash the plunger with soap. The same person told me about some of the wonderful types of coffee - affogato, macchiato, ristretto, doppio macchiato...well maybe only 4 but still. My point is, coffee isn't just coffee, to me anymore. It would almost be incorrect to go in and ask for a coffee, hand over your money and expect a hot beverage. This person would most likely be asking for a flat white, and this person is most probably too busy to worry about what shape or how fluffy their coffee is. Ignorance is bliss. What does it take to be a coffee aficionado and when do you become just a prick? There is a fine line.

At the moment, I might just stick to drinking coffee. Building and learning from what I see and what I taste. What I can remember will only be used if it is a colourful and bright memory. Only if there is extra feeling instilled and can be expressed accordingly. What is the use of saying the cat can jump over the house if, in fact, it can only jump over the sandpit? How long is a piece of string anyway?

Thursday, October 7, 2010

Knee deep in 'dirty' water

Here is a conundrum. Simple as it may be, I'd rather write it down than think about it at the moment, or let someone else think about it. I'm actually looking for some references for a university assignment but I might as well write about what I need them for before I try and find them. The problem has definitely presented itself rather surreptitiously and is actually not much of a problem. Having to travel along much of Brisbane's Bulimba Creek, sometimes even entering it, there was, and expectedly, rubbish here and there. The usual plastic bottles, car tires (parts of), crisp packets, pieces of string or twine, clothing and just stuff that you would classify as rubbish.

Now most of the creek was running quite nicely and freely, probably due to the amounts of rain we have had over the last week. The water was also fairly clear and when I was in the creek, it felt nice - it didn't feel like stuff climbing up my leg or like I was knee deep in a pile of wet mulch. But this is where I think the thinking needs to be done. How can a creek that has scattered pieces of rubbish lying on the banks, less than 2m from the water, and still be clean? Did I mention that I could see to the bottom...

So I guess the story isn't complete. I haven't run the water through and ICP, or run several Inorganic tests for levels of N or P. But instinct usually tells us something about the situation before we attempt to take action. There were moments when I felt like I could drink from it, and maybe I should have just ballsed it and seen what happened. It probably isn't so important because on the scheme of things, I'm sitting at home, drinking water that has been filtered and pH adjusted to my own desire.

Maybe this plastic substrate has been washed free of the pollutants and there is more to this idea that stuff that is classified as rubbish, isn't actually rubbish - a small percentage of it is. The small percentage that we cannot see. The small percentage that dissolves or floats down the creek, along with the leaf that has just fallen from a Eucalypt tree.

Hopefully I can find some decent references, furthermore I hope I can make sense of it all before I'm senseless. Here's a little link from my university website. I've discovered RSS feeds and though I think they're just chewing up my memory, I'm sure I'll see something one day. Water is important. Act now or be axed.