2012年3月7日 星期三

tinycore on qemu


1. download qemu-windows
2. download tinycore 的 iso file
3. 用 qemu-img 來 create 一個 image file
    C:\> qemu-img create tinycore-tce.img 512M
4. 使用 qemu 來執行
    C:\> qemu -hda tinycore-tce.img -m 512 -cdrom tinycore-current.iso -boot d -net nic -net user,hostfwd=tcp:127.0.0.1:8008-:80 -vnc 127.0.0.1:0 -daemonize


1. -hda tinycore-tce.img
   使用 tinycore-tce.img 作為 /dev/hda

2. -cdrom tinycore-current.iso
    使用 tinycore-current.iso 作為 CDROM

3. -boot d
    使用 CD 作為 boot

4. -m 512
    memory size

  -L : bios location
  -m : memory size (Mbyte)
  -boot : boot device  floppy(a), hard disk(c), CD-ROM(d)
  -fda : floppy image
  -hda : hard disk image
  -cdrom : CD-ROM image


-net nic -net user,hostfwd=tcp:127.0.0.1:8008-:80

Create a virtual network interface in “UserMode”, and port forward from port 80 on the dynamically allocated IP address on the virtual machine to port 127.0.0.1:8008 (which means it’s only accessible from the host machine, not from any other machine on the network)

-vnc 127.0.0.1:0 -daemonize

isoLinux creation


What is ISOLINUX?

ISOLINUX is a boot loader for Linux/i386 that operates off ISO 9660/El Torito CD-ROMs in "no emulation" mode. This avoids the need to create an "emulation disk image" with limited space (for "floppy emulation") or compatibility problems (for "hard disk emulation".)

[edit]How Can I Make a Bootable CD With ISOLINUX?

  • Make sure you have a recent enough version of mkisofs. I recommend mkisofs 1.13 (distributed with cdrecord 1.9), but 1.12 might work as well (not tested). Binary versions for Windows can be found on the web.
  • Download Syslinux
  • Create a directory called "CD_root". This is the ISO image master file tree
    • Copy all files you want to have on the CD into this directory
  • Create a directory called "isolinux" underneath the directory "CD_root"
  • Create directories "images" and "kernel" underneath the directory "CD_root"
    • Copy any floppy images you want to boot into "images"
    • Copy "memdisk/memdisk" from the Syslinux archive into "kernel"
  • Use the following command to create your ISO image:
mkisofs -o output.iso \
   -b isolinux/isolinux.bin -c isolinux/boot.cat \
   -no-emul-boot -boot-load-size 4 -boot-info-table \
   CD_root
The file boot.cat will be automatically created.

[edit]Notes about building

When building an ISO with ISOLINUX please understand that ISOLINUX
  • only uses the plain ISO 9660 filenames, i.e. it does not support Rock Ridge or Joliet filenames. It can still be used on a disk which uses Rock Ridge and/or Joliet extensions, of course. Under Linux, you can verify the plain filenames by mounting with the "-o norock,nojoliet" option to the mount command.
  • does support long (level 2) ISO 9660 plain filenames, so if compatibility with short-names-only operating systems like MS-DOS is not an issue, you can use the "-l" or "-iso-level 2" option to mkisofs to generate long (up to 31 characters) plain filenames.
  • does not support discontiguous files, interleaved mode, or logical block and sector sizes other than 2048. This should normally not be a problem.
ISOLINUX is by default built in two versions, one version with extra debugging messages enabled. If you are having problems with ISOLINUX, I would greatly appreciate if you could try out the debugging version (isolinux-debug.bin) and let me know what it reports.

[edit]Path resolution

ISOLINUX resolves pathnames the following way: A pathname consists of names separated by slashes, Unix-style. A leading slash means it searches from the root directory; otherwise the search is from the isolinux directory (think of this as the "current directory".) . and .. in pathname searches are not supported. The maximum length of any pathname is 255 characters.
ISOLINUX will search for the config file directory in the order /boot/isolinux, /isolinux, /. The first directory that exists is used, even if it contains no files. Therefore, please make sure that these directories don't exist if you don't want ISOLINUX to use them.

