2015-12-22

用 Ultraiso/WinImage 製作 Bootable 大IMG軟盤鏡像

Reference 01: 用 WinImage 製作 大IMG軟盤鏡像
Reference 02: WinImage_製作_大IMG軟盤鏡像
Reference 03: The  MS-DOS  5.0 Floppy Disk Boot Record (on a 1200 KiB floppy diskette)
Reference 04: MSWIN4.1 (Windows 98) Floppy Disk Boot Record

Notes/Comments:

1. 要成功使用 Ultraiso 製作 bootable floppy image, 必須把有些隱藏檔確實拉到 image file 中. 若直接從 7z 中拉出, 就是會漏!!!

另外, 拉檔案進入 MS-DOS floppy image 時, IO.SYS/MSDOS.SYS 必須先放!!! 因為 MS-DOS floppy boot
sector 程式碼會去確認 IO.SYS 是不是第一個檔案, MSDOS.SYS 是不是第二個檔案.

至於 Windows 98(SE)/XP floppy boot sector 就沒有這樣的限制, 只要 IO.SYS 存在就好!

2. Imdisk 則無法指定 boot sector format ( dos622, w9x, ...). 無法 create new bootable floppy image. 只能修改現成的. 就不考慮了

3. WinImage 使用了那麼複雜的公式, 似乎只是想保證 n=C*H*S 四個參數值都是整數而已 (...待驗證...), 其中 C/H/S 各有其分別最大值的限制

使用 Ultraiso :

File->New->Floppy Image->select Image Size/Format->(fill in files)->save

使用 WinImage :

U盤作為維護系統,越來越受到關注,U盤的啟動也就成了為關鍵,其Syslinux引導的兼容性較高,U盤一般採用它來引導,但它對IMG鏡像啟動採用memdisk內存磁盤來引導,其memdisk普通只支持2.88MB以下的磁盤 對大於2.88MB的鏡像,要求給出其鏡像的C/H/S 值如何確定一個IMG鏡像正確的C/H/S 也就成了製作鏡像的關鍵

一、計算IMG容量:
軟盤的標準規格有 360 KB   720 KB   1440 KB 等 一般採用1440 KB為一個標準單位,也就是說一個標準的軟盤就是1.44MB. 這個標準也肯定兼容了 360 720 的規格,所以在製作軟盤鏡像時,我們就可以採用 360 720 的規格
   360除以1440等於0.25    360/1440=0.25
   720除以1440等於0.5    720/1440=0.5 (相當二個360/1440)
   0.25這個係數就給製作較大軟盤鏡像提供了一個基準參考,介於0~1之間就有 0.25 0.50 0.75 這三個數
   以 1440KB為一個標準單位來說, 就有 1440×0.25/1440×0.5/1440×0.75 從而得到製作鏡像容量的計算方法
   計算方法:
       鏡像容量=1440×n (n 整數)
       鏡像容量=1440×n.25 (n 整數)
       鏡像容量=1440×n.50 (n 整數)
       鏡像容量=1440×n.75 (n 整數)
例:1440×2.25=3240 KB 容量    1440×3.25=4680 KB 容量
    1440×2.50=3600 KB 容量    1440×3.50=5040 KB 容量
    1440×2.75=3960 KB 容量    1440×3.75=5400 KB 容量
    1440×3 =4320 KB 容量    1440×4 =5760 KB 容量 ............

二、確定C/H/S參數:
WinImage 工具製作 IMG軟盤鏡像 一般採用一個標準系統啟動盤為母盤(win98系統啟動盤),在其上進行擴容 (File->New->1.44MB->OK, then Image->Change Format->Select custom image format)

1.用WinImage打開母盤 選擇 更改格式中的自定義鏡像格式:
  其中設置:
