本文出自:pendrivelinux


Along with the final release of Ubuntu 8.04 came a bug which broke the persistence feature, ultimately dropping the user to a shell when booting with the persistent option. As it turns out, the problem lies with permissions being set to 755 for the cow device (strangely enough the prereleases did not have this problem). In the following tutorial, I will show you how to quickly fix the problem. This is the same process we used to create the custom initrd.gz file that is distributed with our Ubuntu, Kubuntu and Xubuntu 8.04 Hardy Heron related USB flash drive installation tutorials.

 

Note: There is no need to proceed with this tutorial if you have used any of our Ubuntu, Kubuntu or Xubuntu 8.04 USB installation tutorials. This process is being provided for advanced users who want to know what was changed and prefer to attempt the fix themselves.

Fixing Ubuntu 8.04 Casper script for Persistence:

  1. Download Ubuntu 8.04 and burn to a CD/DVD
  2. Restart your PC from the CD/DVD
  3. Open a terminal and type sudo su (to become root)
  4. Type mkdir /projectinit (to make our project directory)
  5. Type cd /projectinit (to change to the project directory)
  6. Type gzip -dc /cdrom/casper/initrd.gz | cpio -i (to extract the initrd.gz)
  7. Type gedit scripts/casper (to edit the casper script)
  8. From gedit, find the following section of code:

    mount ${cowdevice} -t ${cow_fstype} -o rw,noatime,mode=755 /cow

  9. From the line of code, remove ,mode=755. The resulting code should appear as follows:

    mount ${cowdevice} -t ${cow_fstype} -o rw,noatime /cow || panic "Can not mount $cowdevice on /cow"

  10. Save the changes to update the casper script
  11. Type find . | cpio -o -H newc | gzip -9 > initrd.gz (to zip the new initrd.gz file)
  12. Then you can copy the new initrd.gz file to your usb flash drive, replacing the old file (or rebuild the iso to include the new file)

That concludes this simple tutorial on fixing Ubuntu 8.04 for Persistence.


20090113補充:

實作

ubuntu 原先在設計時就已有支援這個功能,只要usb有一個槽名稱設為casper-rw,且在開機參數加入 persistent 即可啟動該功能。
但是,這個功能有個bug,他在啟動核心自動掛載第二磁區時,多了一個錯誤的參數,導致每次啟動persistent功能時,掛載casper-rw磁區都會失敗。
以下是示範如何修改這個bug:

1.把upc目錄下initrd.gz依下列方式解開:
cp /media/NetbossLive/initrd.gz .
gunzip initrd.gz
mv initrd initrd.img
mkdir initrd
mv initrd.img initrd/
cd initrd
cpio -i --make-directories < initrd.img
rm initrd.img

2.修改 scripts/casper bug:
vi scripts/casper
搜尋 "mode"
[quota]
mount ${cowdevice} -t ${cow_fstype} -o rw,noatime,mode=755 /cow || panic "Can not mount $cowdevice on /cow"
[/quota]
刪掉 ",mode=755",並存檔。

3.把initrd.gz依下列方式壓縮回去:
find . | cpio -H newc -ov > ../initrd.img
cd ..
mv initrd initrd.bk
mv initrd.img initrd
gzip initrd

4.把initrd.gz搬回去就完成了。
cp initrd.gz /media/NetbossLive/

註:附件為已修改好之8.04版initrd.gz


接下來示範如何使用此功能:

方法一:將任意一個磁區格式化成ext2或ext3,且磁區名稱設為 casper-rw,並在開機參數加上persistent即可。

$ mkfs.ext3 -b 4096 -L casper-rw /dev/sda1


方法二:在任一磁區根目錄下建立一個影像檔名為casper-rw,並在開機參數加上persistent即可。

$ dd if=/dev/zero of=/media/sda1/casper-rw bs=1M count=128 ←開一個128mb的影像檔,用來儲存資料。

$ mkfs.ext3 /media/sda1/casper-rw

arrow
arrow
    全站熱搜

    正義的胖虎 發表在 痞客邦 留言(0) 人氣()