Friday, August 19, 2011

Step 2: boot livedvd-amd64-multilib-11.2.iso from hard disk (with grub2)

After a few days experience of the gentoo livedvd run from usb, I think the usb drive should be saved for some other important data; I decided to copy the iso and run it from hard disk; usually a hard disk has large enough space, people could just copy all files inside /image.squashfs to a local partition, like the way on gentoo-wiki, but this computer assigned to me has a SSD drive default, has only 120G, furthermore, it's already partitioned long time ago, I don't have more space to back up all data on it and don't want to risk re-partition it; so I'd still like the way of loop mount iso on the fly, for saving disk space;

/dev/sda3       240277504   250068991     4895744   83  Linux
/dev/sda5       129341440   132855807     1757184   82  Linux swap / Solaris
/dev/sda6       132857856   152387583     9764864   83  Linux LABEL=UBUNTU
/dev/sda7       152389632   210980863    29295616   83  Linux LABEL=HOME
/dev/sda8       210982912   211372031      194560   83  Linux LABEL=DEBIAN

The ubuntu partition already has grub2 default installed and home partition has a lot of remaining space, so I mkdir /gentoo under /home, put livedvd-amd64-multilib-11.2.iso there, rename or hardlink a short name gentoo.iso there; extract kernel/initramfs from the iso and put into /boot of the ubuntu partition, create a new entry there and no need to install another grub;

Notice that grub2 (version 1.9*) has slightly different syntax with grub1 (version 0.9*):
  1. disk partition order, counter from 1, same as Linux partitions;
  2. better not to change (append entries) in grub.cfg directly, use /boot/grub/custom.cfg instead; because every time later ubuntu upgrade or install new kernels would call update-grub2 that would overwrite grub.cfg; you could change /etc/grub/40_custom (that support script smart calculation) or /boot/grub/custom.cfg on that ubuntu partition; here I use custom.cfg;
Gentoo-11 ~ # cat /mnt/sda6/boot/grub/custom.cfg
menuentry "Gentoo11-Live Linux-3.0.0 (on /dev/sda7 {gentoo/gentoo.iso})" {
	  linux (hd0,6)/boot/gentoo/gentoo aufs_mem=2G cdroot=/dev/sda7 cdroot_type=ext4 isoboot=gentoo/gentoo.iso vga=791 splash=silent,theme:livecd-10 console=tty1 quiet nodetect doload=ahci dox
	  initrd (hd0,7)/gentoo/gentoo-initramfs.gz

Compared to previous menuentry in syslinux.cfg, here I removed some unused parameters (like "root=/dev/ram0 init=/linuxrc" because that is the default, I think I should recommend the Gentoo-Ten team to remove that, but not sure if any other computer need it, at least my computer doesn't need it, it could boot, as granted; the only useful parameters here are:
  1. aufs_mem=2G, it means how large of tmpfs layered on top of squashfs by aufs; default it's 420M tmpfs, enough if you don't modify/install too many applications in live mode;
  2. cdroot=/dev/sda7, specify a parameter saves parsing during booting; specify cdroot_type the same way;
  3. isoboot=gentoo/gentoo.iso, you need to specify where do you save that iso inside that partition; it's required;
  4. nodetect doload=ahci dox; depends on if you know your hardware, if no idea, autodetect is best, but I know my hardware, specifying it could save booting time;
The default gentoo kernel/initramfs should work this way I thought originally, but it doesn't, I have to look at the init script and change it a little, here is the diff:

the initramfs is just cpio (newc format) + gz; extract and reconstruct in this way;
$ mkdir -vp gentoo-initramfs
$ zcat gentoo.igz |(cd gentoo-initramfs; cpio -d -i)
$ emacs -nw gentoo-initramfs/...; modify /init and /etc/init.scripts
$ (cd gentoo-initramfs/; find |cpio -H newc -o) |gzip -v9 >gentoo-initramfs.gz
$ (cd gentoo-initramfs/; find |cpio -H newc -o) |xz -v9 >gentoo-initramfs.xz
Gentoo-11 ~ # (cd /home/gentoo/; ls -lh gentoo-initramfs.*)
-rw-r--r-- 1 root root 9.8M Aug 16 02:25 gentoo-initramfs.gz
-rw-r--r-- 1 root root 7.5M Aug 15 17:50 gentoo-initramfs.xz
The latest xz (aka. lzma2) could save 20% over "gzip -v9";

Update: use "xz --check=crc32" instead, because some latest xz support "none,crc32,crc64,sha256" or more types of integrity check, default as crc64; the kernel xz dec is "xz embedded" that only support "none or crc32",  kernel may report XZ_OPTIONS_ERROR, you could use "xz -vl ..." to check it, read Documentation/xz.txt for more;
-=--:%%--F1  decompress_unxz.c   92% L364   (C/l Abbrev)

        case XZ_OPTIONS_ERROR:
                error("Input was encoded with settings that are not "
                                "supported by this XZ decoder");

# (cd gentoo-initramfs/; find |cpio -H newc -o) |xz --check=crc32 -v9 >../gentoo-initramfs.xz

Thursday, August 18, 2011

Step 1: boot livedvd-amd64-multilib-11.2.iso from a usbstick (without wiping all data)
Gentoo Linux releases 11.2 LiveDVD: run the iso from hard disk (hack on initramfs)

Recently Gentoo LiveDVD 11.2 was released on Aug 7, I'd like to try it but don't want to waste a blank DVD; the first thing I think is to run it on a usb; the only usb stick I have important data, don't want to try the dd way ("dd if=image.iso of=/dev/sdb")  in faq which will wipe out all data, looking up some documentation on its default isolinux/syslinux, finally I got this way working:

1) mount loop that livedvd-amd64-multilib-11.2.iso; mkdir /gentoo on the usb stick, copy all files inside the iso into that /gentoo;
2) rename its isolinux/ to syslinux/, and isolinux.cfg to syslinux.cfg; yes! thanks to great work, they're sharing the same configuration file syntax, what you need to do is just rename;
3) since we copied all the files from rootdir of cdrom to /gentoo of another disk(usb), the syslinux.cfg need to be adjusted; find out the "label gentoo-x86_64", change it to this;