文件系統(s): FAT 12/16 (只能選它,軟盤格式)
        每扇區字節數(B): 512 (一般選它)
        Sector per cluster (size in bytes) : 1 (512) ... 取最小值
        扇區總數(n): 鏡像容量×2 (計算方法四種之一)
        每磁道扇區數(T=S): 18(36) (採用1440×n.25 1440×n.75 選18;採用1440×n 1440×n.50 選36)
        磁頭(H): 2(8) (採用1440×n.25 1440×n.75 選2 ;採用1440×n 1440×n.50 選8 )
    註:扇區規範採用是18 36 ....進位; 磁頭採用 2 8 16....進位

2.計算C/H/S值
      C/H/S 三者相互關聯與依懶, 決定鏡像磁盤的標準參數, 其中一個有誤, 它們的關係就不存在了, 造成引導不成功
      S=每磁道扇區數(T)
      H=磁頭(H)
      C= 扇區總數(n)/(每磁道扇區數(T)×磁頭(H)) {C=整數}
      註:C 不等於整數,需重新計算容量或設置 每磁道扇區數(T)和磁頭(H)

      例一:鏡像容量=1440×2.25
            設置:
            扇區總數(n)=1440×2.25×2=6480
            每磁道扇區數(T):18    
            磁頭(H):2
       
            計算C=
            C=6480/(18×2) = 180 (整數)
                      這樣就得到了 C/H/S=180/2/18

       注意:如設置 每磁道扇區數(T)36磁頭(H)8 則C=6480/(36×8)=22.5 帶有小數, 磁道扇區沒有半個的標準,
               
       例二:鏡像容量=1440×2.50
            設置:
            扇區總數(n)=1440×2.50×2=7200
            每磁道扇區數(T):36    
            磁頭(H):8
       
            計算C=
            C=7200/(36×8) = 25 (整數)
                      這樣就得到了 C/H/S=25/8/36

      註:如設置 每磁道扇區數(T)18磁頭(H)2 則C=7200/(18×2)=200 整數也行

接下來, 就可以開始製作 bootable image:
1. Image->Boot sector properities->...
2. 放置 io.sys/kernel.sys... 至 image file.

PS:
1. Options ->Setting->Image->size limit for image loaded in memory (KB) 必須大於 floppy image file size.

3. Image->Change format->Select custom image format->Hidden sectors / Physical drive number must be 0.

4. 另外, 標準 image 容量大小可參考以下表格:


2015-12-12

How to reinstall GRUB2 EFI?

Reference 1 : How to reinstall GRUB2 EFI?
Reference 2 : Grub EFI Reinstall
Reference 3 : Linux UEFI 開機

Q : After successfully updating my bios, something went wrong and I ended up with a blinking cursor on the top left corner of a black screen. No errors, no nothing. The bios now only listed a SATA: <disc name> boot option in place of the usual UEFI ubuntu one. I'm using a GPT partitioning scheme.
I eventually found that the working solution was to properly reinstall grub-efi-amd64. So, how do I do this ?

PS: Actually, i succeeded to reinstall GRUB2 EFI on my own and will post my answer here as I was unable to find any complete how-to on this.

A : Boot your computer with a live-usb/CD in UEFI mode. I had two boot options <flash_drive> and UEFI: <flash_drive>, the second is needed to expose the efi variables in /sys/firmware/efi/ so that efibootmgr don't fail later on. Booting with the first option gives me the following error:
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try 'modprobe efivars' as root.
modprobe efivars did'nt work for me.

chroot into the broken system (similar to the ubuntu grub2 help but with efi specificities):
sudo mount /dev/sda2 /mnt #sda2 is my root partition
sudo mount /dev/sda1 /mnt/boot/efi #sda1 is my efi partition
for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt$i; done
sudo cp /etc/resolv.conf /mnt/etc/ #makes the network available after chrooting
modprobe efivars # make sure this is loaded
sudo chroot /mnt

Depending on your linux distribution, you now do different things.
For Ubuntu/Debian:
apt-get install --reinstall grub-efi-amd64
or alternatively:
apt-get install --reinstall grub-efi
update-grub
should the above give you a grub, but not a bootable one (…???…)

For Fedora (up to 16, may work for others):
yum reinstall grub-efi