[edit]Can I boot other operating systems with ISOLINUX?

Starting in version 1.65, ISOLINUX supports booting disk images of other operating systems. However, this feature depends on BIOS functionality which is apparently broken in a very large number of BIOSes. Therefore, this may not work on any particular system. No direct workaround is possible; if you find that it doesn't work please complain to your vendor and indicate that "BIOS INT 13h AX=4C00h fails." Note that you can use MEMDISK as an alternative; MEMDISK is not affected by this problem, but limits the size of the disk images, since it has to load them into memory.
To boot DOS, or other real-mode operating systems (protected-mode operating systems may or may not work correctly), using ISOLINUX, you need to prepare a disk image (usually a floppy image, but a hard disk image can be used on most systems) with the relevant operating system. This file should be included on the CD-ROM in the /isolinux directory, and have a .img extension. The .img extension does not have to be specified on the command line, but has to be explicitly specified if used in a kernel statement in isolinux.cfg.
For a floppy image, the size of the image should be exactly one of the following:
 1,222,800 bytes   1200K floppy (standard 5.25") 
 1,474,560 bytes   1440K floppy (standard 3.5") 
 2,949,120 bytes   2880K floppy (enhanced 3.5") 
Any other size is assumed to be a hard disk image. In order to work on as many systems as possible, a hard disk image should have exactly one partition, marked active, that covers the entire size of the disk image file. Even so, hard disk images are not supported on all BIOSes.

[edit]ISOLINUX and Windows install disks

ISOLINUX supports the use of so-called "CD-ROM boot sectors", which are used primarily by Microsoft Windows NT (including 2000 and XP.) "CD-ROM boot sectors" need to end in the extension .bin. Some people have used this together with Windows install disks to create combination Windows/Linux install CDs.
Please see the following message from the SYSLINUX mailing list for some tips: http://www.zytor.com/pipermail/syslinux/2002-October/001135.html

[edit]What to do when nothing works...

Unfortunately, in what seems to be par for the course when dealing with contemporary BIOSes, there are still a fair number of (mostly older) systems on which ISOLINUX simply will not work. On those systems, you may want to try Smart BootManager, a boot floppy which contains a standalone El Torito stack.

Windows Mount CDRom: WinCDEmu,還可以製作 Windows drivers 與 RAM Disk

http://wincdemu.sysprogs.org/

2012年3月6日 星期二

重要: Windows 的 fsutil 可以用來 USN

執行 coLinux

1. 安裝後,使用  config 檔執行
    colinux-daemon @example.conf  (example.conf 為 config 檔)

2. config 檔可以有多個,或是在命令列中直接加上參數
    colinux-daemon @example.conf @overrider.conf mem=32

3. colinux-daemon.txt :可以看成執行 coLinux 的方式
      該檔中也包含所有的參數

4. create swap file:
   a. copy 舊的 swap image file:可以
   b.

kernel
initrd
mem
cocon
cursor
color
cobdX=
    block device image file
    :image 檔所在的地方
             在一些需要的地方,會自動加上 \DosDevices\
    若打開 verbose output,coLinux 會印出一些關於 configured 與 canonized device paths 的訊息
      而 "\DosDevice\C:\..." 會印出 "\??\C:\..." - windows internal name.
   
    可以是使用 標準 \Device\HarddiskX\PartitionY 格式的 partition 
        Harddisk X 由 0 開始,Partition 由 1 開始.
            Be carefully with these accesses, mount it read only at the first time and check the contains.
        不要在 Windows 會使用時,mount 一個 partition。
        Partitions should only use non beginners to make a "dualboot" runable.


Examples:
cobd0=rootfs.img
cobd1=C:\temp\swapfs.img
cobd2=\Device\Cdrom0



scsiX=,,
       使用 block device image file.
:是 'disk' or 'cdrom'.
: image file 的檔名
        需要是一整個 disk 的 image (/dev/hda),而非只是一個 partition 的 image (dev/hda1).
Linux kernel 會 scans for partition tables, fdisk is usable.

可以是 a raw disk drive, with format  "\\.\PhysicalDriveX", 
                where X starts with 0 for first harddisk.
        Be carefully with these configs, you risk datas on your drive C:.
Don't mount a partition that is in use on windows side!

can optional the size in megabytes. 
          The host driver will create the storage device file if it does not exist.
BE VERY CAREFULL  with this parameter, as it can increase/decrease the
size of a file as well!

For scsi0 the the device inside coLinux is /dev/sda, if type is cdrom or the image file is a part of partition self (all current images).
If file has partition tables, the devices /dev/sda1, /dev/sda2, ... are usable.

Examples:
scsi0=disk,file.img
scsi1=cdrom,file.iso

2012年3月4日 星期日

andLinux 與 coLinux: 似乎都是在 Windows 上直接執行 Linux

ciLinux 網路設定

可以  reference: http://colinux.wikia.com/wiki/Network

CoLinux的网络配置

昨天的说到配置CoLinux在Windows下面启动另一个分区里面的Linux,但是网络配置只是使用了最简单的slirp模式。
CoLinux的网络配置共有3种:
  • slirp:最简单的模式,CoLinux内可通过Windows系统访问网络,但外部不能直接访问Linux,如果需要访问,需要做端口映射。
  • tuntap:在Windows中虚拟一块网卡,Linux与Windows通过该网卡通讯,Linux不能直接访问外部网络,必须在Windows上配置路由和NAT,或者简单使用Windows的Internet连接共享ICS。
  • pcap-bridge:必须有一块连接网络的网卡才能使用,另外需要安装WinPCap软件。该模式将一块实际网卡模拟出另一块网卡并连接到网络,对外部看来,就好像实际上有两台不同机器一样。
  • ndis-bridge:与pcap-bridge模式一样,不过不使用WinPCap软件接口而是通过Windows的NDIS接口层模拟网卡。
下面是配置方式:
  • slirp模式
slirp模式的配置最简单,在CoLinux的配置里面:
eth0=slirp
就可以了。它的具体参数如下:
ethX=slirp,,
可以用来指定网卡MAC地址,也可以直接留空
用来指定端口映射,格式为tcp|upd:hostport:linuxport[:count],将Windows的tcp或者udp的hostport开始的count个端口映射到Linux系统的linuxport开始的count个端口上,如果要添加多个映射,用逗号分隔。如
eth0=slirp,,tcp:2222:22/tcp:4000:80:3
将Windows的端口2222,4000,4001,4002映射到Linux的端口22,80,81,82上。
  • tuntap模式
这个模式比较麻烦,实际上是虚拟了一块网卡和CoLinux相连,所以,Windows和Linux可以直接连接,但是Linux想要访问外网,则需要配置网关或者ICS。
配置参数:
ethX=tuntap,,
是MAC地址,可以不填
是使用Tuntap网卡名字,也可以不填,这样CoLinux会使用第一块Tuntap网卡。
但是tuntap网卡是可以安装多块的,如果需要指定某块具体的虚拟网卡,则需要指定这个名字。
正常安装CoLinux以后,Windows里面会多出来一块网卡,嗯,名字叫什么忘记了:)
进入Windows网上邻居属性界面,查看网络连接就可以看到这块网卡。在这里可以对网卡改名,比如我改成了“Tap-colinux”,然后在参数里面指定这个名字就可以使用这块虚拟网卡。
如果名字里面有空格,则必须使用双引号"括起来。
  • pcap-bridge和ndis-bridge模式
这两个模式实际上是差不多的,除了pcap需要WinPCap软件支持以外,事实上应该ndis模式会快一点?(猜的,没测试过)
这两个模式是先有的pcap,后来才加上了ndis模式,毕竟不需要额外装个软件还是比较容易接受一点的。
具体配置参数:
ethX=pcap-bridge|ndis-bridge,,,
指定要在哪一块真实网卡上模拟虚拟网卡,这个名字也就是在Windows网上邻居属性界面里,查看网络连接时看到的名字(在那里也可以改名的),这个名字不能省略,否则网络跑不起来的。
而且需要注意的是,这块网卡必须要连通网络,否则的话,这个两个模式都不能用。
最后需要注意的是,在一些无线网卡上,这两个模式无法运作。具体原因好像是网卡只接受发到真实网卡的包,其他包直接不要还是怎么的,总之是不能使。(顺便说一句,我的无线网卡就不行,哭啊)
还是MAC地址,可省略。
指定是否工作在sniffer模式下,如果是promisc模式,则能够收到不是发到这块虚拟网卡的网络包,也就可以使用一些sniffer软件了。而nopromisc模式则正好相反,不能使用sniffer软件。

  • 好了,现在说说我怎么配的吧。
昨天的配置文件里面使用的是slirp模式,并且将2222映射到22端口。
然后我先试了下ndis-bridge模式,可惜的怎么都不行,我的无线网卡恐怕是不能支持这种模式了。
最后还是使用tuntap模式:
eth0=tuntap,,02:00:00:00:00:02
然后,去无线网卡属性里面,“共享”页面,打开ICS,指定对Tap-colinux网卡共享网络,这样就可以了。

  • 最后,再点题外话。
这里没有说在Linux下面怎么设置网络,其实就和普通网卡一样设置就好了。
我没有做什么特别的设置,Debian起来以后,自己认出网卡,然后dhcp获得IP,一切就好了。
slirp模式下CoLinux会负责分配ip的,tuntap模式下,ICS也会分配。
如果使用ndis或者pcap模式,它实际上就相当于是另一台机器上的一块网卡一样,家里的无线?路由器自然会负责给它分配IP的。

=========================================
Choose networking method(s) to install. Currently there are three choices:
  1.  Slirp - The simplest way to use networks in coLinux. 
    • This runs as user application on the Windows host and needs no changes on the host networks. 
    • Slirp is a good choice for dialup networks and WLAN cards.
    • Slirp use all times the current outgoing interface and forwards (NAT) networking from linux to the internet world.  Slirp is a virtual Gateway for all outgoing TCP and UDP connections (no IMCP, no ping).
    • Standard installation works as firewall to your linux.  It means, you can not connect from windows side to your linux.  To allow incomings from host system to linux, must additional configure 'redirections'.
    • Slirp has a DHCP-Server for linux side.  To use slirp, edit your CFG file and set "slirp" as first parameter.  Inside linux use DHCP-Client to get your network configuration.
  2. TAP driver - This method installs a virtual network adapter that is typically a separate network between Linux guest and Windows host.
    • This can then be either shared or bridged with a physical network connection. 
      • Note that this requires Internet Connection Sharing or Bridging (Windows XP or higher) or a 3rd party Internet connection sharing application.
    • The TAP method autmatically chooses the TAP first TAP adapter it finds, if you have multiple TAP WIN32 devices, you can specify the specific adapter by name (for sample "TAP-Colinux").
  3. Bridging - This method allows the Cooperative Linux network interface to directly interoperate with one of your built in networking interfaces.
    • You'll need to edit the configuration file to reflect that type "ndis-bridge" and the 'name' parameter needs to be set to a substring of the network connection name that you will be bridging with (e.g. "Local Area Connection").
    • Bridging does not working with WiFi cards.

Tun/Tap on Windows


tuntap for windows
1. Tun: 似乎是 layer 3
2. Tap: 似乎是 layer 2

tuntap driver 主要是在 OpenVPN project 中

tuntap driver 包含兩個檔案
1. tap901.sys: driver 本身
2. .inf 檔:OemWin2K.inf

要安裝在 windows 中需要有 Microsoft 的 DevCon(Device Console)檔,OpenVPN 有包含該檔,但改名過,稱 tapinstall

尚有一個 .cat 檔案

================================
1. install interface
c:\> DevCon install OemWin2k.inf TAP0801
2. enable interface and set static IP
c:\> netsh interface ip set address static 10.3.0.1 255.255.255.0
replace with the connection name of the tap driver in the Control Panel




尚有兩個檔案
1. addtap.bat:似乎是安裝 tap driver
2. deltapall.bat:會將所有的 tap drivers 全部移除,若想要一個一個移除,需使用 Windows 本身 device manager