label gentoo-x86_64
  MENU LABEL Gentoo ^x86_64
  kernel ../boot/gentoo
  append root=/dev/ram0 init=/linuxrc dokeymap aufs looptype=squashfs loop=/gentoo/image.squashfs cdroot initrd=../boot/gentoo.igz vga=791 splash=silent,theme:livecd-10 console=tty1 quiet subdir=gentoo

the "kernel" "initrd=" parameters was parsed by syslinux so it support "../" style relative path, so you could move the whole "/gentoo" to any name, under any path; but the "loop=" and some otherwhere was read by code inside the initramfs (here it's ../boot/gentoo.igz), there some hard code doesn't support relative path, so you must write its full absolute path, prepend "/gentoo" to image.squashfs, and append "subdir=gentoo";

for other label entries if you want to use, you could change the same way;

4) install syslinux bootsector to that usb stick (/dev/sdb has only one vfat partition):
  syslinux -d /gentoo/syslinux /dev/sdb1

Then you could boot it with this usb: find out label gentoo-x86_64 and boot it into LiveDVD 11.2;
The 2.8G iso file has packaged with linux kernel 3.0.0 and most a dozen of major and minor WM Environment (gnome3/kde4/xfce/lxde/windowmaker/openbox/fluxbox/awesome/xmbc/...), and all applications on each WM; just try and found which is your favorite? all the latest software;

livedvd-amd64-multilib-11.2.iso                      06-Aug-2011 07:12  2.8G

Sunday, May 29, 2011

