顯示具有 notes-work 標籤的文章。 顯示所有文章
顯示具有 notes-work 標籤的文章。 顯示所有文章

2015年6月8日 星期一

How to reduce/compact the vdi file size? (如何幫virtualbox的vdi檔減肥, 釋放出硬碟空間?)

只是自己的一些筆記....人老了...總是設過就忘了...Orz
寫下來,  以後比較好找...(明明就是懶的再爬一次文...XD)


         如果你跟我一樣, 平時以windows為主要作業系統, 有時又需要linux的環境, 除了安裝多重開機系統外(但只同一時間只能選一種作業系統使用), 另一種選擇就是安裝虛擬機(virtual machine); 常見虛擬機有VM ware 或是Virtual Box. 又因Virtualbox是freeware, 所以很自然地, 我就使用它啦! (我愛freeware~~:D)

        然而, virtualbox內的OS跑久了, vdi檔就會變得肥大, 即使在virtualbox內已經把用不著的肥大檔案刪除了, 仍不見vdi檔跟著變小;  virtualbox自己有提供VBoxManage的指令來重整夯實vdi檔, 不過對於ext檔案系統, Vbox Manage只會壓縮zeroblock, 所以想要有效幫vdi檔減肥, 得多一個步驟: 先將沒用到的block都標示成zero.

也就是說, 我們要作的就兩大步驟:
1. 用zerofree 來將沒有用到的block標示成0 (zeroblock),
2. 用 VBoxManage.exe 來把zeroblock壓縮.

因為我在vbox上跑的另一個系統是ubuntu, 所以以下也就依ubuntu來說明步驟.
1. 用zerofree 來將沒有用到的block標示成0 (zeroblock)
 
    (1) 在vbox上用iso檔開機
          我的方式是去下載ubuntu的iso檔, 然後把它mount到vbox的CD, 再次開機時, 它就自動從iso檔開機了, 它會問你是要試用或安裝ubuntu, 請選擇試用, 因為我們只是需要另一個系統來執行zerofree.

     mount the ubuntu iso file to vbox CD rom:


    (2)進到live CD ubuntu後, 開啟"terminal",
            a. install zerofree
               sudo apt-get install zerofree
 
b. mount the rootfs which you want to compress.
(a) you need to find your unbuntu device name. Mine is /dev/sda1.
(b) mount the ubuntu device to /mnt of LiveCD as read only.
sudo mkdir /mnt/sda1
sudo mount -n -o ro -t ext4 /dev/sda1 /mnt/sda1
c. execute the zerofree
sudo /mnt/sda1/usr/sbin/zerofree -v /dev/sda1
(-v to show the progress ).


2. 用 VBoxManage.exe 來把zeroblock壓縮.

 (1) find the location which you install the Vbox. Mine is under “c:\Program Files\Oracle\VirtualBox”. We need the path to find the VBoxManage.exe.

 (2) use VBoxManage.exe to compress the zeroblock.
C:\Users\JW\VirtualBox VMs>"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyvdi ubuntu12.04\ubuntu12.04.3.vdi compact
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

C:\Users\JW\VirtualBox VMs>"


in my case, the images size were below.
before: 92GB
after: 70GB







2014年3月21日 星期五

自製Ubuntu開機 + Clonezilla 備份還原USB碟

只是自己的一些筆記....人老了...總是作完就忘了...Orz
寫下來,  以後比較好找...(明明就是懶的再爬一次文...XD)

1. make a bootable ubuntu pen drive.
    (1) download the ubuntu iso file. http://www.ubuntu.com/download
    (2) download the install tool
            a. In windows, you could download the tools, "Universal USB installer".
                http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/   (or google "usb installer")
                It is a very useful tool. You could use it to create a bootable ubuntu USB pen drive, a bootable clonezallia USB pen drive, and so on.
                In the official web page, it will guide you how to install the iso to your pen drive.
            b. In ubuntu, you could use "startup disk creator" to make a bootable pen drive.
                Here is the detail steps. http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-ubuntu


