Combine GRUB2, GPT, UEFI and NanoBSD on Ubuntu 11.04 ?


1. Installing Ubuntu 11.04
  • please change sources.list with apt-get install from ... 
  • tw.archive.ubuntu.com  ->  mirror.nttu.edu.tw
2. Installing ufsutils/gdisk package ...

  • apt-get install ufsutils
  • apt-get install gdisk
3. Partition your hard drive
  • my plan as follows.
    • /dev/sdb1 -> EFI system partition "EF00"
    • /dev/sdb2 -> NanoBSD #1 "A500"
    • /dev/sdb3 -> NanoBSD #1 "A500"
    • /dev/sdb4 -> Data "A503"
  • gdisk /dev/sdb 
  • ...
  • mkfs.vfat -F32 /dev/sdb1
  • mkfs.ufs -O 2 /dev/sdb2
  • mkfs.ufs -O 2 /dev/sdb3
  • mkfs.ufs -O 2 /dev/sdb4
4. Mount EFI system partition
  • mkdir /boot/efi
  • mount /dev/sdb1 /boot/efi
  • mkdir -p /boot/efi/efi
5. Install grub for efi
  • apt-get install grub-efi-amd64
6. Setup your grub2 into the EFI system partition
  • modprobe dm-mod
  • grub-install --boot-directory=/boot/efi/efi --bootloader-id=GRUB2 --no-floppy --recheck
  • cp /usr/share/grub/unicode.pf2 /boot/efi/efi/grub/
  • cp /boot/grub/grub.cfg /boot/efi/efi/grub/grub.cfg
    • grub.cfg context as follows.
      • insmod ufs2
      • set root='(hd0,1,a)'
      • search --no-floppy --fs-uuid --set 4ea7f1272cbdb23e
      • echo Loading kernel of FreeBSD kernel ...
      • kfreebsd /boot/kernel/kernel
      • kfreebsd_loadenv /boot/device.hints
      • set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a
      • set kFreeBSD.vfs.root.mountfrom.options=rw
      • ...
7. Copy my old grub.cfg and seting up the EFI boot entry.
  • modprobe efivars
  • efibootmgr --create --gpt --disk /dev/sdb --part 1 --write-signature --label "GRUB2" --loader "\\EFI\\grub\\grub.efi"
note. GRUB2 is the entry that would appear on the EFI bootloader










Linux_Windows_BIOS_UEFI_boot_USB


https://gitorious.org/tianocore_uefi_duet_builds/pages/Linux_Windows_BIOS_UEFI_boot_USB



Manual setup of UEFI, GPT and GRUB2

http://jkyamog.blogspot.com/2011/09/manual-setup-of-uefi-gpt-and-grub2.html

insmod vs modprobe


insmod 與 modprobe 都是載入 kernel module,不過一般差別於 modprobe 能夠處理 module 載入的相依問題。
比方你要載入 a module,但是 a module 要求系統先載入 b module 時,直接用 insmod 掛入通常都會出現錯誤訊息,不過 modprobe 倒是能夠知道先載入 b module  後才載入 a module,如此相依性就會滿足。
不過 modprobe 並不是大神,不會厲害到知道 module 之間的相依性為何,該程式是讀取 /lib/modules/2.6.xx/modules.dep 檔案得知相依性的。而該檔案是透過 depmod 程式所建立。

modprobe:
modprobe可載入指定的個別模塊,或是載入一組相依的模塊。modprobe會根據depmod所產生的相依關係,決定要載入哪些模塊。若在載入過程中發生錯誤,在modprobe會卸載整組的模塊。
  -a或--all  載入全部的模塊。
  -c或--show-conf  顯示所有模塊的設置信息。
  -d或--debug  使用排錯模式。
  -l或--list  顯示可用的模塊。
  -r, --remove //若在命令指定模塊,則刪除指定模塊,否則,指定"自動清除"模式 
  -t或--type  指定模塊類型。
  -v或--verbose  執行時顯示詳細的信息。
  -V或--version  顯示版本信息。
  -help  顯示幫助。
  -C, --config configfile //指定配置文件.默認使用/etc/modules.conf文件為配置文件
modprobe -r ip_vs  # 刪除ip_vs模塊
modprobe -l | grep ip_vs  # 查看ip_vs模塊是否編譯進內核
lsmod -l | grep ip_vs  # 查看ip_vs模塊是否載入進內核

Manual setup of UEFI, GPT and GRUB2


Ref: http://jkyamog.blogspot.com/2011/09/manual-setup-of-uefi-gpt-and-grub2.html


Manual setup of UEFI, GPT and GRUB2