从NAS端往下复制3GB文件,提示需要1hr, 计算一下速度是870KB/s; 这个可能是802.11a/b/g无线路由的问题,取网线来与路由器直连接,发现这个2009旧版DLink买的时候还是百兆Ethernet, 重新复制文件时提示需要20分钟,还是有点慢,计算速度是2600KB/s, 离百兆性能的极限11MB/s还差得远,常见8~9MB/s文件传输是没问题的;其实发现10年往后买的电脑的Ethernet都缺省是千兆了,NAS上的Ethernet也是千兆,而且是双网口,不如把空闲口与电脑的Ethernet直连;之后是网线有问题,反复auto-negotiation都显示100Mbit/s连接,换了一根质量好的 Ethernet Cable, 连接灯亮后花了约10秒neogotiation之后提示1000Mbit/s连接,再次复制文件提示3分钟。这个速度是18MB/s约是百兆性能的两倍,但离千兆的性能极限110MB/s还差得远哪

Copy files

"dstat -vn -N eth0,wlan0"

Saturday, April 23, 2011

grub2 default menu entry

Under Debian or Ubuntu: edit /etc/default/grub, add or uncomment these two lines


And, run update-grub again;

If you want more customized menu entries, you could add them under /etc/grub.d/40_custom, you also need to run update-grub manually; this file would get updated into /boot/grub/grub.cfg automatically in future when you got kernel updates;

Or you could use /boot/grub/custom.cfg directly (if not exist, create it); in this file you don't need to run update-grub; (if you want to know why, read /etc/grub.d/41_custom)

Monday, January 24, 2011


2010年在新加坡,亲身经历过新加坡的号召献血,不过新加坡的华文称为"捐血",用词不一样,但英文都是 Donate Blood, 但那次因为有事务太多没有去现场,但这个过程了解到他们是真正的义务献血,没有献血证,完全凭自愿,当然献血后的点心补充营养是不会少的。网上搜索到的一篇出自黄冈中心血站的 "新加坡捐血见闻 与我当时在那边本地报纸描写的差不多;

这次2011来到美国,刚开始上班两三周不多久,收到HR发的献血通知,这次是Stanford大学血液中心,斯坦福大学呢,采血卫生条件这样的基本问题应该是没得说,何况这次是安排移动献血车到公司门口停驻, BloodMobile, 一定要去一次。中午早早地吃过饭去,12点半准时到达,看到各位大叔大姐,献血之后在享受美味点心哪。我来到后面开始排队填表,等到我了,我觉得还是有点紧张、说我自己有点偏瘦,第一次献血能不能少点? "Can I donate less than normal?" 负责填表检查的大叔也看出我的紧张了,说没问题,又问我来美国多久了,我说刚满一个月,呵呵,大家都在善意地笑,大叔很严肃地继续问我来自哪里,我说 "China citizen, but coming from Singapore", 他说 Singapore 没问题,但是 China, 最后一次离开是什么时间,我如实回答后大叔说抱歉现在你还不能献血。最后有一位阿姨出来详细地解释 China 有一种(奇怪的)血液病,这个单词太专业了我没太听懂,说这种血液病在短期内无法检测出来,只能请我等离开China满三年后才能献血,也就是2012年。最后只能表示遗憾,友好地合影。 这就是斯坦福大学采血中心的移动献血车、今天来到公司门口

Tuesday, January 04, 2011

Zoom Quiet - 上海->新加坡->USA 标准的越狱路径哪! 尽早整理个攻略出来吧...Jan 3

Sunday, October 10, 2010

1 day in sentosa (圣淘沙一日游)


Siloso Beach - Sentosa - Singapore - 2010.10

Tuesday, August 17, 2010


使用 initrd (or initramfs) 固然有很多优点,但无可置疑地拖慢了启动速度,这方面编译内核的文档虽多,但我发现还是有不少人因曾经编译失败不能启动的体验而被吓住了,或者因保守起见编译了太多本机不需要的驱动程序,这样拖慢了编译内核的速度 (而且不管是模块形式还是内核形式,都是要么浪费了硬盘空间、要么就浪费了内存);

1. 硬盘驱动程序 (或曰主板驱动?)
怎样找到正确的硬盘驱动程序?有人的经验谈是确保选中 ahci, 其实这只是一种流行的选择,当然不能代表所有。发现正确驱动程序的方法是顺着 sysfs 找,这里面提供了非常丰富的信息:
    $ ls -lU /sys/block/sda
