使用Ubuntu Live CD在重装Windows系统时备份完整分区数据

C盘是一个128G SSD, windows在各种方法尝试均失败进不了系统时需要重装,但不确信C盘里还有哪些数据没有备份。

手头没有专业的备份软件,只有ubuntu live cd(USB),需要备份整个C盘,以防止以后想起来什么数据还能恢复出来

解决:使用dd命令

Ubuntu Live CD进入Terminal,首先找到windows分区挂载在哪里(sudo fdisk -l),然后:

dd if=/dev/hdx of=/dev/hdy
dd if=/dev/hdx of=/path/to/image.img

x和y是源分区和目标分区,这样的话,等待半个小时或者更久,会在目标分区产生一个128G的image文件,这就是整个分区的数据了

如果希望压缩的话(需要花费很久,但是可以把空白空间识别出来并去掉,产生的文件会小很多):

dd if=/dev/hdx | gzip > /path/to/image.gz

之后重装好了系统,在windows下,可以安装免费的OSFmount软件来把image文件挂载成一个分区,和正常物理分区一样正常使用。

 

举一个具体用过的例子:

sudo dd if=/dev/sda bs=100M conv=notrunc | gzip -c > /media/ubuntu/external_usb_harddrive/sda_image.gz

or: sudo dd if=/dev/sda bs=100M conv=notrunc of=/media/ubuntu/external_usb_harddrive/sda_image.img

Continue reading 使用Ubuntu Live CD在重装Windows系统时备份完整分区数据

快速了解未知远程linux主机基本概况

现有未知配置及环境的远程主机一台,希望了解基本信息。

//For some common linux distributions
//without using sudo

//CPU info
more /proc/cpuinfo
cat /proc/cpuinfo

//RAM info
more /proc/meminfo
free -m    //units in MB

//Linux Version
cat /proc/version

//Distribution Version
cat /etc/*release

//close all the process
kill -9 -1

//network related:
more /etc/resolve.conf
more /etc/hosts

//redhat:
more /etc/sysconfig/network-scripts/ifcfg-eth0

Continue reading 快速了解未知远程linux主机基本概况

Install KLEE on Ubuntu Server 13.04 x64 system (with LLVM)

Update Oct 2014: 

The original installation log was written in June 2013. At that time Klee project was hosted on http://klee.llvm.org, and their installation instruction was quite confused. Now they move the project to http://klee.github.io/.

It looks like that they have completely re-written the installation instructions on the new website, the procedure is very similar to the one I logged below, you can also refer to their official tutorial.

——————————————————–

I was trying to set up KLEE on Ubuntu 13.04 x64 server edition based on official KLEE guide: http://klee.llvm.org/GetStarted.html.

llvm-gcc and llvm 2.9 are necessary to KLEE.  Initially I tried to compile llvm-gcc from source code on my server, but it failed for some reason. I didn’t have time digging into it (error message is very similar to another user’s post at http://s1151.socode.info/question/508146694f1eba38a44c48e6) So I just use a binary version of llvm-gcc during my installation.

Notice I also use a text editor to edit one of the .cpp files (see comment in the code below) to avoid an error while compiling. I use ‘make -j ‘  to compile faster (if errors occur, please only use ‘make’).

#XL @ 2013.6.29
$ sudo apt-get install build-essential

#Install dependencies
$ sudo apt-get install g++ curl dejagnu subversion bison flex

#download llvm-gcc, I put it in home folder
$ cd ~
$ sudo curl -O http://llvm.org/releases/2.9/llvm-gcc4.2-2.9-x86_64-linux.tar.bz2  
$ tar xjvf llvm-gcc4.2-2.9-x86_64-linux.tar.bz2

#add path
$ echo "export PATH=$PATH:~/llvm-gcc4.2-2.9-x86_64-linux/bin" >> ~/.bashrc
$ echo "export PATH=$PATH:~/klee/Release+Asserts/bin" >> ~/.bashrc
$ echo "export C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu" >> ~/.bashrc
$ source ~/.bashrc

#download and install llvm
$ sudo curl -O http://llvm.org/releases/2.9/llvm-2.9.tgz
$ tar zxvf llvm-2.9.tgz
$ cd llvm-2.9
$ ./configure --enable-optimized --enable-assertions

$ vi ~/llvm-2.9/lib/ExecutionEngine/JIT/Intercept.cpp
# Use vi (or other text editor) to add this line 
# at the beginning of this cpp file: #include “unistd.h” 
# Otherwise the compiling process may fail

$ make -j $(grep -c processor /proc/cpuinfo)

$ cd ..
$ svn co -r 940 https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp stp
$ cd stp
$ ./scripts/configure --with-prefix=/home/$(whoami)/stp_install --with-cryptominisat2
$ make  -j $(grep -c processor /proc/cpuinfo) OPTIMIZE=-O2 CFLAGS_M32= install

$ cd ..
$ svn co http://llvm.org/svn/llvm-project/klee/trunk klee
$ cd klee
$ ./configure --with-llvm=/home/$(whoami)/llvm-2.9 --with-stp=/home/$(whoami)/stp_install
$ make -j $(grep -c processor /proc/cpuinfo) ENABLE_OPTIMIZED=1
$ make unittests

Continue reading Install KLEE on Ubuntu Server 13.04 x64 system (with LLVM)