In the following command, you have to replace sdX with the device which has the EFI partition you want to boot from. In --part Y you have to replace the Y with the number of the EFI partition (as in /dev/sdXY).
efibootmgr -c --disk /dev/sdX --part Y
efibootmgr -v # verify a new record called Linux is there
Now type Ctrl+D to exit chroot, unmount everything and reboot:
for i in /sys /proc /dev/pts /dev; do sudo umount /mnt$i; done
sudo umount /mnt/boot/efi #please do this. corrupted efi partitions are not nice
sudo umount /mnt
sudo reboot

2015-12-10

Can't call grubx64.efi using startup.nsh in EFI

I installed debian on VirtualBox.
When I launched it I got the regular skip startup.nsh message with the counter and the prompt right after it.

My grubx64.efi resides under FS0:\EFI\debian\, when I tried to call it directly using absolute path it didn't work so I tried putting it in startup.nsh, same result, called it with single and double quotes on both sides, tried escaping the space, still not working.

What can I do in a case where the directory name has space in it?

[Solved], All I had to do is to add the storage device by name and double quotes to handle the space character.

Full procedure:
    edit FS0:\startup.nsh
    FS0:\EFI\debian\grubx64.efi
    < ctrl+s >
    Enter
    < ctrl+q >
    reset
    Watch the magic happens.

2015-12-05

Virtualbox 與 Avira 的問題

2015/12/02 Virtual machine 突然無法開啟, 等很久之後, 出現以下訊息:

Timed out after 60014 ms waiting for child request #1 (ClosedEvents).
(rc=258)
where: supR3HardNtChildWaitFor what:5
Unknown status 258 (0x102) (258)

好在 2015/11/28 有使用 ghost 做備份. 回復之後, 第一次執行 VirtualBox VM 沒問題, 但過一陣子之後, 問題又回來了.
感覺好像是防毒軟體 (Avira) 出問題. 將其移除後, 果然就可以了. Virtualbox forum 有人也是有相同問題 : [Solved] E_FAIL (0x80004005)

Avira 用了很久, 一直存在一些小問題, 但習慣了, 就繼續使用到今.

但 2015/12/04 開始, 決定試用 Bitdefender.

2015-11-14

使用 GRUB4DOS / RMPrepUSB 的注意事項

1. 可 mount 大部份 ISO 檔案的方法
A : 參考 www.rmprepusb.com
>>> 93 - Boot almost ANY linux ISO from a grub4dos USB drive (e.g. Tails, BackTrack or even Ophcrack)!
>>> 21 - GRUB4DOS GUIDE (with videos) - how to make a multi-boot drive (+examples)

2. Error 60: File for drive emulation must be in one contiguous disk area
A1 : RMprepUSB->Drive->Make all files on drive contiguous (Ctl+F2)
A2 : Run winimage
A3 : (最笨最有效的作法) Copy USB 內容到暫存目錄, delete USB 內容, 是 delete, 不是 format. Using the Ctrl-F2 hotkey in RMPrepUSB to make all the files on the E2B drive contiguous. 再將暫存木錄之內容, 回存到 USB.
A4 : (建議的作法): Comment from http://rmprepusb.blogspot.tw/.  A nice tool you can use to help you look at the files on the USB drive and understand what is happening is the free Piriform Windows utility Defraggler. 分析之後, 針對單一檔案進行處理, 不要中斷; 千萬不要全部重組.
defraggler
Defraggler also asks if you want to erase the Recycle Bin files when you Analyze or Defrag a drive.
As you can see from the screenshot above, you can select a drive, click Analyze and then immediately see the fragmented files (shown by the red squares). You can then select a red square and Defraggler will list what files are in that block. You can then tick the checkbox next to any of these files and defragment them separately by clicking the 'Defrag checked' button. Nice!
Defraggler is not a good tool to use on the whole USB drive however. It attempts to move all the files to the beginning of the drive as well as make them contiguous. This can take a longggg time and is also uneccessary. What is more, if you Stop Defraggler during a defrag operation, it can prevent the drive from being defragged again and prevent WinContig from being able to make all the files contiguous unless you first delete a large file from the USB drive to make more room! So I would advise that you only use Defraggler to defrag single files and don't interrupt it once it has started. If you need to make all files on a drive contiguous use WinContig (or Ctrl+F2 in RMPrepUSB).
P.S. In case you missed it, in a previous blog post, I describe a case where a 6GB ISO could not be copied and then defragged on an empty 8GB USB drive and the reason why this happens.