lrwxrwxrwx 1 root root 0 2010-08-17 21:03 /sys/block/sda -> ../devices/pci0000:00/0000:00:14.1/host4/target4:0:0/4:0:0:0/block/sda
发现了它在 /devices 下的真正节点是 "/devices/pci0000:00/0000:00:14.1" (而不在 host4 下,想想), 这时再一次访问
    $ ls -lU /sys/devices/pci0000:00/0000:00:14.1
其下 driver -> ../../../bus/pci/drivers/pata_atiixp 因此,此机器上正确的驱动程序是 pata_atiixp,
  找到了正确的驱动程序之后还有一个任务是在 menuconfig 阶段如何找到其对应哪一个菜单项?这个需要在源代码中搜索:
    $ find drivers/ -name Makefile |xargs grep -nw pata_atiixp
drivers/ata/Makefile:28:obj-$(CONFIG_PATA_ATIIXP)    += pata_atiixp.o
  不知道在内核哪个子目录的话就在根目录 find, 一般来说大概知道是在 drivers/ 子目录,省点时间, 搜索所有 Makefile 将结果传给 xargs grep -nw 搜索单词 pata_atiixp, 得到唯一的一个结果 是 CONFIG_PATA_ATIIXP, 这个也许你猜到了结果其实就是小写变大写,但实际中有很多驱动的模块名称与 CONFIG 配置项名称是不一样的。所以 find 搜索能保证一定能找到了 menuconfig 配置项;
  最后一步就是在 menuconfig 过程中,使用 "/" 键,调出搜索界面,输入 PATA_ATIIXP 搜索之,一般来说,就找到了准确的 pata_atiixp 驱动所在菜单项的位置。把它设置为内联编译 (inlined compiling)就可以了。
以当前硬件流行驱动一般都是SATA或者PATA,都在 Device Drivers \ SerialATA and Parallel ATA 目录,而且一般来说一个机器只需要一个此类驱动就足够了 (同时使用两种SATA硬件的还没见过),因此选上 pata_atiixp 之后, 其它选项皆禁用之。
2. 根文件系统
  大概调查一下 (df -Th), 判断一下 根文件系统的类型,是 ext4 还是 btrfs, 与上同理,也把它设置为内联编译。为了常用U盘可以加上FAT支持,其它文件系统皆禁用之。
(注意不要选内核NTFS, 真正要读写NTFS分区可以使用 ntfs-3g 项目全用户层 code 解决)

3. 从 /sys/class/net/... 出发,找到 eth0 的真正驱动程序,在源代码搜索 Makefile 找到配置项名称,在 menuconfig 找到菜单项,设为内联编译;其它无关网卡驱动皆清除之。


Saturday, August 07, 2010

Latest Tweet: L: Bencoolen Link N 1°18' 0'' / E 103°51' 0'' 萌古连商业中心 & 福禄寺 四面佛


福禄寺 四面佛
印度庙 Sri Krishnan Temple 正在举行大型庆祝140周年活动,对面观音堂佛祖庙固自门庭若市


Thursday, July 22, 2010

见到了 Dawn Song 和 周杰伦海外学人–宋晓东(dawn-song)/
  1. crquan 于 2010-07-21 4:52 pm
    今天到新加坡国大NUS算是亲眼见识了 Dawn Song 之 aggressive, 语速、以及思维转换之快皆非常人所能及也,在1个小时的Seminar里讲了三个普通Seminar的内容,其在UCBerkeley的最新研究是 webblaze, 在Web安全领域的最新Symbolic应用;并且相关 paper 又是其一贯的对security领域四大TOP1会议(IEEE S&P, Usenix security, ACM CCS, NDSS)皆灌水之

晚餐在 Bugis 才吃过, 得闻前方有一新加坡闻名小吃街,步行至与 Beach Road 有一条 Link 小径,两旁都是古式三层复式楼;只闻海南鸡饭、以及麻辣飘香、港汇茶点,食客都热情到自己帮忙把店家的桌子往外搬到行人街道,尚有余而不得座者;行间忽见不远处 Bugis 广场有排队长龙, 怕是又有什么大人物吧!走近看,竟然才知是周杰伦,排队者每人皆持两本唱片,黑皮不见其名,排队者约有上千人,等待上台亲笔签名;远处舞台之上有某人伏笔挥持;颇有神采;待良久,竟不能得见全貌;

