顯示具有 FreeBSD 標籤的文章。 顯示所有文章
顯示具有 FreeBSD 標籤的文章。 顯示所有文章

[轉載]【FreeBSD】Dmidecode-查詢硬體資訊


【FreeBSD】Dmidecode-查詢硬體資訊


前言

[dmidecode] 為一套可輕鬆顯示您目前主機的各項硬體資訊套件,它查詢在您主機 BIOS 當中 SMBIOS/DMI 資訊查達到查詢各項硬體資訊的目的,例如您可查詢 CPU 類型、Cache、Memory Module、Slots、I/O Ports...等。 (請尊重 weithenn 的辛勞!!)
Dmidecode 支援作業系統類型如下:
  • FreeBSD i386, x86-64 (請尊重 weithenn 的辛勞!!)
  • NetBSD i386, x86-64
  • OpenBSD i386
  • BeOS i386
  • Cygwin i386 (請尊重 weithenn 的辛勞!!)
  • Linux i386, x86-64, ia64
  • Solaris x86


實作環境

  • FreeBSD 5.4-RELEASE
  • dmidecode-2.9 (請尊重 weithenn 的辛勞!!)

安裝及設定

步驟1.安裝 dmidecode 套件

切換至 Ports Tree 路徑安裝 dmidecode 套件 (請尊重 weithenn 的辛勞!!)
#cd /usr/ports/sysutils/dmidecode //切換到安裝路徑
#make install clean //安裝套件並清除安裝中不必要的檔案

步驟2.開始使用 dmidecode

安裝完成後即可開始使用,詳細參數可參考 [FreeBSD Man Pages - dmidecode]
  • -t (--type) Type_Number or Keyword: 參數加上硬體資訊號碼或關鍵字進行查詢 (ex. 4 = CPU、39 = Power Supply、bios、memory ...etc)
  • -s (--string) Keyword: 參數加上關鍵字進行查詢 (ex. bios-vendor、baseboard-serial-number ...etc)
  • 顯示最詳細及完整的 BIOS 硬體資訊 (請尊重 weithenn 的辛勞!!)
#dmidecode
  • 搭配 Type Number 查詢指定的硬體資訊 (請尊重 weithenn 的辛勞!!)
#dmidecode -t 4 //查詢 CPU 資訊
#dmidecode -t 39 //查詢 Power Supply 資訊
#dmidecode -t 4,39 //查詢 CPU 及 Power Supply 資訊
  • 搭配關鍵字查詢指定的硬體資訊 (請尊重 weithenn 的辛勞!!)
#dmidecode -t //顯示所有可用關鍵字
#dmidecode -t processor //查詢 CPU 資訊
#dmidecode -t memory //查詢 Memory 資訊
#dmidecode -t processor memory //查詢 CPU 及 Memory 資訊
  • 搭配關鍵字查詢指定的硬體資訊 (請尊重 weithenn 的辛勞!!)
#dmidecode -s //顯示所有可用關鍵字
#dmidecode -s bios-vendor //查詢 BIOS 製造商
#dmidecode -s baseboard-serial-number //查詢主機版序號 (Serial Number)

補充1:硬體資訊號碼及關鍵字

詳細參數可參考 [FreeBSD Man Pages - dmidecode]
硬體資訊號碼如下:
  • 0: BIOS
  • 1: System (請尊重 weithenn 的辛勞!!)
  • 2: Base Board
  • 3: Chassis
  • 4: Processor
  • 5: Memory Controller
  • 6: Memory Module
  • 7: Cache
  • 8: Port Connector (請尊重 weithenn 的辛勞!!)
  • 9: System Slots
  • 10: On Board Devices
  • 11: OEM Strings
  • 12: System Configuration Options
  • 13: BIOS Language
  • 14: Group Associations
  • 15: System Event Log
  • 16: Physical Memory Array
  • 17: Memory Device
  • 18: 32-bit Memory Error
  • 19: Memory Array Mapped Address
  • 20: Memory Device Mapped Address
  • 21: Built-in Pointing Device
  • 22: Portable Battery (請尊重 weithenn 的辛勞!!)
  • 23: System Reset
  • 24: Hardware Security
  • 25: System Power Controls
  • 26: Voltage Probe
  • 27: Cooling Device
  • 28: Temperature Probe
  • 29: Electrical Current Probe
  • 30: Out-of-band Remote Access
  • 31: Boot Integrity Services
  • 32: System Boot
  • 33: 64-bit Memory Error
  • 34: Management Device (請尊重 weithenn 的辛勞!!)
  • 35: Management Device Component
  • 36: Management Device Threshold Data
  • 37: Memory Channel
  • 38: IPMI Device
  • 39: Power Supply