I recently got a Crucial m4.  I then have to transfer my existing HDD on it.  Its easier to do a clean install of Oneiric and it would pretty much do UEFI + GPT + GRUB2 for you.  However if you want to manually transfer everything I did the following steps:

  • Boot on Oneiric live CD or another boot this that will boot in UEFI mode. Its important that boot is on UEFI mode and not BIOS mode
  • Go to a shell and install gdisk as we want to partition the SSD w/ GPT and not MBR. fdisk only supports MBR
    apt-get install gdisk
    
  • Partition a EFI system partition.  This would hold grub2 files later and other boot loaders if needed.  I partitioned mine on sda1 as type EF00 (EFI System) w/ the size of 200mb.  Yes a bit bigger than what is needed however most people recommend 200mb as some boot loaders needs a bigger space.
  • Format the partitions.  The EFI System partition is formatted as vfat, as per EFI spec.
    mkfs.vat /dev/sda1
    mkswap /dev/sda2
    mkfs.ext4 -E stripe-width=128 /dev/sda3
    mkfs.ext4 -E stripe-width=128 /dev/sda4
    
    I put in a stripe width of 128 k as there are some recommendation this is optimal for SSD. However test suggest that your mileage may vary.
  • Mount and create the dirs on EFI system partition
    mkdir /boot/efi
    mount /dev/sda1 /boot/efi
    mkdir -p /boot/efi/efi
  • Install grub efi
    apt-get install grub-efi-amd64
    
  • Setup grub on the EFI system partition
    modprobe dm-mod
    grub-install --boot-directory=/boot/efi/efi --bootloader-id=GRUB2 --no-floppy --recheck
    cp /usr/share/grub/unicode.pf2 /boot/efi/efi/grub/
    cp /boot/grub/grub.cfg /boot/efi/efi/grub/grub.cfg
    
    I copied my old grub.cfg and update the UUID to point to the new SSD
  • Setup the EFI boot entry
    modprobe efivars
    efibootmgr --create --gpt --disk /dev/sda --part 1 --write-signature --label "GRUB2" --loader "\\EFI\\grub\\grub.efi"
    
    GRUB2 is the entry that would appear on the EFI bootloader.
The following resource helped me a lot
https://help.ubuntu.com/community/UEFIBooting#Install_GRUB2_in_.28U.29EFI_systems

I am still working out on the graphics output,  This would only give you a text based grub.

GRUB2 Arch



How to install GRUB2 into flash on FreeBSD

1. Setup GRUB package
gy# cd /usr/ports/sysinstall/grub2
gy# make install clean

2. fdisk&newfs three partition in a flash as follows.
da0
da0s1
da0s2
da0s3

gy# newfs /dev/da0s3

3. Create folder "/boot/grub"
gy# mkdir /mnt/da0
gy# mount /dev/da0s3d /mnt/da0

// gy# mkdir /mnt//boot
// gy# mkdir /mnt/boot/grub

4. install GRUB2 into da0
// cp -r /boot/grub/* /mnt/boot/grub
// copy
gy# grub-install --root-directory=/mnt/da0 /dev/da0  
or
gy# grub-install --modules=ufs2 /dev/da0
gy# grub-mkconfig -o /mnt/da0/boot/grub/grub.cfg
//gy# grub-setup /dev/da0





Note that. please type as follows command if show of grub rescue >
grub rescue>set root=hd0,2,d
grub rescue>prefix=(hd0,2,d)/boot/grub
grub rescue>insmod normal
grub rescue>normal

GRUB2 rescue

grub rescue>

grub rescue>set
prefix=(hd0,6)/boot/grub
root=hd0,6

grub rescue>ls
(hd0), (hd0,1), (hd0,2), (hd0,3), (hd0,5)
grub rescue>set root=(hd0,1)
grub rescue>set prefix=(hd0,1)/boot/grub
grub rescue>insmod normal
rescue:grub>normal





  • Modify : /boot/grub/grub.cfg
    • Excute update-grub to modify menu
    • sudo update-grub

  • Reinstall grub
    • sudo grub-install /dev/sda

Testing GRUB 2 on your GPT-partitioned flash drive


I did a quick test, and you can, too.  I'll explore this some more after GRUB 2 and 9.10 are finalized.

Here's my summary.