Sunday, July 04, 2010

Latest Tweet: 今闻母校国防科大开设“天河计划”研究生国际暑期班(7月19日至8月6日),招生正式七十人、旁听四十人、由国际知名教授、全英文授课、云计算及无线前沿技术、费用全免、西部地区学校正式学员报销往返硬座火车票。报名截止7月10日。

    1).云计算和虚拟化技术(Prof. Kai Hwang)
    2).无线和移动网络(Prof. WEI WAYNE LI)
    3).高级软件工程(Prof. Haibin Zhu )


    1). Prof. Kai Hwang
Ph.D. in Electrical Engineering and Computer Science, 1972, UC, Berkeley, Berkeley, CA.

    2). Prof. WEI WAYNE LI

    3).Prof. Haibin Zhu


(同感于1help1@tektalk, 如能开放视频,做成类似于 MIT-Open-Web-Course, 就更精彩了!)天河计划/

Tuesday, June 29, 2010

Unwired 2010, 05-27, SMU Administration Building, Conference Hall

Tuesday, June 15, 2010

File:, Node: Double-Colon, Next: Automatic Prerequisites, Prev: Static Pattern, Up: Rules

4.13 Double-Colon Rules

"Double-colon" rules are rules written with `::' instead of `:' after
the target names. They are handled differently from ordinary rules
when the same target appears in more than one rule.

When a target appears in multiple rules, all the rules must be the
same type: all ordinary, or all double-colon. If they are
double-colon, each of them is independent of the others. Each
double-colon rule's commands are executed if the target is older than
any prerequisites of that rule. If there are no prerequisites for that
rule, its commands are always executed (even if the target already
exists). This can result in executing none, any, or all of the
double-colon rules.

Double-colon rules with the same target are in fact completely
separate from one another. Each double-colon rule is processed
individually, just as rules with different targets are processed.

The double-colon rules for a target are executed in the order they
appear in the makefile. However, the cases where double-colon rules
really make sense are those where the order of executing the commands
would not matter.

Double-colon rules are somewhat obscure and not often very useful;
they provide a mechanism for cases in which the method used to update a
target differs depending on which prerequisite files caused the update,
and such cases are rare.

Each double-colon rule should specify commands; if it does not, an
implicit rule will be used if one applies. *Note Using Implicit Rules:
Implicit Rules.