硬體資訊關鍵字如下: (顯示關鍵字輸出硬體資訊等於對應的 Type Number)
  • bios: 0, 13
  • system: 1, 12, 15, 23, 32
  • baseboard: 2, 10 (請尊重 weithenn 的辛勞!!)
  • chassis: 3
  • processor: 4
  • memory: 5, 6, 16, 17
  • cache: 7 (請尊重 weithenn 的辛勞!!)
  • connector: 8
  • slot: 9

補充2:硬體 序號/版本/製造商 關鍵字

詳細參數可參考 [FreeBSD Man Pages - dmidecode]
  • BIOS
    • bios-vendor: 查詢 BIOS 製造商
    • bios-version: 查詢 BIOS 版本 (請尊重 weithenn 的辛勞!!)
    • bios-release-date: 查詢 BIOS Release 日期
  • System
    • system-manufacturer: 查詢系統製造商
    • system-product-name: 查詢系統產品名稱
    • system-version: 查詢系統版本
    • system-serial-number: 查詢系統序號 (Serial Number)
    • system-uuid: 查詢系統 UUID
  • MontherBoard (請尊重 weithenn 的辛勞!!)
    • baseboard-manufacturer: 查詢主機板製造商
    • baseboard-product-name: 查詢主機板產品名稱
    • baseboard-version: 查詢主機板版本 (請尊重 weithenn 的辛勞!!)
    • baseboard-serial-number: 查詢主機板序號 (Serial Number)
    • baseboard-asset-tag: 查詢主機板資產標籤
  • Chassis (請尊重 weithenn 的辛勞!!)
    • chassis-manufacturer: 查詢基座製造商
    • chassis-type: 查詢基座類型
    • chassis-version: 查詢基座版本 (請尊重 weithenn 的辛勞!!)
    • chassis-serial-number: 查詢基座序號 (Serial Number)
    • chassis-asset-tag: 查詢基座資產標籤
  • CPU (請尊重 weithenn 的辛勞!!)
    • processor-family: 查詢 CPU 種類/系列
    • processor-manufacturer: 查詢 CPU 製造商
    • processor-version: 查詢 CPU 版本/速度
    • processor-frequency: 查詢 CPU 處理時脈 (請尊重 weithenn 的辛勞!!)

參考

[dmidecode]
[FreeBSD Man Pages - dmidecode]
[dmidecode FreeBSD]
[Dmidecode - Linux Wiki]

Make a NanoBSD for GPT scheme on Freebsd9.0 RC1 + UEFI on VirtualBox

1. get freebsd 9.0 rc1, then install all srouce code

2. Install dmidecode ports on FreeBSD 9.0 RC1
    Path : /usr/local/sbin/dmidecode
  • # cd /usr/ports/sysutils/dmicode/
  • # make install clean
  • # ./usr/loacl/sbin/dmidecode | grep Name
    • Product Name : VirtualBox
3. Modify /usr/src/sys/amd64/amd64/machdep.c to add the string as follows
  • strncmp(sysenv, "VirtualBox", 10)  == 0 || 
