This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.
Step 1 - Enable NBD on the Host
modprobe nbd max_part=8
| <?php | |
| /** | |
| * Calculate the elapsed time between two timestamps | |
| * and display in a pretty human way. | |
| * @param integer $start Initial timestamp | |
| * @param integer $end Final timestamp, set to -1 for current time. | |
| * @return string Formatted elapsed time. | |
| */ | |
| function timeBetween($start, $end=-1){ | |
| if($end < 0) $end = time(); |
| <?xml version='1.0' encoding='ASCII'?> | |
| <flow_graph> | |
| <timestamp>Tue Aug 12 14:13:51 2014</timestamp> | |
| <block> | |
| <key>options</key> | |
| <param> | |
| <key>id</key> | |
| <value>fm_receiver</value> | |
| </param> | |
| <param> |
| ## Openbox autostart.sh | |
| ## ==================== | |
| ## When you login to your CrunchBang Openbox session, this autostart script | |
| ## will be executed to set-up your environment and launch any applications | |
| ## you want to run at startup. | |
| ## | |
| ## Note*: some programs, such as 'nm-applet' are run via XDG autostart. | |
| ## Run '/usr/lib/openbox/openbox-xdg-autostart --list' to list any | |
| ## XDG autostarted programs. | |
| ## |
| =================================pc lubuntu上, 2013年=========================================== | |
| #!/bin/sh | |
| #chroot only for root user session | |
| #pivot_root for whole system root directory changing | |
| #sudo su | |
| #mkdir /mnt/new_root #must be 755 root:root, or else sudo won't work: unable to stat /etc/sudoers: Permission denied | |
| #mkdir /mnt/root #must be 755 root:root | |
| #mkdir /mnt/rw #must be 755 root:root |
| #!/bin/sh | |
| mkdir /proc | |
| mkdir /sys | |
| mkdir /d | |
| /bin/mount /proc | |
| /bin/mount /sys | |
| echo /sbin/mdev >/proc/sys/kernel/hotplug | |
| mdev -s | |
| mkdir /roothost | |
| mkdir /newroot |
| # Building static nginx for teh lulz | |
| # | |
| # basic dependencies | |
| sudo apt-get install libxslt1-dev libxml2-dev zlib1g-dev libpcre3-dev libbz2-dev libssl-dev | |
| # download nginx and openssl | |
| wget http://nginx.org/download/nginx-1.5.6.tar.gz | |
| tar xf nginx-1.5.6.tar.gz; cd nginx-1.5.6 |
| # compile | |
| $ g++ zlib-example.cpp -lz -o zlib-example | |
| # run | |
| $ ./zlib-example | |
| Uncompressed size is: 36 | |
| Uncompressed string is: Hello Hello Hello Hello Hello Hello! | |
| ---------- |
| <?php | |
| function elapsed_time($timestamp, $precision = 2) { | |
| $time = time() - $timestamp; | |
| $a = array('decade' => 315576000, 'year' => 31557600, 'month' => 2629800, 'week' => 604800, 'day' => 86400, 'hour' => 3600, 'min' => 60, 'sec' => 1); | |
| $i = 0; | |
| foreach($a as $k => $v) { | |
| $$k = floor($time/$v); | |
| if ($$k) $i++; | |
| $time = $i >= $precision ? 0 : $time - $$k * $v; | |
| $s = $$k > 1 ? 's' : ''; |
Adapted from: http://perpetual-notion.blogspot.com/2011/08/unetbootin-on-mac-os-x.html
fdisk -e /dev/[your disk name here]
e.g., fdisk -e /dev/disk5, then do the following from inside 'fdisk':
f 1