--zz-Info:(,36 行 --All-- 子文件

Monday, May 10, 2010

JVM, Longene in Linux Kernel [Was Re: 为什么不把JVM加入Kernel呢?(Why not add JVM into Kernel)]

Cheng Renquan

星期二 五月 11 14:17:48 CST 2010

2010/5/7 Liang Guo <bluestonechina at>:
> 在 2010年5月7日 下午4:47,Avanpak <slevin.van at>写道:

>> Linux下有很多Java应用,如openoffice,
>> 为什么不把JVM加入Kernel,让这些应用跑起来更顺畅呢?
>> There're many Java applications on Linux, such as openoffice.
>> Why not add JVM into Kernel, and let them run better.
> Why do you think JVM in kernel space is better in user space ?

我个人觉得:除了法律、GPL的要求之外,没有什么技术上的理由说 JVM 不可以放进内核,

我想真正唯一的理由是:谁去做它? 谁有能力、有需求的人士不妨可以去尝试,

当时 03,04 年我们还在 linuxsir 的内核区讨论 “把 XWindow 移进内核让它像
运行Windows图形一样快, 如何?”, 支持和反对者辩论了很久,支持者认为会提高性能
经常崩溃;这样的辩论在各 Linux 社区都时常可见,但都没什么结果,因为没有人真正

我们当时确实没有能力去实现 内核态XWindow 这么一件大工程,现在来看,内核模式设定
 KMS 可以被 内核接受,被各Linux发行版引用,其本质就是把一部分 XWindow代码移进了
内核态运行 (Xorg 的显卡驱动的一部分,), 证实了这个方向确实是可行的,

@Avanpak, 你说的内核态JVM是目的让 内核态直接能运行 Java应用程序的class 文件?
这样以后运行 Eclipse 确实应该快些,

位于 杭州 - 浙大网新 - 毛德操老师引领的 Longene 项目与此目的倒是有些类似,
让 Linux内核直接运行Windows的PE格式exe可执行程序,

初期版本的方案是内核模式的wine, 但0.3版以后实现有改变?其git仓库还是没变化,Jack能否发布点文档?


回到 JVM 和 Logene 问题本身,技术上没有什么不可以做的,有了需求,有了 motivation,
还要有人坚持不懈把它做出来才行,Avanpak 您愿意开始 内核JVM 工作吗?

> --
> Liang Guo

Cheng Renquan

关于邮件列表 Linux-kernel 的更多信息


Tuesday, March 30, 2010

Monday, March 08, 2010

Friday, March 05, 2010

suseuser@linux-2.6.33-uk> PAGER= git log --no-merges --pretty="%h %s" v2.6.30..v2.6.33 -- kernel/fork.c
fabf318 sched: Fix fork vs hotplug vs cpuset namespaces
9cd80bb do_wait() optimization: do not place sub-threads on task_struct->children list
6580807 ptrace: copy_process() should disable stepping
569b846 memcg: coalesce uncharge during unmap/truncate
1d61548 sched: Convert pi_lock to raw_spinlock
b69f229 block: Fix io_context leak after failure of clone with CLONE_IO
0cf55e1 sched, cputime: Introduce thread_group_times()
d99ca3b sched, cputime: Cleanups related to task_times()
8e7cac7 core: Fix user return notifier on fork()
1d51075 Correct nr_processes() when CPUs have been unplugged
322a2c1 futex: Move exit_pi_state() call to release_mm()
fc6b177 futex: Nullify robust lists after cleanup
801460d task_struct cleanup: move binfmt field to mm_struct
858f099 aio: ifdef fields in mm_struct
123be07 fork(): disable CLONE_PARENT for init
d899bf7 procfs: provide stack information for threads
1f10206 getrusage: fill ru_maxrss value
28b83c5 oom: move oom_adj value from task_struct to signal_struct
1c2fb7a ksm: fix deadlock with munlock in exit_mmap
9ba6929 ksm: fix oom deadlock
f8af4da ksm: the mm interface to ksm
c6a7f57 mm: oom analysis: Show kernel stack usage in /proc/meminfo and OOM log output
cdd6c48 perf: Do the big rename: Performance Counters -> Performance Events
e0e8173 CRED: Add some configurable debugging [try #6]
4ab6c08 clone(): fix race between copy_process() and de_thread()
f41d911 rcu: Merge preemptable-RCU functionality into hierarchical RCU
0753ba0 mm: revert "oom: move oom_adj value"
9c8a822 execve: must clear current->clear_child_tid
42c4ab4 itimers: Merge ITIMER_VIRT and ITIMER_PROF
9f498cc perf_counter: Full task tracing
933b787 mm: copy over oom_adj value at fork time
ed900c0 perf_counter: Log vfork as a fork event
b43f3cb headers: mnt_namespace.h redux
72a1de3 copy_process(): remove the unneeded clear_tsk_thread_flag(TIF_SIGPENDING)
2dff440 kmemcheck: add mm functions
60313eb perf_counter: Add fork event
226f62f perf_counter: Add a comm hook for pure fork()s
f7e8b61 function-graph: move initialization of new tasks up in fork
bbbee90 perf_counter: Ammend cleanup in fork() fail
6ab423e perf_counter: Propagate inheritance failures down the fork() path
e4cbb4e perf_counter: Move child perfcounter init to after scheduler init
a63eaf3 perf_counter: Dynamically allocate tasks' perf_counter_context struct
ad8d75f tracing/events: move trace point headers into include/trace/events
a8d154b tracing: create automated trace defines
0f48140 x86, ptrace: add bts context unconditionally
0793a61 performance counters: core code