2. Copy the clonezilla file system to your pen drive.
   (ref. http://kinmenalex.blogspot.tw/2011/08/ubuntu-usb-clonezilla.html)
    (1) download the clonezilla file system (zip file).
    (2) copy the file system of clonezilla to your bootable ubuntu pen drive.
             a. create /cloneusb/686
             b. extract the file system of clonezilla to /cloneusb/686/.
    (3) edit the booting menu
             a. edit /syslinux/txt.cfg. Add a label for clonezilla as following.
                =======================================================
                default live
                label live
                  menu label ^Try Ubuntu without installing
                  kernel /casper/vmlinuz.efi
                  append  file=/cdrom/preseed/ubuntu.seed noprompt cdrom-detect/try-usb=true persistent boot=casper initrd=/casper/initrd.lz quiet splash --

                label clonezilla-live-1.2.9-19-i686-pae menu label clonezilla-live kernel /cloneusb/686/live/vmlinuz append initrd=/cloneusb/686/live/initrd.img boot=live config noswap nolocales edd=on live-media-path=/cloneusb/686/live/ nomodeset noprompt ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="NONE" ocs_live_batch="no" ocs_lang="zh_TW.UTF-8" vga=788 toram=filesystem.squashfs ip=frommedia nosplash  

                label live-install
                  menu label ^Install Ubuntu
                  kernel /casper/vmlinuz.efi
                  append  file=/cdrom/preseed/ubuntu.seed noprompt cdrom-detect/try-usb=true persistent boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash --

                label check
                  menu label ^Check disc for defects
                  kernel /casper/vmlinuz.efi
                  append  noprompt cdrom-detect/try-usb=true persistent                                 boot=casper integrity-check initrd=/casper/initrd.lz quiet splash --

                label memtest
                  menu label Test ^memory
                  kernel /install/mt86plus

                label hd
                  menu label ^Boot from first hard disk
                  localboot 0x80
                =======================================================
     For now, you could reboot the system to try if this pendrive is working.

3. setup the clonezilla images to this pen drive
    (1) copy the clonezilla images to this pen drive
          Just find a place you like to store them. I put them under /cloneusb/686/home/partimg/.
    (2) verify the images checksums - "MD5sums"

4. verify clonezilla images in clonezilla system.


    

2013年10月9日 星期三

How to install Java plugin for chrome & firefox in ubuntu?

只是自己的一些筆記....人老了...總是設過就忘了...Orz
寫下來,  以後比較好找...(明明就是懶的再爬一次文...XD)


Test if java is working with your browser already.
http://www.java.com/zh_TW/download/testjava.jsp

If it is not working, you have to install & enable it.

Installation:

1. download Java from java website.
http://www.java.com/zh_TW/download/

2. untar the tarball (I untar it to /usr/java.)
# sudo mkdir -p /usr/java
# cd /usr/java
# sudo tar vzxf jre-7u40-linux-i586.tar.gz



Enabling:

Chrome:

1. create the symbolic link for chrome.
# sudo mkdir /opt/google/chrome/plugins
# cd /opt/google/chrome/plugins
# sudo ln -s /usr/java/jre1.7.0_40/lib/i386/libnpjp2.so

2. close all chrome windows/pages, and re-open it .
check if java plugin is enabled in chrome.
open "chrome://plugins/" in chrome.

open "http://www.java.com/zh_TW/download/testjava.jsp" to check if the java is working in chrome.

Firefox:

1. create the symbolic link for firefox
# cd /usr/lib/mozilla/plugins
# sudo ln -s /usr/java/jre1.7.0_40/lib/i386/libnpjp2.so

2. close all firefox windows/pages and re-open it.
check if java plugin is enabled in firefox.
工具->附加元件->外掛程式

open "http://www.java.com/zh_TW/download/testjava.jsp" to check if the java is working in firefox.



note: the official guide from java website: http://www.java.com/zh_TW/download/help/enable_browser_ubuntu.xml