当前位置 博文首页 > 文章内容

    Tiny Core Linux 安装配置

    作者: 栏目:未分类 时间:2020-09-29 15:01:37

    本站于2023年9月4日。收到“大连君*****咨询有限公司”通知
    说我们IIS7站长博客,有一篇博文用了他们的图片。
    要求我们给他们一张图片6000元。要不然法院告我们

    为避免不必要的麻烦,IIS7站长博客,全站内容图片下架、并积极应诉
    博文内容全部不再显示,请需要相关资讯的站长朋友到必应搜索。谢谢!

    另祝:版权碰瓷诈骗团伙,早日弃暗投明。

    相关新闻:借版权之名、行诈骗之实,周某因犯诈骗罪被判处有期徒刑十一年六个月

    叹!百花齐放的时代,渐行渐远!



    Published 2020年9月1日 by garlic

    Tiny Core Linux 安装配置

    简介

    Tiny Core Linux是一个mini Linux操作系统,基于 BusyBoxFLTK提供基本功能。 其发行版本在11M-16M 官网上也提供Plus版本也只有106M。它很精致。

    安装

    操作系统安装

    镜像下载

    下载页面 http://tinycorelinux.net/downloads.html
    我下载了两个版本镜像:

    • x86版本: TinyCore-11.1.iso
    • x86_64位版本:TinyCorePure64-11.1.iso

    环境准备

    我们使用的vmware 首先新建一个linux虚拟机, 我选的版本是其他Linux5.x或更高版本内核64位, 并添加了两块SATA的硬盘(默认的SCSI硬盘识别似乎有些问题)

    开始安装

    安装过程主要下面三个步骤 :

    • 光盘启动操作系统;
    • 配置网络
    • 下载安装脚本安装;

    1 . 选择镜像: 光盘镜像选择 x86版本:TinyCore-11.1.iso (不影响安装)
    2 . 启动系统: 启动后会出现四个选项, 选择第三项

    Boot TinyCore
    Boot TinyCore (on slow devices, waitusb=5)
    Boot Core (command line only)
    Boot Core (command line only on slow devices, waitusb=5)
    

    可以看到系统后进入命令行窗口,但是这种模式下进行操作重启将全部丢失。要保留我们相关配置,需要挂载硬盘。

    3 . 配置网络: 配置网卡地址路由及域名服务器。

    sudo ifconfig eth0 192.168.xxx.202 netmask 255.255.255.0
    sudo route add default gw 192.168.xxx.1 dev eth0
    sudo echo nameserver 192.168.xxx.1 >> /etc/resolv.conf
    

    4 . 下载安装脚本: 会联机下载相关安装包

    tce-load -wi tc-install.tcz
    

    5 . 安装:

    • 启动安装脚本
    sudo tc-install.sh
    
    • 选择c从光盘启动
    Core Installation.
    Install from [R]unning OS, from booted [C]drom, from
     [I]so file, or from [N]et. (r/c/i/n): c
    
    • 选择f安装到本地硬盘
    Select install type for /mnt/sr0/boot/core.gz
    
    Frugal
    * Use for frugal hard drive installations.
    Note: You will be prompted for disk/partion and 
    formatting options.
    
    HDD
    * Use for pendrives. Your BIOS must support USB-HDD booting.
    * A single FAT partition will be made.
    Note: Requires dosfstools extension.
    Warning: This is a whole drive installation!
    
    Zip
    * Use for pendrives. Drive will be formatted into two FAT partitions.
    * One small one for USB_ZIP boot compatibility, and used to hold Tiny Core.
    * The remaining partition will be used for backup & extensions.
    Note: Requires dosfstools and perl extensions.
    Warning: This is a whole drive installation!
    
    Select Install type [F]rugal, [H]DD, [Z]ip. (f/h/z): f
    
    • 选择1使用整个硬盘安装
    Select Target for Installation of core
    
     1. Whole Disk
     2. Partition
    
    Enter selection ( 1 - 2 ) or (q)uit: 1
    
    • 选择1安装到第一块硬盘上
    Select disk for core
    
     1. sda
     2. sdb
    
    Enter selection ( 1 - 2 ) or (q)uit: 1
    
    • 安装bootloader选择y
    Would you like to install a bootloader?
    Most people should answer yes unless they are trying to embed Core
    into a different Linux distribution with an existing bootloader.
    
    Enter selection ( y, n ) or (q)uit: y
    Install Extensions from this TCE/CDE Directory: 
    
    • 选择分区格式 ext4
    Select Formatting Option for sda
    
     1. ext2
     2. ext3
     3. ext4
     4. vfat
    
    Enter selection ( 1 - 4 ) or (q)uit: 3
    
    • 设置一些启动选项, 这里先不输入, 直接回车
    Enter space separated boot options: 
    Example: vga=normal syslog showapps waitusb=5
    
    • 选择y,开始安装
    Last chance to exit before destroying all data on sda
    Continue (y/..)?
    
    • 安装完毕后有以下信息回显, 安装完毕.
    Writing zero's to beginning of /dev/sda
    Partitioning /dev/sda
    Formatting /dev/sda1
    mke2fs 1.45.4 (23-Sep-2019)
    1+0 records in
    1+0 records out
    440 bytes (440B) copied, 0.000846 seconds, 507.9KB/s
    UUID="XXXXXXX"
    Applying syslinux.
    /mnt/drive/tce/boot/extlinux is device /dev/sda1
    Setting up core image on /mnt/sda1
    Installation has completed
    Press Enter key to continue.
    

    按照这个步骤把第二块硬盘也安装一下. 第二块硬盘使用镜像
    TinyCorePure64-11.1.iso 安装, 使用umount卸载原有x86镜像,mount重新挂载新的镜像。

    sudo umount /dev/sr0
    ...
    sudo mount /dev/sr0
    

    6 . 重启动,进入配置阶段

    配置

    启动后默认进入X86版本系统, 下面开始配置grub2,openssh等,其中需要注意的是 Tiny linux相关设置如果不执行filetool.sh, 只是临时生效,重启系统就会丢失。

    相关软件包安装需要先配置网络然后联网通过tce工具下载即可, 如果要长期使用需要做持久化处理。

    网络配置

    配置网络并支持永久生效

    • 生成文件/opt/eth0.sh 文件内容:
    sudo ifconfig eth0 192.168.xxx.202 netmask 255.255.255.0
    sudo route add default gw 192.168.xxx.1 dev eth0
    sudo echo nameserver 192.168.xxx.1 >> /etc/resolv.conf
    
    • 增加可执行权限
    chmod 755 /opt/eth0.sh
    sudo /opt/eth0.sh
    
    • 设置开机启动及永久生效
    sudo echo "/opt/eth0.sh" >> /opt/.filetool.lst
    sudo chmod 775 /opt/bootlocal.sh
    sudo echo "/opt/eth0.sh &" >> /opt/bootlocal.sh
    filetool.sh -b
    

    开机启动配置

    • 联网后使用tce安装grub2
    tce-load -wi grub2-multi.tcz
    sudo grub-install --target=i386-pc --boot-directory=/mnt/sda1/boot /dev/sda
    
    • 生成 grub.cfg文件
    menuentry "x86" {
        set root=(hd0, 1)
        linux /tce/boot/vmlinuz tce=sda1
        initrd /tce/bot/core.gz
    }
    
    menuentry "x86_64" {
        set root=(hd1, 1)
        linux /tce/boot/vmlinuz64 tce=sdb1
        initrd /tce/bot/corepure64.gz
    }
    

    这部分修改由于本事就在硬盘上不需要做持久化处理, 重新启动就可以看到grub2启动界面

    *x86
     x86_64
    

    openssh配置

    • 如果需要远程登录可以安装openssh
    tce-load -wi openssh.tcz
    
    • 相关配置文件生成
    cd /usr/local/etc/ssh
    sudo cp sshd_config.orig sshd_config
    
    • 设置密码
    passwd
    
    • 持久化处理
    sudo echo '/usr/local/etc/ssh' >> /opt/.filetool.lst
    sudo echo '/etc/shadow' >> /opt/.filetool.lst
    filetool.sh -b
    sudo echo '/usr/local/etc/init.d/openssh start &' >> /opt/bootlocal.sh
    
    • 配置免密
      生成SSH key, 使用 ssh-keygenPuTTY Key Generator可以生成公私钥对, 公钥上传服务器/home/tc/.ssh目录命名为authorized_keys

       

    • 相关问题
      安装过程中报错 : server refused our key

       

      • 公钥格式: 如果使用 putty key generator界面上会提示要拷贝的公钥文件内容,需要改为 openssh 使用的公钥格式, 或者使用下面命令转换
      ssh-keygen -i -f 公钥文件名
      
      • 权限调整:去掉组权限
      chmod 700 ~/.ssh
      chmod 600 ~/.ssh/authorized_keys
      
    • 永久保存处理

       

    sudo echo '/home/tc/.ssh/' >> /opt/.filetool.lst
    filetool.sh -b
    

    这样就可以通过ssh远程免密登录了

    新增硬盘

    • 安装gdisk
    tce-load -wi gdisk.tcz
    
    • 使用gdisk 创建两个500M分区, 重启生效
    brw-rw----    1 root     staff       8,  33 Sep  2 04:51 /dev/sdc1
    brw-rw----    1 root     staff       8,  34 Sep  2 04:51 /dev/sdc2
    
    • 格式化
    mkfs.ext2 /dev/sdc1
    mkfs.ext3 /dev/sdc2
    
    • 修改/etc/fstab
    /etc/fstab
    /dev/sdc1       /mnt/sdc1       ext2     noauto,users,exec    0 0 # Added by TC
    /dev/sdc2       /mnt/sdc2       ext3     noauto,users,exec    0 0 # Added by TC
    
    • 修改bootlocal.sh启动后自动挂载
    echo "sudo mount /dev/sdc1 &" >> /opt/bootlocal.sh
    echo "sudo mount /dev/sdc2 &" >> /opt/bootlocal.sh
    filetool.sh -b
    sudo reboot
    ...
    
    $ mount
    rootfs on / type rootfs (rw,size=633520k,nr_inodes=223783)
    ...
    /dev/sdc1 on /mnt/sdc1 type ext2 (rw,relatime)
    /dev/sdc2 on /mnt/sdc2 type ext3 (rw,relatime)
    

    参考

    Assign Persistent Static IP Address to Tiny Core Linux
    Install Tiny Core Linux on Local Disk (Frugal)
    Configure SSH Server on Tiny Core Linux using openSSH
    Trying to do ssh authentication with key files: server refused our key

     

     

    出处:https://garlicspace.com/2020/09/02/tiny-core-linux-%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/