4. Compile your kernel
  • # cd /sys/amd64/conf
  • # cp GENERIC NASBSD9
  • # ee NASBSD9
    • or put the file of NASBSD9 to /home/backup, and set soft link
      • #cd /usr/src/sys/amd64/conf
      • #ln -s /home/backup/NASBSD9
  • To compile your kernel
    • # cd /sys/amd64/conf
    • # config NASBSD9
    • # cd ../compile/NASBSD9
    • # make depend
    • # make
    • # make install
    • # reboot
    • # uname -a
5. Installing GRUB2
  1. Create an EFI system partition
    • On Ubuntu 11.10
      • $ apt-get install gdisk ufsutils
      • $ gdisk /dev/sdx 
      • EF00 
      • using 'gdisk' to partition an GPT format disk with an EFI system partition.
      • $ mkfs.vfat -F32 /dev/sdx1
    • On FreeBSD 8/9
      • # gpart create -s GPT /dev/adax








// ref to solve efi booting
// need to add product name from smibios, ex:VirtualBox
http://forums.freebsd.org/showthread.php?t=12198


//must to format FAT32 on flash disk in order to access EFI system for montherboard boot up.
mkfs.vfat -F32 /dev/sdc1

gpart create GPT /dev/ada0




build grub1.99 rc1


./configure LEX=/usr/local/bin/flex --with-platform=efi --target=x86_64
  • LEX=/usr/local/bin/flex
    • I installed the latest port (flex-2.5.35_4) from /usr/ports/textproc/flex
  • cd /usr/ports/lang/gcc44 
    • make install


----------------------------------------------------

// 宣告一塊虛擬memory disk -> md0
#mdconfig -a -t vnode -f _.disk.image

// 將_.disk.image 掛載在/mnt
#mount /dev/md0a /mnt

// 卸載 md0
#mdconfig -d -u 0

---------------------------------------------------

// Make a cpio+gz image
$find . | cpio -ocvB | gzip > /usr/src/tools/tools/nanobsd/nanobsd.cpio.gz

解壓縮
$gzip -dc folder1.cpio.gz | cpio -idv

------------------------------------------------------------------------

mkdir /tmp/ramdisk; chmod 777 /tmp/ramdisk
mount -t tmpfs -o size=256M tmpfs /tmp/ramdisk/

Read more: http://www.linuxscrew.com/2010/03/24/fastest-way-to-create-ramdisk-in-ubuntulinux/#ixzz1ciIwVOz3

How to use mdconfig cmd on FreeBSD

// 宣告一塊虛擬memory disk -> md0
#mdconfig -a -t vnode -f _.disk.image

// 將_.disk.image 掛載在/mnt
#mount /dev/md0a /mnt

// 卸載 md0
#mdconfig -d -u 0

Installing FreeBSD on a GPT disk


Synopsis:

These notes describe the general process for manually installing FreeBSD onto a GPT-partitioned hard disk.

Prerequisites:

Process:

  1. Boot from the FreeBSD install DVD or USB stick and run the Fixit environment.
  2. Create new partition table on ad0 using GPT scheme:
  3. # gpart create -s GPT ad0
  4. Add 'freebsd-boot' partition to contain boot code ('-s' argument specifies partition size in 512 byte blocks):
  5. # gpart add -t freebsd-boot -s 128 ad0
  6. Write Protective MBR to sector 0 of disk and gptboot code into freebsd-boot partition
  7. # gpart bootcode -b /dist/boot/pmbr -p /dist/boot/gptboot -i 1 ad0
  8. Add 'freebsd-swap' partition:
  9. # gpart add -t freebsd-swap -s 8388608 ad0
  10. Add appropriately sized 'freebsd-ufs' partitions for /, /var, /usr and /home filesystems (I use swap-based tmpfs for /tmp)
  11. # gpart add -t freebsd-ufs -s 2097152 ad0
    # gpart add -t freebsd-ufs -s 2097152 ad0
    # gpart add -t freebsd-ufs -s 41942040 ad0
    # gpart add -t freebsd-ufs ad0
    
  12. List our partition table so far
  13. # gpart show ad0
    =>       34  312581741  ad0  GPT  (149G)
             34        128    1  freebsd-boot  (64K)
            162    8388608    2  freebsd-swap  (4.0G)
        8388770    2097152    3  freebsd-ufs  (1.0G)
       10485922    2097152    4  freebsd-ufs  (1.0G)
       12583074   41942040    5  freebsd-ufs  (20G)
       54525114  258056661    6  freebsd-ufs  (123G)
    
  14. Format freebsd-ufs partitions (p3 will be the root partition so softupdates are not enabled with '-U')
  15. # newfs ad0p3
    # newfs -U ad0p4
    # newfs -U ad0p5
    # newfs -U ad0p6
    
  16. Mount partitions under /mnt:
  17. # mount /dev/ad0p3 /mnt
    # cd /mnt
    # mkdir var usr home
    # mount /dev/ad0p4 /mnt/var
    # mount /dev/ad0p5 /mnt/usr
    # mount /dev/ad0p6 /mnt/home
    
  18. Install FreeBSD distribution to mounted filesystems:
  19. # export DESTDIR=/mnt
    # cd /dist/8.1-RELEASE
    # for dir in base catpages dict doc info lib32 manpages; do (cd $dir; ./install.sh); done
    # cd kernels
    # ./install.sh GENERIC
    # cd src
    # ./install.sh all
    
  20. Copy GENERIC kernel to expected location:
  21. # cd /mnt/boot
    # rmdir kernel
    # cp -Rp GENERIC kernel
    
  22. Create a new fstab
  23. # cd /mnt/etc
    # vi fstab
    
    /dev/ad0p3      /       ufs     rw      1       1
    /dev/ad0p4      /var    ufs     rw      2       2
    /dev/ad0p5      /usr    ufs     rw      2       2
    /dev/ad0p6      /home   ufs     rw      2       2
    /dev/ad0p2      none    swap    sw      0       0
    
  24. The hard disk now contains a minimal, unconfigured FreeBSD installation and should be bootable. Exit the Fixit environment, exit Sysinstall and reboot. Remove the CD while the machine resets.
  25. FreeBSD should boot up cleanly. Perform basic configuration steps:
    • Set root's password
    • Create /etc/rc.conf, setting hostname, network interface configuration, sshd_enable, etc
    • Set timezone by copying appropriate timezone file from /usr/share/zoneinfo/*/ to /etc/localtime
    • Create non-root user account

FREEBSD 使用gpart建立超過2tb的分割區


ref:http://hd-inky.blogspot.com/2010/07/freebsd-gpart2tb.html


FREEBSD 使用gpart建立超過2tb的分割區

gpart 是 GEOM framework 裡的 tool,


透過它可以支援 multiple partitioning schemes,
在 FreeBSD 7 開始比較建議使用 gpart 而不是 gpt。


gpart跟gpt的指令參數不太一樣 不能直接套用
# gpart create -s GPT da2
# gaprt show

=> 6 1953124597 da2 GPT (7.3T)
6 1953124597 - free - (7.3T)

# gpart add -b 6 -s 1953124597 -t freebsd-ufs da2
da2p1 added

-b -s -t 這三個參數必填
-b是start , -s 是size -t是fs_type



# gpart show
=> 6 1953124597 da2 GPT (7.3T)
6 1953124597 1 freebsd-ufs (7.3T)

# newfs -O2 -b 65536 -f 8192 -U /dev/da2p1

# mount /dev/da2p1 /raid1

#df -h

Filesystem Size Used Avail Capacity Mounted on
/dev/da0s1a 62G 3.7G 54G 6% /

devfs 1.0K 1.0K 0B 100% /dev
/dev/da2p1 7.2T 16K 6.6T 0% /raid1

Install FreeBSD with GPT partitions ...

ref: http://www.freebsdonline.com/content/view/732/531/

For now sysinstall does not support GPT partition. So everything must be installed manualy but it is easy. This quick tutorial show you stept by step installation using GPT partitions. Why GPT? Better support for bigger drives (>2TB) and up to 128 partitions instead of 4.

Step 1. Partitioning the drive
----------------------------------
We boot from FreeBSD 8.2 USB image and then we go to Fixit menu and then from there we mount USB Live image, that has all necessary tools to install FreeBSD.

First we will initialize the drive to support GPT partitions:

  gpart create -s GPT ad0

Then we will proceed creating partitions. We will create partitions for boot, root, tmp, var, usr.

  gpart add -s 128 -t freebsd-boot -l boot ad0                       # for boot     (1)
  gpart add -s 5G -t freebsd-ufs -l root ad0                          # for / (root)  (2)
  gpart add -s 4G -t freebsd-ufs -l tmp ad0                          # for tmp       (3)
  gpart add -s 4G -t freebsd-swap -l swap ad0                       # for swap     (4)
  gpart add -s 10G -t freebsd-ufs -l var ad0                        # for var        (5)
  gpart add -s 200G -t freebsd-ufs -l usr ad0                      # for usr and home  (6)

To see partitions you've just created use:

  gpart show ad0

To see partition with labels use:

  gpart show -l ad0

To delete a partiton use:

  gpart delete -i3 ad0              # where 3 is third partiton.

If you want to remove GPT table from drive ad0 run (in case you want start partitioning process again):

  gpart destroy ad0


Now we will place the MBR code in our freebsd-boot partition:

  gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptboot -i 1 ad0

We need now to newfs (format) our newly created partitions:

  newfs -U /dev/ad0p2
  newfs -U /dev/ad0p3
  newfs -U /dev/ad0p5
  newfs -U /dev/ad0p6

We will mount now all partitions to install FreeBSD on them:

  mount /dev/ad0p2 /mnt
  mkdir /mnt/boot /mnt/tmp /mnt/var /mnt/usr
  mount /dev/ad0p3 /mnt/tmp
  mount /dev/ad0p5 /mnt/var  mount /dev/ad0p6 /mnt/usr


Step 2. Installing FreeBSD
-------------------------------
We will now use the install.sh script from our FreeBSD USB Image:

  export DESTDIR=/mnt
  cd /dist/8.2-RELEASE
  for dir in base catpages dict doc info lib32 manpages; do (cd $dir; ./install.sh); done

If you install FreeBSD i386 you will not need lib32 in the for loop.
Now we install the kernel:

  cd kernels
  ./install.sh GENERIC

We install the sources:

  cd ..
  cd src
  ./install.sh all

We copy the kernel in /mnt/boot/kernel directory:

  cd /mnt/boot
  rmdir kernel
  cp -Rp GENERIC kernel


Step 3. Configuring FreeBSD
-----------------------------------

Last step is to configure FreeBSD by creating /etc/fstab, /etc/resolv.conf and /etc/rc.conf files.

We edit /mnt/etc/resolv.conf file and add our dns there:

  nameserver 208.67.220.220           # that is your ISP's DNS


We create /etc/rc.conf with the following content (asuming em0 is our network card):


/etc/rc.conf
defaultrouter="10.0.0.1"
hostname="server"
ifconfig_em0="inet 10.0.0.2  netmask 255.255.255.0"
sshd_enable="YES"
We must create an /etc/fstab file with the following content:
/etc/fstab
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ad0p4             none            swap    sw              0       0
/dev/ad0p2             /               ufs     rw              1       1
/dev/ad0p3             /tmp            ufs     rw              2       2
/dev/ad0p6             /usr            ufs     rw              2       2
/dev/ad0p5             /var            ufs     rw              2       2
/dev/cd0               /cdrom          cd9660  ro,noauto       0       0

GPT Partitioning Tips
----------------------
- If you get the error "Device Busy" when you try to delete GPT from drive with gpart delete ad0 , you can succesfully delete GPT if you turn of the safety with sysctl variable:

  sysctl kern.geom.debugflags=16


- If you want to destroy GPT table from the drive with gpart delete ad0 command you must first delete all partitions (Otherwise you might get "Device Busy" error.

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

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

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.

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