`

ubuntu from read-only harddisk/cd

阅读更多

使用 unionfs 及 aufs 的觀念來達成唯讀的功能。
(特別感謝 penk 所製作的 PUD live cd,參考其中的作法才能完成)

※ 已修改好的相關檔案 (請參考附檔)

所需檔案:
(請下載 ftp://mirror.nttu.edu.tw/penk/patch/binary/aufs.ko)
aufs.ko

安裝方法:

1.由 Ubuntu CD 安裝系統及其它軟體 (核心請更新至 2.6.20-16)

2.進入終端機模式,複製 initrd.img-2.6.20-16-generic 到家目錄
cp /boot/initrd.img-2.6.20-16-generic .

3.解開此檔

 

cp initrd.img-2.6.20-16-generic initrd.gz

gunzip initrd.gz

mkdir tmp

cd tmp

cpio  -iF ../initrd.gz 

 

 

4.底下均以 initrd.img-aufs 為工作目錄 (cd initrd.img-aufs)

5.編輯 conf/modules (插入第一列空白列後,輸入 aufs)

6.新增 lib/modules/2.6.20-16-generic/kernel/fs/aufs 資料夾,並複製 aufs.ko 置於此資料夾

7.編輯 scripts/local (方法如下)
移到檔案後方,約在
第 74 列 # Mount root
第 75 列 mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
將 75 列 加上 # 註解
在第 76 列插入下列指令碼:

if [ ${aufsmb} = no ]; then
mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
else
modprobe aufs
mkdir -p /rofs
mkdir -p /aufs
mount -t tmpfs -o size=${aufsmb}m /dev/shm /aufs
mount -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} -o ro /rofs
mount -t aufs -o dirs=/aufs=rw:/rofs=ro unionfs ${rootmnt}
fi


8.編輯 init (方法如下)
移到約第 37~44 列 (此處均為 export ??? 型式)
移到最末的 export 後插入一列 export aufsmb=no
移到約第 117 列找到 break=*)
在此列前插入三列,分別輸入
aufs=*)
aufsmb=${x#aufs=}
;;


9.新增兩個文字檔於 scripts/init-bottom/ 資料夾 (名稱為 12fstab 及 13swap)
(特別注意:務必將此兩檔案改成可執行的屬性,chmod +x 12fstab)
------------------------------------------------------
12fstab:
------------------------------------------------------
#!/bin/sh

if [ ${aufsmb} != no ]; then
cat > /root/etc/myfstab1 << EOF
unionfs / unionfs rw 0 0
tmpfs /tmp tmpfs nosuid,nodev 0 0
EOF
cat /root/etc/fstab | grep '/ ' -v > /root/etc/myfstab2
cat /root/etc/myfstab1 /root/etc/myfstab2 > /root/etc/fstab

rm -f /root/etc/myfstab1
rm -f /root/etc/myfstab2

rm -f /root/etc/rcS.d/S*checkroot.sh
fi

------------------------------------------------------
13swap: (2007.07.31 修改)
------------------------------------------------------
#!/bin/sh

cat /root/etc/fstab | grep 'swap'
if [ $? == 1 ] && [ ${aufsmb} != no ]; then
devices=""
for device in /dev/[hs]d[a-z][0-9]*; do
if ! [ -b "$device" ]; then
continue
fi

magic=$(/bin/dd if="$device" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue

if [ "$magic" = "SWAPSPACE2" -o "$magic" = "SWAP-SPACE" ]; then
devices="$devices $device"
fi
done

for device in $devices; do
cat >> /root/etc/fstab << EOF
$device swap swap defaults 0 0
EOF


10.製成開機檔 initrd.img-2.6.20-16-aufs
find . | cpio -L -H newc -o | gzip -9 > ../initrd.img-2.6.20-16-aufs

11.複製 initrd.img-2.6.20-16-aufs 到 /boot/ 資料夾
cd ..
sudo cp initrd.img-2.6.20-16-aufs /boot

12.編輯 /boot/grub/menu.lst (複製原有選項,並修改如下)
Title Ubuntu (readonly)
root (hd....)
kernel /boot/vmlinuz-2.6.20-16-generic ....(同原選項) aufs=32
initrd /boot/initrd.img-2.6.20-16-aufs
quiet

註:修改處 Title 及 aufs=32 及 initrd.img-2.6.20-16-aufs
其中 aufs=32 表示使用 32MB RAM 來當做寫入用的緩衝記憶體 (適用於實際記憶體 256MB RAM,可視自己電腦配備調整數字)

13.重新開機後進入 grub 選單時,選擇 Ubuntu, kernel 2.6.20-16-generic (可寫入模式)
或選擇 Ubuntu (readonly) 則進入唯讀模式

分享到:
评论

相关推荐

    g4u-ghost for unix

    g4u ("ghost for unix") is a NetBSD-based bootfloppy/CD-ROM that allows easy cloning of PC harddisks to deploy a common setup on a number of PCs using FTP. The floppy/CD offers two functions. The first...

    html-webpack-harddisk-plugin:即使使用Webpack开发服务器或中间件,也将html文件写入硬盘

    $ npm install --save-dev html-webpack-harddisk-plugin 基本用法 在您的webpack配置中需要插件: const HtmlWebpackHarddiskPlugin = require ( 'html-webpack-harddisk-plugin' ) ; 将该插件添加到您的webpack...

    linux 0.11 kernel开发包 适于进行Linux OS研究

    cd /usr/root gcc -s -o hello hello.c ./hello ------------------------------------------------ files included: README -- This file. Bochs-2.1.1.exe -- Bochs system for use in win32 environment...

    Bochs - The cross platform IA-32 (x86) emulator

    - ported the read-only part of Qemu's 'virtual VFAT' block driver - additions: configurable disk geometry, FAT32 support, read MBR and/or boot sector from file, volatile write support using hdimage...

    Microsoft Visual Studio

    可再发行编码 - 有限使用: msjet35.dll msjint35.dll msjter35.dll msrd2x35.dll msrepl35.dll expsrv.dll vbajet32.dll msexch35.dll msexcl35.dll mspdox35.dll msltus35.dll mstext35.dll msxbse35.dll ...

    pli-jade2-dm500-20090322-6302

    - Support for slave harddisk on DM7020 Fixes: - Web interface timer menu fixes - Let exit key on a DM500 repeat to quit menus quickly - Take time start and stop offsets into account if a recording ...

    Harddisk-winpe-c--v20170717.zip

    harddisk-winpe-c--v20170714 请阅读“readme FOR winpe-c.zip”文件中的说明,本压缩包包含symantec商业软件的部分应用程序、仅用于非商业性质的应用场合! 请有条件的用户购买完全版本、包含完善售后服务支持的...

    grldr (boot from harddisk)

    grldr (boot from harddisk, via grub)

    西门子2011年授权大全

    09/09/2010 add some info for WinCC DowntimeMonitor, WinAC, fix bug for comp and Virtual Machine with 1 HardDisk partition 09/05/2010 add keys for WinCC Flexible 2008 SP2 options v1.3, Sinaut, ...

    西门子2013年最新授权工具Simatic_EKB_Install_2013_05_26

    09/09/2010 add some info for WinCC DowntimeMonitor, WinAC, fix bug for comp and Virtual Machine with 1 HardDisk partition 09/05/2010 add keys for WinCC Flexible 2008 SP2 options v1.3, Sinaut, fixed ...

    存储卡中的Flash文件没声音了怎么恢复-迅捷数据恢复

    存储卡数据恢复软件免费版http://download.pchome.net/system/harddisk/detail-191618.html 存储卡数据恢复软件免费版http://xiazai.zol.com.cn/detail/43/425173.shtml

    存储卡中的TXT文件显示乱码怎么恢复原文件丨迅捷数据恢复丨

    存储卡数据恢复软件免费版http://download.pchome.net/system/harddisk/detail-191618.html 存储卡数据恢复软件免费版http://xiazai.zol.com.cn/detail/43/425173.shtml

    Android代码-Uae4all2

    Features: AGA/OCS/ECS, 68020 and 68000 emulation, harddisk-support, WHDLoad-support, Chip/Slow/Fast-mem settings, savestates, vsync, most games run fullspeed Authors: Chui, john4p, TomB, notaz, Bernd ...

    HardDisk硬盘低格

    HardDisk硬盘低格HardDisk硬盘低格

    西门子2014年最新授权工具原版 Simatic_EKB_Install_2013_12_25.zip

    09/09/2010 add some info for WinCC DowntimeMonitor, WinAC, fix bug for comp and Virtual Machine with 1 HardDisk partition 09/05/2010 add keys for WinCC Flexible 2008 SP2 options v1.3, Sinaut, fixed ...

    harddisk-ID修改工具

    有些时候能够用的到的东西可以下来试试玩玩

    intellitamper

    Just type in the address, let IntelliTamper works and read the dirty pages for you, and you will be able to access the files and browse the folders like if they were on your own hard-disk ! ...

    ptdd分区表医生 3.5

    Partition Table Doctor is the only real software for harddisk partitions recovery when you experience a drive error (other than hardware failure) this versatile tool automatically checks and repairs ...

    HARDDISK.zip昆仑通态触摸屏案例编程源码资料下载

    HARDDISK.zip昆仑通态触摸屏案例编程源码资料下载HARDDISK.zip昆仑通态触摸屏案例编程源码资料下载HARDDISK.zip昆仑通态触摸屏案例编程源码资料下载HARDDISK.zip昆仑通态触摸屏案例编程源码资料下载 1.合个人学习...

    HardDisk.cs

    HardDisk.cs

Global site tag (gtag.js) - Google Analytics