OS:   Kubuntu 9.10 alpha 6 (which uses the latest version of GRUB 2 (1.97x).
Bootloader:  GRUB 2 (beta)
Disk device:  1 GB Kingston USB flash drive
Motherboard:  Intel DG33FBC; Intel D915GAVL
Disk partition utility:   GParted Live CD, current version

Steps:

1   Boot into Kubuntu

2   Open Konsole (Terminal program)

3   Optional:  Zero-out your flash drive
THIS WILL DESTROY ALL DATA ON THE FLASH DRIVE.
This writes zeros to the entire flash drive and restores it to factory-new condition.
Find out how Kubuntu sees your flash drive:
sudo fdisk -lu
Let's say, for this example, it is /dev/sdc.
Use the dd command to write zeros to the entire flash drive:
sudo dd if=/dev/zero  of=/dev/sdc
(You will not see any progress meter or output until it finishes.  It took approximately 7 minutes on my system.)

4  Partition the flash drive using GParted Live CD
You can also do this using an installed gparted (Partition Editor).
Tip:  While in GParted Live CD, remember that you have access to a terminal if you need one (for dd, or sudo fdisk -lu): double-click Terminal icon at top.  For root, simply use sudo in front of commands.

I partitioned as follows:

Plug in the flash drive, click Devices > Refresh (you may have do it more than once until the flash drive appears in the drop-down list of drives at the upper right or under GParted > Devices).
You'll get a message that a Disklabel must be set on the disk and asked if you want the (default) msdos  Disklabel.  (You will also get this message if you highlight unallocated space and click Partition > New).  You don't want msdos, so click the Advanced button and select gpt, then Create.

Partitions:

Partition 1:  BIOS Boot partition
8 MB (the minimum size offered), FAT32, for the BIOS Boot partition (embedding core.img).
Set a flag:  Partition > Manage flags, then check the bios_grub box (as the tag).
Set a Label on the partition to remind you what it is:
Partition > Label, and I typed BIOS_BOOT as the label.

Partition 2:  For setting up the GRUB 2 files in /boot/grub
10 MB, ext2
Also, set the boot flag on this partition to make it the active partition:
Partition > Manage flags > check the boot box.
Set a label on the partition to remind you what it is:
Partition > Label, and type GRUB_FILES as the label.

Partition 3:  A for-fun extra test partition for the heck of it.  (In another test, I also tested creating 10 partitions, and it went well under GPT.)
200 GB, ext2

5  Install GRUB 2 to the flash drive
Exit GParted Live CD, remove the CD and the flash drive, reboot into your regular Kubuntu.
Plug in the flash drive.  See how it is mounted (or go into Dolphin and click on the second partition GRUB_FILES to mount it).  Open Konsole. install GRUB 2 to the flash drive, setting up the GRUB 2 files in the second partition (GRUB_FILES) and installing the bootloader (boot.img = 512 bytes) to the MBR of the flash drive.
Example:
Suppose the second partition is mounted as /media/GRUB_FILES and suppose the flash drive is seen as /dev/sdc in Kubuntu (use sudo fdisk -lu to find out).  Then install GRUB 2 to it as follows:
sudo grub-install --root-directory=/media/GRUB_FILES  /dev/sdc
If it doesn't go, do it again with --recheck:
sudo grub-install --recheck --root-directory=/media/GRUB_FILES /dev/sdc

6  Re-booting from the flash drive:
Make sure your BIOS is set to boot from USB and configure BIOS to boot from your flash drive.
If you re-boot starting from your Kubuntu session, keep the flash drive plugged in (but click Safely Remove to unmount it), reboot the PC, enter BIOS setup, configure BIOS to boot from USB and put the flash drive at the top of the drive list, F10 to Save & Exit, and re-boot from the flash drive.  After the POST, you should see the GRUB 2 prompt (coming from the GRUB 2 on the flash drive): grub>.  (You get the GRUB prompt grub>  since there is no boot menu  (/boot/grub/grub.cfg) configured.)  You can use this grub prompt to boot into one of your OSs; or simply shutdown the PC (grub>halt) and remove the flash drive; or re-boot (grub>reboot), enter BIOS setup, remove the flash drive, set BIOS to boot from your regular drive, F10 to save this change and exit to reboot from your regular drive.

What is the GPT format for basic disks?


Basic disks are the storage types most often used with Windows. The term basic disk refers to a disk that contains partitions, such as primary partitions and logical drives, and these in turn are usually formatted with a file system to become a volume for file storage.
The GPT format for a basic disk is illustrated in the following figure.
Figure 1. GPT Format for Basic Disks
The protective MBR area exists on a GPT partition table for backward compatibility with disk management utilities that operate on MBR. The GPT header defines the range of logical block addresses that are usable by partition entries. The GPT header also defines its location on the disk, its GUID, and a 32-bit cyclic redundancy check (CRC32) checksum that is used to verify the integrity of the GPT header. Each entry in the GUID partition table begins with a partition type GUID. The 16-byte partition type GUID, which is similar to a System ID in the partition table of an MBR disk, identifies the type of data that the partition contains and identifies how the partition is used, for example, whether it is a basic disk or a dynamic disk. Note that each GUID partition entry has a backup copy.
For more information about basic disks, refer to the MSDN topic "Basic and Dynamic Disks."

Built NanoBSD step by step

bsdlabel -e adxsx  ->      a: ......  4.2BSD ......
                                       c: ........


title FreeBSD 4.10
                root (hd0,a)
                kernel /boot/loader ro root=/dev/hda1

set currdev=disk2s1a

r
>       currdev=disk1s1a:


GRUB背景,具体做法是怎样?

问:我想请教一下,要修改Mandrake 9下的GRUB背景,具体做法是怎样?
答: 文件/boot/grub/splash.xpm.gz 就是GRUB启动后的背景图象。
#gzip -d splash.xpm.gz

然后再
more splash.xpm
/* XPM */
static char * splash_xpm[] = {
"640 480 15 1",
" c None",

Setting SSH+DHCP on FreeBSD


rc.conf

# Created: Wed Oct 12 05:11:14 2011                                                               
# Enable network daemons for user convenience.                                              
# Please make all changes to this file, not to /etc/defaults/rc.conf.                      
# This file now contains just the overrides from /etc/defaults/rc.conf.                
                                                                                                                           
synchronous_dhclient="YES"                                                                                                                           
                                                                                                                           
#ifconfig_em0="dhcp"                                                                                                                           
                                                                                                                           
ifconfig_em0="inet 172.16.4.50 netmask 255.255.240.0"                                                                                                                           
defaultrouter="172.16.0.1"                                                                                                                           
                                                                                                                           
sshd_enable="Yes"                                                                                                                            
ftpd_enable="Yes"                                                                                                                              
                                                                                                                                                            
usbd_enable="YES"                                     
                                                                






                     

Using Slices in FreeBSD



This setup will allow your disk to work correctly with other operating systems that might be installed on your computer and will not confuse other operating systems'fdisk utilities. It is recommended to use this method for new disk installs. Only use dedicated mode if you have a good reason to do so!
# dd if=/dev/zero of=/dev/da1 bs=1k count=1
# fdisk -BI da1 #Initialize your new disk
# bsdlabel -B -w da1s1 auto #Label it.
# bsdlabel -e da1s1 # Edit the bsdlabel just created and add any partitions.
# mkdir -p /1
# newfs /dev/da1s1e # Repeat this for every partition you created.
# mount /dev/da1s1e /1 # Mount the partition(s)
# vi /etc/fstab # Add the appropriate entry/entries to your /etc/fstab.
If you have an IDE disk, substitute ad for da.

How to install grub in FreeBSD

ref:http://administratosphere.wordpress.com/2008/02/25/installing-grub-on-freebsd/


Installing GRUB onto a FreeBSD system isn’t that hard – if you know how.
If you just run grub-install as root – which should normally work – you might see an error like this:
# grub-install hd0
GNU GRUB version 0.97 (640K lower / 3072K upper memory)
[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub> root (hd0,1,a)
Filesystem type is ufs2, partition type 0xa5
grub> setup --stage2=/boot/grub/stage2 --prefix=/boot/grub (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/ufs2_stage1_5" exists... yes
Running "embed /boot/grub/ufs2_stage1_5 (hd0)"... failed (this is not fatal)
Running "embed /boot/grub/ufs2_stage1_5 (hd0,1,a)"... failed (this is not fatal)
Running "install --stage2=/boot/grub/stage2 /boot/grub/stage1 (hd0) /boot/grub/stage2 p /boot/grub/menu.lst "... failed
Error 29: Disk write error
grub> quit
The first step is to set a FreeBSD kernel variable:
sysctl kern.geom.debugflags=16
This will make the master boot record (MBR) writable, which is normally where the boot record is installed. Unless you do this, you will receive the error above.
Once the variable is set, the program grub-install should work fine with your chosen drive. The menu is in/boot/grub/menu.lst; here is a starter example for FreeBSD:
title FreeBSD
root (hd0,0,a)
kernel /boot/loader
The loader is the “kernel” in this case, as it will load the FreeBSD kernel anyway and it allows you the ability to drop into the boot console if you want.

Bring up service at booting in FreeBSD


synchronous_dhclient="YES"

#ifconfig_em0="dhcp"

ifconfig_em0="inet 172.16.4.50 netmask 255.255.240.0"
defaultrouter="172.16.0.1"

sshd_enable="Yes"
ftpd_enable="Yes"

usbd_enable="YES"

Configure a service to start at boot time


ref:http://bsdwiki.reedmedia.net/wiki/Configure_a_service_to_start_at_boot_time.html

Concept

Recognize that the BSD boot process does not use runlevels. Be able to configure essential services to start at boot time to minimize the impact of a system reboot.
TODO: PUT THIS NEXT TO RELATED CONCEPTS

Introduction

The BSDs all run the /etc/rc system startup script. It is ran by /sbin/init (known as the "parent of all processes") before it initializes the terminals and local logins.
Note that the BSDs do not have System V-style runlevels, such as found on Linux, where different startup scripts are available for networking, X11 workstation, server, etc. (On systems with multiple runlevels, these are normally done by using symlinks in the specific runlevel directories pointing to the desired startup scripts.)
TODO: should this mention single-user mode here? Point to it.
The /etc/rc scripts vary on each system, but all basically do the same steps:
  • Load the "rc.conf" configurations.
  • Enable special virtual disks, like concatenated disks, Vinum Logical Volume Manager, and RAID devices.
  • Enable swap device for virtual memory.
  • Check file systems.
  • Mount special disks or pseudo-devices.
  • Mount the main / (root) disk partition.
  • Set device-specific flags for terminals. (TODO: should I remove this?)
  • Configure system console driver, such as setting a video mode, screen burner timeout, keyboard bell's pitch, and keyboard encoding.
  • Loading initial firewall (packet filter) rules.
  • Set default settings (tunables) for the kernel.
  • Set the hostname.
  • Turn on the network.
  • Load custom packet filter rules.
  • Mount /usr and /var partitions (if not already mounted).
  • Initialize (seed) random devices.
  • Clean up junk and /tmp files.
  • Save a copy of the "dmesg" boot messages.
  • Startup the syslogger daemon.
  • Mount other filesystems.
  • Enable swap files (if any).
  • Save operating system core dump. TODO: why on OpenBSD does this happen after enabling swap?
  • Create kernel and /dev device databases.
  • Set default ownership and permissions on terminal devices.
  • Update the "message of the day".
  • Create runtime link editor directory cache. (TODO: reword that)
  • Check for vi editor recovery files.
  • Generate SSH host keys if needed.
  • Start the SSH server.
  • Start cron.
Some other tasks that may be enabled include:
  • Startup the "named" DNS server.
  • Start IKE key management daemon (and generate key if needed).
  • Start IPsec SA failover synchronization daemon.
  • Configure IPsec.
  • Start the RPC program number mapper server.
  • Start the YP/NIS database services.
  • Enable NFS services.
  • Start filesystem auto-mounter. TODO: "file system" or "filesystem"? Be consistent
  • Set date over network.
  • Start network time server.
  • Start Arla File System (AFS) cache manager. (Footnote: AFS is a distributed file system.)
  • Check and enable file system quotas.
  • Set kernel security level.
  • Enable system accounting.
  • Start various networking daemons, like routed and dhcpd.
  • Enable PPP over ethernet.
  • Start the "watchdog" daemon.
  • Start "lpd" printer server.
  • Start mail server.
  • Start FTP server.
  • Start inetd.
  • Set audio system mixer variables.
  • Start Kerberos services.
  • Start Advanced Power Management (APM) monitor.
  • Start mouse pointer daemon.
  • Start X Display Manager.
TODO: more to list
On OpenBSD, the /etc/rc script is mostly self-contained, while on DragonFly, FreeBSD, and NetBSD, the /etc/rc script runs many individual startup scripts, commonly found in the /etc/rc.d/ directory. Details about about manually using rc.d scripts as used on NetBSD, FreeBSD and DragonFly are covered in section Use an rc(8) script to determine if a service is running and start, restart or stop it as required.
The BSDs primarily use /etc/rc.conf to configure what is started up.
On NetBSD, FreeBSD, and DragonFly, the rc.conf defaults are stored in the /etc/defaults/rc.conf file. The settings in /etc/rc.conf override the defaults. Do not edit the defaults so upgrades are easier.
The configurations are done by setting a shell variable so be careful to use proper Bourne shell syntax such as no spaces around equal signs and making sure quotes are ended.

OpenBSD Configuration

On OpenBSD, /etc/rc.conf contains the system defaults. It is suggested to keep custom settings in /etc/rc.conf.local which overrides the defaults.
On OpenBSD, the shell variables can be set to "NO" to disable that feature or set to the command-line arguments (flags). For example, here is an example of some enabled settings on OpenBSD:
""sshd_flags="" ""sendmail_flags="-L sm-mta -C/etc/mail/localhost.cf -bd -q30m" ""inetd=YES ""check_quotas=YES
And here are some disabled settings on OpenBSD:
""spamd_flags=NO ""spamlogd_flags="" ""nfsd_flags="-tun 4" ""nfs_server=NO
Note in the above example, even though spamlogd_flags is not set to NO, it is disabled because spamd_flags=NO. And even though nfsd_flags has command-line arguments, it also disabled via nfs_server=NO. TODO: do formatting here
TODO: add separate sections for other BSDs here

FreeBSD Configuration

To enable FreeBSD rc.d scripts so they are used at boot time, the individual scripts need to be enabled. The variable name with its default setting can be seen by running the rc.d script with "rcvar" as the argument; for example:
""$ /etc/rc.d/inetd rcvar ""# inetd ""$inetd_enable=NO
To enable the feature (to start at boot for example), set that variable in your /etc/rc.conf (or /etc/rc.conf.local) file (do not use string/dollar sign in front):
""inetd_enable=YES
By default, FreeBSD's startup will use rcorder(1) to scan the /etc/rc.d/ and /usr/local/etc/rc.d/ directories. The "rcorder" tool will look at special tags that identify and order the rc.d scripts.
On FreeBSD, the /etc/rc.d/localpkg rc.d script will run the /usr/local/etc/rc.d/ scripts using old style semantics (don't contain the "rcorder" tags). They must be named with ".sh" on the end and must be executable. It will run files starting with a digit first which can be used for ordering if you don't use the rc.d system.
TODO: cover ordering using rc.d system very briefly
TODO: cover "force" and "fast" command prefixes? Where should this be covered?
TODO: FreeBSD and DragonFly also use /etc/rc.conf.local by default but NetBSD does not. TODO: /etc/rc.conf.d/ directory is also available but don't over in this intro book?
TODO: make sure this is not redundant with other sections

Examples

Practice Exercises

More information

rc.conf(5) (or rc.conf(8) on OpenBSD), rc(8), inetd(8)

[轉載][教學]簡單利用AJA System Test測試你的硬碟傳輸速度


ad49
隨著資訊設備的進步,數位檔案越來越大,硬碟容量真的是越來越不夠用了,最近Stanley也遇到這個問題,Macbook Pro的硬碟空間只剩區區的4GB,到了該換硬碟的時候了(為什麼我腦子裡一直出現"出來跑,遲早要還的..."這樣的老梗),說到換硬碟,又是個需要做個天人交戰的決定,那就是高轉速大容量擇其一,最近在看WD的兩款硬碟,一款式型號為WD3200BEKT的硬碟是7200轉320GB,另一款型號為WD5000BEVT的硬碟是5400轉500GB,就是高轉速和大容量的代表,讓Stanley好生煩惱,當然在網路爬到這篇文章 ,看完之後,發現高轉速沒有什麼優勢,裝在筆電上7200轉和5400轉相去不多,不過Stanley還是對那篇文章抱持著保留的態度,希望有這兩顆硬碟的朋友可以給Stanley一些實際的數據。如果你是用MBP而且剛好最近換了以上兩種型號的硬碟,麻煩你幫我測一下實際上在Mac OS X下的速度,Stanley會感激不盡的。
Arrow_Down至於在Mac下要用哪套軟體來測試硬碟傳輸速度呢?Stanley就順便來介紹一下一個軟體,那就是AJA這家做影音IO設備的廠商所寫的一套免費軟體AJA KONA System Test,各位朋友可以點選這裡 來下載,以下是這套軟體的英文簡介。
1

Arrow_Down下載回來後,執行軟體的介面就長這樣,然後在Test的地方選擇Disk Read/Write就可以作為硬碟讀寫速度的測試,Volume的地方就讓你選擇你要測試的那顆硬碟,這套軟體不僅可以測試內建硬碟,外接硬碟甚至網路硬碟都可以測。
要注意的是在測試硬碟的時候,將下圖箭頭所指的項目勾選起來,避免快取影響測試結果。選擇好了之後,按下Start即可開始測試。
2

Arrow_Down至於Video Frame Size和File Size選擇什麼對結果影響有限,只是測試時間長短上會有所不同。測試過程會在下圖的紅框中顯示,讀取和寫入的平均速度。你可以看到Stanley原本的內建5400轉160GB硬碟,讀寫速度只有36MB/sec,感覺比一般的筆電慢滿多的,是不是Stanley的這個硬碟有問題?因為別人的5400轉大多可以跑到55MB/sec左右...真怪~
3

Arrow_Down測試完畢之後,點選上圖中的Graph就會有下圖的圖示可以觀看
4

Arrow_Down點選Text就有文字形式的測試結果出現
5

整體來說,這個軟體小巧方便,測試出來的結果也頗具參考價值的,如果大家有測試硬碟速度的需求,這個軟體推薦給你。另外,如果你最近也換了2.5吋7200轉或500GB大容量的硬碟的話,幫個忙,測測看速度多少,告知一下,Stanley會非常謝謝你的^^

FreeBSD cmd about

shutdown -p now                                
關機

GY# shutdown -p now 

指令寫作範例


GY# alias
....其他省略....
alias vi='vim'  <==重點在這行啊!



【FreeBSD】Mount msdos-掛載 USB 隨身碟



前言

今天為了要測試將三個 FreeBSD .iso 合併為一個 .iso 所以要掛載 USB 隨身碟 (因為我是存在別台電腦上),所以就順手寫個筆記吧。(請尊重 weithenn 的辛勞!!)

作業環境

  • FreeBSD 6.3-RELEASE
  • 2 GB USB 隨身碟(請尊重 weithenn 的辛勞!!)



安裝及設定

步驟1.插入 USB 隨身碟

在插入 USB 隨身碟以前請先檢查在您的 Kernel 中是否將下列項目註解掉。(請尊重 weithenn 的辛勞!!)
device scbus # SCSI bus (required for SCSI)
device da # Direct Access (disks)
device pass # Passthrough device (direct SCSI access)
device uhci # UHCI PCI->USB interface (Support USB 1.x)
device ohci # OHCI PCI->USB interface (Support USB 1.x)
device ehci # EHCI PCI->USB interface (Support USB 2.0)
device usb # USB Bus (required)
device umass # Disks/Mass storage - Requires scbus and da
接下來檢查系統是否啟動 usbd 服務 (預設便開啟)(請尊重 weithenn 的辛勞!!)
#less /etc/rc.conf
usbd_enable="YES" //開機後啟動 usbd 服務
將您的 USB 隨身碟插入 FreeBSD 機器上,此時 FreeBSD Console 應該會出現如下類似訊息,或使用 dmesg 來查看也可。(請尊重weithenn 的辛勞!!)
umass0: vendor 0x13fe Silicon-Power, rev 2.00/1.10, addr 2
da0 at umass-sim0 bus 0 target 0 lun 0
da0: <> Removable Direct Access SCSI-0 device
da0: 40.000MB/s transfers
da0: 1967MB (4029440 512 byte sectors: 255H 63S/T 250C)

步驟2.掛載 USB 隨身碟

所以由上述訊息可知 USB 隨身碟被系統辦認為 da0 (就像 Windows 辦認為 ex. E: 一樣),接下來就使用下列指令掛載 USB 隨身碟到 /mnt 下吧。(請尊重 weithenn 的辛勞!!)
#mount -t msdos /dev/da0s1 /mnt
mount: Using "-t msdosfs", since "-t msdos" is deprecated.
確認 USB 隨身碟是否有掛載到 /mnt 下(請尊重 weithenn 的辛勞!!)
#df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/ad0s1a 496M 63M 393M 14% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/ad0s1g 127G 8.0M 117G 0% /home
/dev/ad0s1e 496M 12K 456M 0% /tmp
/dev/ad0s1f 9.7G 1.2G 7.7G 14% /usr
/dev/ad0s1d 2.9G 2.2M 2.6G 0% /var
/dev/da0s1 1.9G 1.5G 400M 80% /mnt //由 Size 可知有正確掛載(我的 USB 容量是 2GB)
當 使用完 USB 後記得離開 /mnt 後下 umount 指令,然後就可將 USB 隨身碟拔出 FreeBSD 機器了,拔出後 FreeBSD Console 應該會出現相關訊息,或使用 dmesg 查看也可, (就像 Windows 會說您可安裝移除該裝置一樣)(請尊

Ports and Packages 常見問題

[轉載] http://www.freebsd.org/zh/FAQ/ports.html


20.1. 如何只抓取 tarball?
如果只希望抓取 tarball 下來的話,僅需打下面指令即可:
# make fetch
如果是要抓取單一的 port,以 editors/joe 為例的話,則:

# cd /usr/ports/editors/joe
# make fetch
那麼,預設會將 editors/joe 的 tarball 下載至 /usr/ports/distfiles 目錄下。
如果是希望抓取安裝此 ports 所有相關相依 ports 的 tarball,以 systuils/portupgrade 為例的話,則:
# cd /usr/ports/systuils/portupgrade
# make fetch-recursive
預設會將此 port 與所有需要的其他 port 的 tarball,都下載至 /usr/ports/distfiles 目錄下。
如果是希望抓取 ftp 分類下所有 ports 的 tarball ,則:
# cd /usr/ports/ftp
# make fetch-recursive
則會所將 ftp 分類下所有 ports 的 tarball 都下載至 /usr/ports/distfiles 目錄下。
20.2. 如何僅做到解開 tarball的步驟?
有時候習慣自己 patch 原始碼的時候,會很常用到這個功能。以 editors/joe 為例的話,則:
# cd /usr/ports/editors/joe
# make extract
那麼就會將 tarball解開至 /usr/ports/editors/joe/work 目錄下。
20.3. 如何僅做到解開 tarball 並補上官方提供的 patch ?
此法與上面方式有一些類似,不同於是先補上官方提供的 patch ,再行 patch 自己的修正。有時候習慣自己 patch 原始碼的時候,會很常用到這個功能。 以 editors/joe 為例的話,則:
# cd /usr/ports/editors/joe
# make patch
那麼就會將 tarball解開至 /usr/ports/editors/joe/work 目錄下 ,並補上官方提供的 patch。
20.4. 如何安裝一個新的 port?
如果系統上未安裝此軟體,則可以選擇安裝一個新的 port。 以 editors/joe 為例的話,則:
# cd /usr/ports/editors/joe
# make install
如此會在系統上安裝一個新的 joe 軟體。 如果需要在安裝完成後,也一併清除編輯時期所留下來的暫存目錄,則可配合 make clean 方法一起使用,如:
# cd /usr/ports/editors/joe
# make clean
20.5. 如何安裝一個新的 port,並打包(package)起來?
將安裝完成的軟體打包起來,有許多便利性:包括在叢集系統中,可供其它機器使用, 或將未來此軟體出問題可重新利用此 package 重新快速安裝。 以 editors/joe 為例的話,則:
# cd /usr/ports/editors/joe
# make package
如此會在系統上安裝一個新的 joe 軟體,並將此軟體打包(package)起來。 package 預設會在 /usr/ports/editors/joe 目錄下,如果希望集中管理的話,建議做如下的步驟:
# mkdir -p /usr/ports/packages/All
以後打包的 packages 都會存放在此目錄下,並且系統會自動做分類,以方便管理。 如果需要在安裝完成後,一併清除編輯時期所留下來的暫存目錄,則可加上 make clean 一起使用,比如:
# cd /usr/ports/editors/joe
# make package clean
20.6. 如何打包一個 port,並將其所有相依的 ports 也打包起來?
因為上面剛說的 make package 方式只有打包單一套件, 中間依賴的 ports 並沒有一起打包,這會出現一個常遇到的問題: 就是如果一個 port 需要依賴其它的 ports,那麼必須將其它 ports 也一起打包,否則安裝 packages 會有相依的問題。 以 sysutils/portupgrade 為例:
# cd /usr/ports/sysutils/portupgrade
# make DEPENDS_TARGET=package package
如此一來,就會對所有 portupgrade 所相依賴的 ports 都一併打包,也包括自己本身。
20.7. 如何對一個已經安裝的 port 打包?
如果安裝好一個套軟,事前並未打包,事後想打包的話, 以 editors/joe 為例:
# cd /var/db/pkg
# pkg_create -b joe-{版本號}
如此一來,就會將已安裝的 port 打包起來,放在 /var/db/pkg 目錄下。
20.8. 如何清理 ports 編輯期間所產生的暫存資料?
在安裝 port 的時候,通常會有編譯期間所需要的工作目錄(work),因此通常安裝好一個套件後,會清除此暫存目錄,以節省硬碟空間。 以editors/joe 為例:
# cd /usr/ports/editors/joe
# make clean
而如果是希望清除所有 ports 的暫存目錄,則:
# cd /usr/ports
# make clean
而如果是希望清除所有 ftp 分類的暫存目錄,則:
# cd /usr/ports/ftp
# make clean
20.9. 如何清理 ports 編輯期間所產生的暫存資料,以及 tarball 檔?
上面所講的 make clean 僅只是清除編輯期間所需要的工作目錄(work),並沒有將編譯 ports 時一併下載的 tarball 刪除(相對應之 tarball 預設會存放在/usr/ports/distfiles) 如果打算把 tarball 也一併清除的話,以 editors/joe 為例:
# cd /usr/ports/editors/joe
# make distclean
make distclean 的步驟包含了 make clean 的功能,也就是說除了會刪除 tarball 外,還會一併清除編譯時的暫存 work 目錄。
如果是希望清除所有 ports 的暫存 work 目錄及 tarball,則:
# cd /usr/ports
# make distclean
而如果是希望清除所有 ftp 分類的暫存目錄以及 tarball,則:
# cd /usr/ports/ftp
# make distclean
20.10. 如何在安裝 ports 前查詢所依賴的相關套件?
在安裝 ports 前,可以查詢所需依賴/相關的套件。 以 mail/p5-Mail-SpamAssassin 為例:
# cd /usr/ports/mail/p5-Mail-SpamAssassin
# make all-depends-list
make all-depends-list 顯示此套件所有相依的套件。
# cd /usr/ports/mail/p5-Mail-SpamAssassin
# make pretty-print-build-depends-list
make all-depends-list 顯示此套件在編譯期間所需要的套件。
# cd /usr/ports/mail/p5-Mail-SpamAssassin
# make pretty-print-run-depends-list
make all-depends-list 顯示此套件要執行時所需要的套件。
20.11. 如何移除已安裝的 ports?
以 editors/joe 為例:
# cd /usr/ports/editors/joe
# make deinstall
或是使用 pkg_delete
# pkg_delete joe-{version}
有時候套件之間的相依性會導致無法直接移除,如果要強制移除的話,則:
# pkg_delete -f joe-{version}
但請注意:很有可能會導致其它相依到這軟體的套件執行起來出現問題。
20.12. 如何一併移除所相依的 ports?
以 sysutils/portupgrade 為例:
# cd /usr/ports/sysutils/portupgrade
# make deinstall-depends
執行此步驟前,請注意是否會移除其他套件也有共同相依的部分。建議先參考 上面所講的 make-depends-list 的方法來檢查。
# pkg_delete joe-{version}
或者建議用:pkg_delete,這樣若仍有相依該套件的話,會先警告而不會移除。 除非有另外加了 -f 參數來強制移除...。
# pkg_delete -r joe-{version}
20.13. 如何重新安裝已安裝過的 ports?
重新安裝的前提是:之前有安裝過或目前已安裝。以 editors/joe 為例:
# cd /usr/ports/editors/joe
# make deinstall clean install
或是
# cd /usr/ports/editors/joe
# make reinstall
或是
# portupgrade -f joe
20.14. 如何以關鍵字搜尋所要找的 ports?
如果要從全部的 ports collection 中找尋與關鍵字 "ldap" 有關的 ports,則:
# cd /usr/ports
# make search key=ldap
如果只要從與 ftp 相關的 ports 下找尋與關鍵字 "ldap" 有關的 ports,則:
# cd /usr/ports/ftp
# make search key=ldap
另外,還有另一個用法,方法只是將 key 換成 name。如果已經知道要搜尋 ports 的名稱,或只想找名稱相關的關鍵字 "ldap", 則:
# cd /usr/ports
# make search name=ldap
20.15. 如何升級已安裝的 ports?
如果已經安裝套件,事後欲升級的話,必須先移除舊版的 port。以 editors/joe 為例:
# portupgrade joe
或是
# cd /usr/ports/editors/joe
# make clean reinstall
或是
# portupgrade -f joe
20.16. 如何查詢目前系統安裝了哪些套件?
查詢目前系統已安裝的全部套件:
# pkg_info
20.17. 如何查詢目前系統有沒有安裝這個關鍵字的套件?
假設要找的關鍵字是 joe 的話:
# pkg_info | grep joe
20.18. 如何查詢某個檔案是屬於哪些套件?
如果想查詢 /usr/local/bin/joe 是屬於哪個套件的話,則:
# pkg_info -W /usr/local/bin/joe
如果沒有回傳任何資訊的話,代表著這個檔案是由 FreeBSD 內建的。
20.19. 如何查詢某個套件安裝了哪些檔案?
如果想查詢目前系統所安裝的 joe 包含了哪些檔案,則:
# pkg_info -L /var/db/pkg/joe-{version}
20.20. 如何安裝舊版的 ports?
有時候會因為相依性,或是新版有問題,而會想裝舊版本的套件。 這裡介紹的方法是利用 CVS 的好處,回歸到以前舊版本存在的日子,以安裝舊版本的套件。
首先,若我們要回復到某一個套件的版本時,需要去查詢 FreeBSD ports CVS repository。 最常見的就是 Freshports 網站、 FreeBSD 的 Mailing FreeBSD cvs 或是 FreeBSD ports cvsweb
查到該套件版本所依存的日子後,就修改 CVS tag。一般預設 ports 的 CVS tag 會寫在 /usr/share/examples/cvsup/ports-supfile ,如要回溯到 2002/10/05 號的話,則:
# vi /usr/share/examples/cvsup/ports-supfile
default date=2002.10.05.00.00.00  #將 date 改成當日
然後按照一般 CVSup 或 csup 的時候一樣,執行 CVSup 或 csup (make update),此時的 ports collections 就會回到當時的情形,那麼該套件的舊版也會出現在 ports collections 中,只要安裝即可。
如果僅是想回溯某部份的 ports,則必須加上額外的資訊,如僅希望把 lang/perl5.8 回溯, 而我們得知此屬於 lang 中的一支,則:
# vi /usr/share/examples/cvsup/ports-supfile
#ports-all #將 ports-all 標示起來
ports-lang #加入這行


最後,執行 CVSup 或 csup ,並安裝即可。目前若希望單獨回溯單一的 port,則比較麻煩。

虹光大成就-密教灌頂(一)