2015-10-29

影音轉檔及字幕使用

軟體:
1. Handbrake : 從光碟片抽取影音檔, 轉換影音格式. 不提供字幕檔格式設定/編輯.
2. Avidemux : 合併/裁剪影音檔
3. ConvertZ : 字幕檔簡繁體轉換 (Microsoft Office Word, Libreoffice Writer 也都有簡繁轉換功能; 接著利用 notepad++ 轉換至 UTF-8 (檔首無 BOM))
4. Notepad++ : 改變字幕檔編碼格式為 UTF-8; 檔案大小會比原本的檔案增大約 1.5 倍; UTF-8 以 3 bytes 存中文.
5. SrtEdit : 轉換字幕檔格式 (SRT, SSA, ASS), 中文簡繁轉換, 調整字幕大小及字型
6. VLC : media player
7. PLEX : media server


=============================================================================
影音檔格式差別:

MKV:
老牌封裝格式。以可以自由調節各項設置而備受視頻壓制人員的喜愛,而且後天可以提取內掛字幕和外掛字幕都很容易。只是這個格式在安卓和iOS等移動設備上不是默認支持的,因為其相同碼率和設置下體積較大,且由於充分開放自由設置而導致的編碼不同等問題不適合移動設備觀看,另外Mac OSX也不是原生支持這種格式的。

MP4:
新興封裝格式。雖然不及MKV那般高自由度的調節選項,但是由於其被移動設備、掌機以及Mac OSX等原生支持,在移動視頻領域異軍突起,成為了很多視頻網站和論壇開始大量採用的視頻格式。不過此種格式雖然也是可以封裝其他視頻格式的,但是由於其有限的調節設定導致其後天再編輯性不強,也無法提取內嵌字幕。


=============================================================================
字幕有兩種形式

1. softsub (軟)
可以是獨立的字幕檔,也可以封裝在影片檔內. 最大的特點是可以選擇、開啟/關閉指定字幕
常見文字格式: ASS、SSA、SRT、Plain Text
常見圖形格式: DVD字幕、Blu-ray字幕

2.hardsub (硬)
如果你的播放設備不支援字幕(softsub),你就要重新編碼視訊將字幕烙印在畫面上, 但轉換編碼格式很耗時還會損失畫質. 播放時一定有字幕,因為字幕是烙印在畫面上,有畫面就有字幕

輸入字幕

支援的字幕格式:
‧ Plain Text (純文字): 僅內建
‧ SubRip (SRT): 內建、外掛
‧ Advanced SubStation Alpha (ASS): 僅內建
‧ SubStation Alpha (SSA): 僅內建
‧ DVD Subtitles (IDX+SUB): 僅內建
‧ Blu-ray Subtitles (PGS/SUP): 僅內建

字元編碼格式:
‧ UTF-7
‧ UTF-8
‧ UTF-16
‧ UTF-32

前置作業

如果 SRT 之類的文字格式字幕的字元編碼不是 Unicode 格式, 你必須先將字元編碼轉為 UTF-8 或其他 Unicode 格式

http://www.mobile01.com/topicdetail.php?f=511&t=4192036

如果是獨立的字幕檔 (非 SRT),可用 mkvmerge 將所需的字幕、視訊、音訊重新封裝為單 MKV 檔給Handbrake 或 VidCoder 讀取。如果需要匯出內建字幕,可用 gMKVExtractGUI 匯出字幕。

http://www.mobile01.com/topicdetail.php?f=510&t=4192044

