2018年4月30日 星期一

安裝 Tiny Core Linux ê 法度

Tiny Core Linux 是一个足細 ê Linux, 規个系統(kernel + rootfs)只要十幾 MBytes 爾爾,
我定定因為電腦無夠濟,需要用 virtualbox 裝 server. 毋過, 若是用一般 ê linux distribution,
需要誠大 ê 空間佮 memory. 這个時陣, 用 Tiny Core Linux 就真四序.

官方網站提供 3 種版本
我干焦欲裝一寡仔小小 ê server,無需要 GUI, 所以選上細 ê Core.
Tiny Core Linux 咧走 ê 時陣, 會共所有 ê 檔案攏囥佇 ram 內底.
按呢做,會使予系統走較緊, 猶閣有就是共檔案囥佇 ram, 重開機就無去矣.
較毋免驚設定 ê 時陣重耽, 有問題,重開機就好矣。

安裝系統


我是用 VirtualBox, RAM 佮  HD 攏設定 64 MB 爾爾, 用 iso 開機

拄開始, 會看著這个畫面, 會使改變一寡仔開機 ê 設定. 毋過, 通常毋免改就會使開機矣.揤 enter 就會使得.

fdisk

開機了後, 愛共 HD 割予好. 會使用 fdisk 這个家私處理.
1. 先換身份
sudo su
2. 選擇欲割 ê HD
fdisk /dev/sda
3. 閣來, 上簡單 ê 就是全部攏配予 / (root) 就好矣.
3.1 輸入 o 建立新 ê 表
Command (m for help): o
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.
3.2 建立新 ê 分區, 全部 ê 空間攏配予伊.
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-110, default 1): Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-110, default 110): Using default value 110

3.3 共這 ê 分區設做會使用來開機
Command (m for help): a
Partition number (1-4): 1
3.4 檢查這 ê 表敢有正確
Command (m for help): p
Disk /dev/sda: 64 MB, 67108864 bytes, 131072 sectors
110 cylinders, 37 heads, 32 sectors/track
Units: cylinders of 1184 * 512 = 606208 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/sda1 *  0,1,1       109,36,32           32     130239     130208 63.5M 83 Linux
3.5 共這 ê 表寫入去 HD
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table

format

紲落去, 共這 ê 分區 format 了後, 就會使囥資料矣
root@box:~# mkfs.ext4 /dev/sda1
Creating filesystem with 65104 1k blocks and 16320 inodes
Filesystem UUID: c2309346-2069-40f3-9c45-1eb97c3cfb79
Superblock backups stored on blocks:
8193, 24577, 40961, 57345
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

安裝 boot loader (grub-0.97)

閣來, 愛對網路安裝 grub-0.97, 愛記得共網路攢予好, 原本 ê iso 無佮這 ê 軟體.
安裝 ê 時陣愛換轉去原本 ê 口座. tce-load
tc@box:~$ tce-load -wi grub-0.97-splash
閣來, 共需要用著 ê 檔案囥佇著 ê 所在就會使矣
先 mount 頭拄仔做好 ê sda1 佮 iso (sr0)
mount /mnt/sda1
mount /mnt/sr0

共開機愛用 ê kernel 佮 rootfs 裝入去
mkdir -p /mnt/sda1/boot/grub
cp -p /mnt/sr0/boot/* /mnt/sda1/boot/

tiny core linux 開機 ê 時陣會揣 tce 佇佗位, 對 tce 內底揣出需要安裝 ê 軟體
因為伊 ê 資料攏是囥佇 ram, 逐擺關機資料攏會擲㧒捔, 想欲保留 ê 軟體佮資料愛囥佇 tce 內底,
按呢, 後擺開機伊才有法度共資料抾倒轉來.
mkdir -p /mnt/sda1/tce
touch /mnt/hda1/tce/mydata.tgz

落尾, 共 boot loader ê 檔案囥入來
cp -p /usr/lib/grub/i386-pc/* /mnt/sda1/boot/grub/

grub 裝好了後, 就會使編輯開機選單
vi /mnt/sda1/boot/grub/menu.lst

下底是一个簡單 ê 例

default 0
timeout 10
title tinycore
kernel /boot/vmlinuz quiet
initrd /boot/core.gz

閣來,共 boot loader 裝入去 HD
root@box:~# grub
Probing devices to guess BIOS drives. This may take a long time.
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 16 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
Done.
grub> quit

處理了,重開機,用 HD 開機, 若有出現 grub ê 選單, 而且開機了後會使讀著 /mnt/sda1/tce, 按呢就完成矣.






沒有留言: