1. 使用超級使用者登錄, 事先安裝好 squashfs-tools
sudo su
apt-get install squashfs-tools
如果要製作 Grub2 boot CDROM時, 需要安裝 xorriso
apt-get install xorriso
2. 製作 4G 映像檔
dd if=/dev/zero of=ubuntu.img bs=1k count=1 seek=3999999
p.s. 該映像檔案(ubuntu.img)盡可能放在 ext3 或 ext4 系統上, 速度會比較快, 千萬不要放在 ntfs 上(有可能在操作 unsquashfs 時, 因速度慢, 造成當機的假像).
3. 轉換成 ext4 格式映像檔
mkfs.ext4 ubuntu.img
4. 掛載檔案系統, 進入工作目錄
mkdir rootfs
mount -o loop ubuntu.img rootfs
cd rootfs
5. 解出在 CDROM 上的 squashfs 檔案系統, 會自動產生 squashfs-root
unsquashfs /cdrom/casper/filesystem.squashfs
6. 複製網路設定檔 hosts, resolv.conf
cp /etc/hosts squashfs-root/etc
cp /etc/resolv.conf squashfs-root/etc
7 bind /dev, 並 chroot
mount --bind /dev squashfs-root/dev
chroot squashfs-root
8.掛在系統特殊目錄
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts
9. 加加減減 apt-get install, 或 apt-get purge
我想增加的 package計有
squashfs-tools
xorriso
bareftp
proftpd
gerbv
qcad
freemat
geany
apache2
php5
mysql-server
php5-mysql
php5-curl
php5-sqlite
php5-sybase
php5-gd
qemu
10. 刪除不必要檔案, 並退出 chroot
rm -f /root/.bash_history
rm -f /etc/hosts
rm -f /etc/resolv.conf
rm -f /tmp/*
rm -f /var/tmp/*
apt-get clean
umount /dev/pts
umount /sys
umount -lf /proc
exit
umount -lf squashfs-root/dev
11.產生iso工作目錄,並準備製作成Ubuntu所需的檔案放入casper目錄內
mkiso /iso
mkdir /iso/casper
mkdir /iso/boot
mkdir /iso/boot/grub
cp /cdrom/casper/initrd.lz /iso/casper
cp /cdrom/casper/vmlinuz /iso/casper
cp /cdrom/.disk /iso
mksquashfs squashfs-root /iso/casper/filesystem.squashfs
chroot squashfs-root dpkg-query -W --showformat='${Package} ${Version}\n' > /iso/casper/filesystem.manifest
12. 編輯 /iso/boot/grub/grub.cfg
menuentry "Remaster Ubuntu" {
linux /casper/vmlinuz boot=casper locale=zh_TW.UTF-8 quiet splash
initrd /casper/initrd.lz
}
13 將 /iso目錄轉換,產生可開機CDROM映像檔
grub-mkrescue -o new.iso /iso
14.如有需要將new.iso燒成cdrom或DVD或使用qemu來測試
qemu -boot d -cdrom new.iso
2011年4月16日 星期六
使用 grub2 boot Ubuntu CDROM
1. apt-get install xorriso
2. 產生工作目錄 iso
3. 在工作目錄建立兩個目錄 boot 及 casper
4. 在 boot 內產生 grub 目錄, 編輯 grub.cfg, 放到 iso/boot/grub 內
5. 將 vmlinuz, initred.lz, filesystem.squashfs,filessystem.manifest 放進 iso/casper 目錄內
6. 執行 grub-mkrescue -o cdrom.iso iso
7. grub.cfg 內容範例:
menuentry "Ubuntu" {
linux /casper/vmlinuz boot=casper locale=zh_TW.UTF-8 quiet splash
initrd /casper/initrd.lz
}
2. 產生工作目錄 iso
3. 在工作目錄建立兩個目錄 boot 及 casper
4. 在 boot 內產生 grub 目錄, 編輯 grub.cfg, 放到 iso/boot/grub 內
5. 將 vmlinuz, initred.lz, filesystem.squashfs,filessystem.manifest 放進 iso/casper 目錄內
6. 執行 grub-mkrescue -o cdrom.iso iso
7. grub.cfg 內容範例:
menuentry "Ubuntu" {
linux /casper/vmlinuz boot=casper locale=zh_TW.UTF-8 quiet splash
initrd /casper/initrd.lz
}
2011年4月3日 星期日
Grub 2 + memdisk
從舊版 Grub (ver < 0.97) 升級到 Grub 2 後, memdisk 也必須升級, 否則會不正常.
UBuntu 9.1 已經使用改用 Grub 2, 使用其 (Ubuntu.iso) cdrom 便可安裝了
並且在 grub.cfg 中的一些設定也需跟著修改
例如 kernel 須改為 linux16, initrd 須改為 initrd16 才可使用舊的 floopy image 來開機
另外 Partition 數字由 1 開始數, 需要注意! Disk 仍維持由 0 開始數
menuentry "Grub 2 Floopy Image Boot" {
root (hd0,1)
linux16 /boot/memdisk
initrd16 /boot/disk2880.img
}
參考 Memdisk 說明書網址:
http://syslinux.zytor.com/wiki/index.php/MEMDISK
UBuntu 9.1 已經使用改用 Grub 2, 使用其 (Ubuntu.iso) cdrom 便可安裝了
並且在 grub.cfg 中的一些設定也需跟著修改
例如 kernel 須改為 linux16, initrd 須改為 initrd16 才可使用舊的 floopy image 來開機
另外 Partition 數字由 1 開始數, 需要注意! Disk 仍維持由 0 開始數
menuentry "Grub 2 Floopy Image Boot" {
root (hd0,1)
linux16 /boot/memdisk
initrd16 /boot/disk2880.img
}
參考 Memdisk 說明書網址:
http://syslinux.zytor.com/wiki/index.php/MEMDISK
Grub 2 初探
Grub 2 的設定檔共有 1 個目錄及 1 個共同設定檔案:
目錄在 /etc/grub.d 包含好幾個規劃好的設定檔, 看其命名應該就能體會其用意, 另外一個共同檔案則是 /etc/default/grub, 執行 sudo update-grub 後, 將會自動產生 grub.cfg, 並將它放在 /boot/grub 目錄內
一般如果要修改,或增加 menuentry, 可以加入到 /etc/grub.d/41_custom 檔案內, 再執行 update-grub 來變更設定
另外 Grub 2 多了 loopback device, 可以用以提取檔案內容, 讓後面的 linux 或 initrd 來使用. 是一相當實用的功能, 以下例子
menuentry "Ubuntu 10.10" {
# set root directory to disk0, 2nd patition
root (hd0,2)
# define a loopback device as loop, point to file: /boot/ubuntu.iso
loopback loop /boot/ubuntu.iso
#grab the linux kernel from loopback device (loop)
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/ubuntu.iso ro splash quiet locale=zh_TW.UTF-8
#grab the initial ram disk from loopback device (loop)
initrd (loop)/casper/initrd.lz
}
參考 Grub 2 說明書網址:
http://www.gnu.org/software/grub/manual/grub.html#Introduction
目錄在 /etc/grub.d 包含好幾個規劃好的設定檔, 看其命名應該就能體會其用意, 另外一個共同檔案則是 /etc/default/grub, 執行 sudo update-grub 後, 將會自動產生 grub.cfg, 並將它放在 /boot/grub 目錄內
一般如果要修改,或增加 menuentry, 可以加入到 /etc/grub.d/41_custom 檔案內, 再執行 update-grub 來變更設定
另外 Grub 2 多了 loopback device, 可以用以提取檔案內容, 讓後面的 linux 或 initrd 來使用. 是一相當實用的功能, 以下例子
menuentry "Ubuntu 10.10" {
# set root directory to disk0, 2nd patition
root (hd0,2)
# define a loopback device as loop, point to file: /boot/ubuntu.iso
loopback loop /boot/ubuntu.iso
#grab the linux kernel from loopback device (loop)
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/ubuntu.iso ro splash quiet locale=zh_TW.UTF-8
#grab the initial ram disk from loopback device (loop)
initrd (loop)/casper/initrd.lz
}
參考 Grub 2 說明書網址:
http://www.gnu.org/software/grub/manual/grub.html#Introduction
2010年12月17日 星期五
使用 php winbinder 寫一個計算檔案的 MD5 碼
< ?php
include "winbinder.php";
define("IDC_STATUSWIN", 101);
define("IDC_TEXTWIN", 102);
define("ID_OPEN" , 201);
define("ID_CLOSE", 202);
function process_main($window, $id)
{
switch($id) {
case ID_OPEN:
$filename = wb_sys_dlg_open($window, "Choose a file", array(array("All files", "*.*")) );
if(file_exists($filename) )
{
$sn="S/N: ".md5_file($filename);
wb_set_text(wb_get_control($window,IDC_TEXTWIN) , $filename);
wb_set_text(wb_get_control($window,IDC_STATUSWIN), $sn );
}
break;
case IDCLOSE : // IDCLOSE is predefined
case ID_CLOSE: wb_destroy_window($window); break;
}
}
$mainwin = wb_create_window(null, AppWindow,"PHP " . PHP_VERSION, WBC_CENTER, WBC_CENTER,500,100);
wb_create_control($mainwin, Menu,
array(iconv('big5','utf-8',"檔案-&File"),
array(ID_OPEN ,iconv('big5','utf-8',"開啟-&Open") , NULL, "" ,"Ctrl+O"), null,
array(ID_CLOSE,iconv('big5','utf-8',"關閉-&Close"), NULL, "" ,"Ctrl+X")
)
);
wb_create_control($mainwin, Label ,"Choose a file" ,1, 10, 290, 80, IDC_TEXTWIN);
wb_create_control($mainwin, StatusBar,"MD5:" ,0, 0, 0, 0, IDC_STATUSWIN);
wb_set_handler($mainwin, "process_main");
wb_main_loop();
?>
include "winbinder.php";
define("IDC_STATUSWIN", 101);
define("IDC_TEXTWIN", 102);
define("ID_OPEN" , 201);
define("ID_CLOSE", 202);
function process_main($window, $id)
{
switch($id) {
case ID_OPEN:
$filename = wb_sys_dlg_open($window, "Choose a file", array(array("All files", "*.*")) );
if(file_exists($filename) )
{
$sn="S/N: ".md5_file($filename);
wb_set_text(wb_get_control($window,IDC_TEXTWIN) , $filename);
wb_set_text(wb_get_control($window,IDC_STATUSWIN), $sn );
}
break;
case IDCLOSE : // IDCLOSE is predefined
case ID_CLOSE: wb_destroy_window($window); break;
}
}
$mainwin = wb_create_window(null, AppWindow,"PHP " . PHP_VERSION, WBC_CENTER, WBC_CENTER,500,100);
wb_create_control($mainwin, Menu,
array(iconv('big5','utf-8',"檔案-&File"),
array(ID_OPEN ,iconv('big5','utf-8',"開啟-&Open") , NULL, "" ,"Ctrl+O"), null,
array(ID_CLOSE,iconv('big5','utf-8',"關閉-&Close"), NULL, "" ,"Ctrl+X")
)
);
wb_create_control($mainwin, Label ,"Choose a file" ,1, 10, 290, 80, IDC_TEXTWIN);
wb_create_control($mainwin, StatusBar,"MD5:" ,0, 0, 0, 0, IDC_STATUSWIN);
wb_set_handler($mainwin, "process_main");
wb_main_loop();
?>
2010年12月13日 星期一
Windows7 建立一個隱藏目錄防君子不防小人
1. 開啟 dos 視窗, 先建立一個目錄: secrete..\
mkdir secrete..\
2. 將要隱藏的檔案放到目錄 secrete..\
3. 同一資料夾下再建立一個相同名稱的目錄
mkdir secrete
4. 然後將 secrete 隱藏起來
attrib +h secrete
則 secrete..\ 目錄下的東西, 在 windows7 會以為是 secrete 內的東西, 因而消失不見了
5. 除非用 dos 視窗將 secrete 目錄刪除, windows7 才可以看到 secrete..\ 下的內容
神奇吧!
WindowsXP 應該也可以!
mkdir secrete..\
2. 將要隱藏的檔案放到目錄 secrete..\
3. 同一資料夾下再建立一個相同名稱的目錄
mkdir secrete
4. 然後將 secrete 隱藏起來
attrib +h secrete
則 secrete..\ 目錄下的東西, 在 windows7 會以為是 secrete 內的東西, 因而消失不見了
5. 除非用 dos 視窗將 secrete 目錄刪除, windows7 才可以看到 secrete..\ 下的內容
神奇吧!
WindowsXP 應該也可以!
訂閱:
文章 (Atom)