在USB盘和内存里运行OpenBSD
发表于 : 2010-10-21 0:28
让OpenBSD运行在USB盘和内存里
来龙去脉:
wkx9dragon总有一些好点子,我们在这里先称赞一下,以下是我从网上找到的文章,经测试(个别的地方还要修改,否则无法正常运行,例如 / 分区的属性,还有就是 /proto/dev 目录的大小等)可以运行。首先 / 分区不能动,因为系统启动要用,此外,我试着将X整合进内存,不太容易,因为X在 /usr 目录下,我还没有想到办法将 /usr 放进内存分区。另外一个不通用的地方是,原作者的思路是假设你用的是IDE的硬盘,也就是说你的usb盘,系统识别为sd0, 这样制作的usb上运行的OpenBSD系统只能运行在类似的环境中,例如在我的系统上,因为OpenBSD将一块大硬盘识别为5块scsi硬盘,(sd0,sd1,sd2,sd3,sd4),所以制作的系统为sd5, 这样拿到别的计算机上是无法应用的,要是能有一个方法制作为类似ram内核bsd.rd、或者live usb的就比较好一些了,继续google一下,也请有类似经验的朋友放开讨论。
原文摘自:
http://www.volkerroth.com/tecn-obsd-diskless.html
按照原作者的思路和方法(还要略作修改),经测试可以在U盘及内存上运行OpenBSD,但是我总觉得还是不完美(例如 /usr 和 X 的处理),希望大家集思广益。
来龙去脉:
wkx9dragon 写了:leo 写了:瞧这意思,你想把OpenBSD生生折腾成无盘工作站。:)
我以前在网上还真看过这方面的讨论,不过一时想不起来在哪里了。
对呀!我就是想把OS整个放到内存里,反正内存也够,netbsd,openbsd也不大。现在没找到方法。
wkx9dragon总有一些好点子,我们在这里先称赞一下,以下是我从网上找到的文章,经测试(个别的地方还要修改,否则无法正常运行,例如 / 分区的属性,还有就是 /proto/dev 目录的大小等)可以运行。首先 / 分区不能动,因为系统启动要用,此外,我试着将X整合进内存,不太容易,因为X在 /usr 目录下,我还没有想到办法将 /usr 放进内存分区。另外一个不通用的地方是,原作者的思路是假设你用的是IDE的硬盘,也就是说你的usb盘,系统识别为sd0, 这样制作的usb上运行的OpenBSD系统只能运行在类似的环境中,例如在我的系统上,因为OpenBSD将一块大硬盘识别为5块scsi硬盘,(sd0,sd1,sd2,sd3,sd4),所以制作的系统为sd5, 这样拿到别的计算机上是无法应用的,要是能有一个方法制作为类似ram内核bsd.rd、或者live usb的就比较好一些了,继续google一下,也请有类似经验的朋友放开讨论。
原文摘自:
http://www.volkerroth.com/tecn-obsd-diskless.html
Running OpenBSD off a USB Stick
Introduction
This document describes how OpenBSD (obsd) can be installed and run off a USB stick without the need for a hard drive. Write operations to the USB stick are avoided.
We assume that the USB stick has a capacity of 512MB or more. In this case, the base installation fits well onto the stick and no pruning is required.
Installing
The easiest way to install obsd is to boot the OpenBSD installation CD on any computer with the USB stick plugged in. The installation script will show the available drives and the stick will be shown as sd0. By choosing this drive, the installation can be performed as any regular obsd installation. However, we must be careful not to touch the actual drive of the computer, which will show up as wd0.
The following partition layout should work fairly well:
PartitionMountMB512K a/4898304 d/var1632768 e/var/log1632768 f/tmp1632768 g/home1632768 h/usr** On a 512MB stick this should leave enough room in /usr for a basic (non-X) installation. With all non-X sets and the xbase40 set installed the /usr partition will be about 388 MB large. We do not want to swap to the drive and therefore we do not configure a swap partition either.
Mounting file systems
All file systems that reside on the stick shall be mounted read-only. All file systems that must be writable while obsd is running are copied to and mounted as memory file systems. The following file systems must be writable:If a computer running obsd is available then these steps can be performed on the mounted drive. Otherwise, the computer should be booted from the drive.代码: 全选
/dev /tmp /var /var/log
First, we create a prototypical /dev directory, which we are going to populate with device nodes:Next, copy the MAKEDEV script from /dev to /proto/dev and run it to create all device nodes. This is accomplished by:代码: 全选
/proto/dev
The creation process takes a while. Next, we must adjust the fstab file using vi. This includes the following steps:代码: 全选
cd /proto/dev ; ./MAKEDEV all
The -P option of the mount_mfs command populates the mounted filesystem. This can be done from a directory or from a block device. In our case, we created separate partitions for /tmp, /var and /var/log, which leads to a clean and simple setup for their corresponding memory file systems.
- The noatime option is appended to all entries.
- Access for all entries is limited to read-only.
- Entries for writable file systems are commented out.
- Entries for memory-mounted writable file systems are added.
The inode value for the population of the /dev memory file system should be small e.g., 128 since the device nodes are small and therefore many inodes are required. The number of sectors required can be estimated by running:and rounding this number up with a good safety margin added. My rationale is as follows: each device entry will occupy one sector. Additional blocks are needed for inodes.代码: 全选
ls /proto/dev | wc -l
The final fstab may look as given below:We simply commented out the partitions we wish to move to a memory file system. For each such partition, we added a memory file system entry that populates the file system from the corresponding partition. The only exception is /dev, which we populate from a directory in the root file system of the drive.代码: 全选
# cat /etc/fstab /dev/sd0a / ffs ro,noatime 1 1 /dev/sd0g /home ffs ro,nodev,nosuid,noatime 1 2 /dev/sd0h /usr ffs ro,nodev,noatime 1 2 # /dev/sd0d /var ffs ro,nodev,nosuid,noatime 1 2 # /dev/sd0e /tmp ffs ro,nodev,nosuid,noatime 1 2 # /dev/sd0f /var/log ffs ro,nodev,nosuid,noatime 1 2 swap /var mfs rw,nosuid,noexec,nodev,-P=/dev/sd0d 0 0 swap /tmp mfs rw,nosuid,noexec,nodev,-P=/dev/sd0e 0 0 swap /var/log mfs rw,nosuid,noexec,nodev,-P=/dev/sd0f 0 0 swap /dev mfs rw,nosuid,noexec,-P=/proto/dev,-i=128,-s=2048 0 0
Notes
The /var file system is very small and will therefore fill up quickly as obsd sends reports to the root account by e-mail. However, since /var is a separate partition, no harm is done except that the operation fails and an occasional error message appears in the logs.
按照原作者的思路和方法(还要略作修改),经测试可以在U盘及内存上运行OpenBSD,但是我总觉得还是不完美(例如 /usr 和 X 的处理),希望大家集思广益。