由於 Handbrake 不提供字幕樣式設定選項,所以純文字字幕只能使用預設的風格/樣式,但你可以將純文字字幕轉為 ASS,並直接在 ASS 字幕內設定風格/樣式。最後再用 mkvmerge 重新封裝成單 MKV 給 Handbrake 或 VidCoder 讀取。

http://www.mobile01.com/topicdetail.php?f=510&t=4192039

Handbrake 輸出字幕設定

開啟影片後切換到 "Subtitles" 分頁; 如果字幕來源是輸入影片,則點擊 [Add Track] 之後從 "Source" 的下拉式選單選取要使用的字幕, 如果字幕來源是 SRT 檔,則點擊 [Import SRT] 來選取字幕檔案,且必須設定正確的字元編碼 (Car Code), 如果你勾選 [Burn In],則該字幕會被燒錄(烙印)至畫面上,即 "hardsub"。


HandBrake 轉檔出現亂碼 = =
除了Handbreak設定要選UTF-8之外,.srt檔有些也要用文字編輯另存成UTF-8格式。

=============================================================================

2015-10-18

RS485 & RS232 簡介

RS485 & RS232

通訊可分成串列通訊與並列通訊兩種,串列通訊是以分時方式每次傳送一個位元(bit)給接收端,像是RS232、USB等等。
若以操作模式區分可以分成單端傳輸(Single-ended transmission)與差動傳輸(Differential transmission),單端傳輸資料傳送之電壓準位的參考是地GND;而差動傳輸資料傳送之電壓準位是參考則是兩端的電位差,換句話說資料不是對地在送。
單端傳輸之缺點是抗雜訊能力較差,傳輸距離無法遠與傳輸速率慢,例如 RS232。差動傳輸之優點則是抗雜訊能力強,傳輸距離較遠與傳輸速率快,例如RS485。

 


規格
RS232 RS423 RS422 RS485
操作模式 單端傳輸 單端傳輸 差動傳輸 差動傳輸
線上允許之傳送/接受數目 1 Driver/1 Receivers 1 Driver/10 Receivers 1 Driver/10 Receivers 32 Driver/32 Receivers
最大傳輸距離 50 feet (15 m) 4000 feet (1.2 km) 4000 feet (1.2 km) 4000 feet (1.2 km)
最大傳輸速率 20 kb/s 100 kb/s 10 Mb/s 10 Mb/s
接收端之輸入靈敏度 ±3 V ±200 mV ±200 mV ±200 mV

 

RS485 簡介

RS485是一種工業標準,RS485之傳輸距離最大為1.2公里,傳送速率最大為10 Mb/s。RS485優點是抗雜訊能力強,通訊過程只需要2條線,RS485是一種半雙工傳輸,半雙工意指同一時間只能做傳送或是接收的動作,無法同時傳送與接收,像是對講機就是半雙工通訊的一種。

RS232通訊至少需要3條線(一條發射線TxD、一條接收線RxD、一條接地線GND),RS232通訊電壓準位的參考是地;而RS485傳輸不需要地線,其電壓準位的參考標準不是地,而是兩端之電位差。
RS485的電氣規格:邏輯“1”以兩線間的電壓差為+(2~6)V表示;邏輯“0”以兩線間的電壓差為-(2~6)V表示。RS485之電壓準位相較於RS-232來的低,所以較不易損壞介面電路的IC。再者,RS485電壓準位TTL電壓準位相容,也方便與TTL 電路連接。

RS485介面是採用差動傳輸方式,其抗共模能力增強,即抗雜訊干擾性好。因為RS485組成的半雙工網路,只需二條線,所以RS485介面均採用遮罩雙絞線傳輸。

應用

RS485可以是1對多甚至是多對多通訊。RS485最大傳輸距離為1.2 km,另外RS232通訊只能是1對1傳輸,而RS-485通訊可允許多對多傳輸(32 Driver 32 Receiver),故可利用RS-485介面方便地建立起設備網路。