Scaleway星尘安装AlpineLinux
/ 9 min read
TOC
添加SSH-key
按照官方文档创建或者添加一个公钥
ssh-key 添加:https://console.scaleway.com/project/ssh-keys
创建实例
控制台或者CLI创建一个实例,只能创建10g开机,待会才能修改 1GB硬盘
不要使用CLI强开!机子缺货的话会卡在ing状态,无法开机也无法关机
法国:scw instance server create zone=fr-par-1 root-volume=block:10GB name=fr type=STARDUST1-S ipv6=true ip=none
荷兰:scw instance server create zone=nl-ams-1 root-volume=block:10GB name=nl type=STARDUST1-S ipv6=true ip=none
波兰:scw instance server create zone=pl-waw-2 root-volume=block:10GB name=pl type=STARDUST1-S ipv6=true ip=none
##返回服务器信息表示命令执行成功。如果返回各种乱七八糟参数,表示命令输入有误,需重新执行。
安装实例
常用命令
使用命令行操作减少扣费,通过面板操作开关机都会收取0.01费用
##重启scw instance server reboot <实例的InstanceID>
##启动scw instance server start <实例的InstanceID>
##关机scw instance server stop <实例的InstanceID>
更改 1GB 硬盘
- 左侧 Instances,进入实例管理面板,输入命令关机
- 分离 10GB 硬盘:实例管理面板,Attached volumes 选项卡,在硬盘右侧三个点选 Detach 解绑
- 创建 1GB 硬盘:点击 Create Volume 创建 Local Storage,大小 1GB
- 删除 10GB 硬盘:左侧 Instances,Volumes 选项卡,旧 10GB 硬盘右侧三个点选 Delete 删除
救援恢复模式启动
- 在实例管理面板的 Advanced settings 选项卡中,选中 Use rescue image,保存
- 面板关机:左侧 Instances,进入实例管理面板,右上角开关,开机
- 重启后耐心等待 10 分钟,通过创建的 SSH Key 连接实例,执行命令:
我不想要硬盘呢?直接启动救援模式后在block storage中解绑硬盘并删除即可!只有block能在启动后解绑 Local不行,最低每月0.11欧运行,cloud-init可能不起作用
parted /dev/vda mklabel gpt
wget -qO- https://dl-cdn.alpinelinux.org/alpine/v3.21/releases/x86_64/alpine-virt-3.21.3-x86_64.iso | dd of=/dev/vda
使用最新镜像到官网获取
https://alpinelinux.org/downloads/
Virtual - x86_64
改硬盘启动
- 面板关机:左侧 Instances,进入实例管理面板,右上角开关,关机
- 更改硬盘启动:实例管理面板,Advanced settings 选项卡
- 选中 Use local boot,保存,Boot volume 选择 1GB 硬盘,保存,开机
安装 Alpine Linux
进入Console
实例 overview 选项卡 的右上方 进入 console,再进行开机, 用户名 root 密码无
前置配置
mkdir /media/setupcp -a /media/vda/* /media/setupmkdir /lib/setupcp -a /.modloop/* /lib/setup/etc/init.d/modloop stopumount /dev/vdamv /media/setup/* /media/vda/mv /lib/setup/* /.modloop/
export BOOT_SIZE=33## 配置efi分区为33mb
set 配置
setup-alpine
主机名
ALPINE LINUX INSTALL----------------------Hostname----------Enter system hostname (fully qualified form, e.g. 'foo.example.org') [localhost] NLHostname must only contain letters (a-z), digits (0-9), '.' or '-'Enter system hostname (fully qualified form, e.g. 'foo.example.org') [localhost] nl
网口
Interface-----------Available interfaces are: eth0.Enter '?' for help on bridges, bonding and vlans.Which one do you want to initialize? (or '?' or 'done') [eth0]done [输入done]Do you want to do any manual network configuration? (y/n) [n] y [输入y进入配置]
[进入配置按i输入内容,在后面追加,ip和网关改成自己的]
auto eth0iface eth0 inet6 static address 2001:bc8:1640:1640:1640:ff:1640:1640/64 gateway fe80::1640:ff:1640:1640
DNS本地域名
回车跳过
DNS domain name? (e.g 'bar.com')DNS nameserver(s)?
ROOT密码
Root Password---------------Changing password for rootNew password:Bad password: too weakRetype password:passwd: password for root changed by root
时区
随意填写。回车跳过
巴黎 Europe/Paris
阿姆斯特丹 Europe/Amsterdam
华沙 Europe/Warsaw
Timezone----------Africa/ Egypt Iran PolandAmerica/ Eire Israel PortugalAntarctica/ Etc/ Jamaica ROCArctic/ Europe/ Japan ROKAsia/ Factory Kwajalein SingaporeAtlantic/ GB Libya TurkeyAustralia/ GB-Eire MET UCTBrazil/ GMT MST US/CET GMT+0 MST7MDT UTCCST6CDT GMT-0 Mexico/ UniversalCanada/ GMT0 NZ W-SUChile/ Greenwich NZ-CHAT WETCuba HST Navajo ZuluEET Hongkong PRC leap-seconds.listEST Iceland PST8PDT posixrulesEST5EDT Indian/ Pacific/
Which timezone are you in? (or '?' or 'none') [UTC]
Proxy
不设置代理,回车跳过
Proxy-------HTTP/FTP proxy URL? (e.g. 'http://proxy:8080', or 'none') [none]
软件源
输入 skip
跳过稍后设置CDN的源
APK Mirror------------wget: bad address 'mirrors.alpinelinux.org'wget: bad address 'mirrors.alpinelinux.org'(f) Find and use fastest mirror(s) Show mirrorlist(r) Use random mirror(e) Edit /etc/apk/repositories with text editor(c) Community repo enable(skip) Skip setting up apk repositories
Enter mirror number or URL: [1] skip
用户
设置用户与公钥
User------Setup a user? (enter a lower-case loginname, or 'no') [no]Which ssh server? ('openssh', 'dropbear' or 'none') [openssh]Allow root ssh login? ('?' for help) [prohibit-password]Enter ssh key or URL for root (or 'none') [none] 这里粘贴公钥,不显示* service sshd added to runlevel default* Caching service dependencies ...[ ok ]ssh-keygen: generating new host keys: RSA ECDSA ED25519* Starting sshd ...[ ok ]
安装到硬盘
因为没安装引导,随便填填跳过即可
Disk & Install----------------Available disks are:vda (1.0 GB 0x1af4 )
Which disk(s) would you like to use? (or '?' for help or 'none') [none] vda
The following disk is selected:vda (1.0 GB 0x1af4 )
How would you like to use it? ('sys', 'data', 'crypt', 'lvm' or '?' for help) [?] sysERROR: unable to select packages:dosfstools (no such package):required by: world[dosfstools]grub-efi (no such package):required by: world[grub-efi]
配置DNS64服务器以访问ipv4资源
输入下面命令配置DNS64服务器
echo "nameserver 2a00:1098:2c::1" | tee /etc/resolv.conf > /dev/null
配置CDN软件源
echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/main" >> /etc/apk/repositoriesecho "http://dl-cdn.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositoriesecho "##http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositoriesecho "##http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositoriesecho "##http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
安装引导并安装到硬盘
apk updateapk add dosfstoolsapk add grub-efi
setup-disk -s 0
正式安装并关闭swap
setup-disk -s 0Available disks are: vda (1.0 GB 0x1af4 )
Which disk(s) would you like to use? (or '?' for help or 'none') [vda] vda
The following disk is selected: vda (1.0 GB 0x1af4 )
How would you like to use it? ('sys', 'data', 'crypt', 'lvm' or '?' for help) [?] sys
WARNING: The following disk(s) will be erased: vda (1.0 GB 0x1af4 )
WARNING: Erase the above disk(s) and continue? (y/n) [n] yCreating file systems...mkfs.fat 4.2 (2021-01-31)Installing system on /dev/vda2:Installing for x86_64-efi platform.Installation finished. No error reported.
Installation is complete. Please reboot.
看到最后面即安装成功
必须要的安全措施
SSH
因为之前设置了公钥登陆,禁用密码也会一起启用。修改ssh22端口改为1w端口往后即可,
vi /etc/ssh/sshd_config
//找到 ##Port 22 去掉 ##
改成想要的端口号保存
service sshd restart重启服务
常用命令
安装并更新常用软件
apk update
apk add wget curl unzip zip jq bash htop
apk del 删除软件名rc-update add 添加开机自启的服务名rc-update del 删除开机自启的服务名
#查看服务状态rc-status
#服务管理start stop restartservice sshd restart
开启BBR
echo "tcp_bbr" >> /etc/modules-load.d/bbr.confmodprobe tcp_bbrecho "net.core.default_qdisc=fq_pie" >> /etc/sysctl.confecho "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.confsysctl -p
重启生效 reboot
验证
lsmod | grep bbr
//出现以下内容表示成功:tcp_bbr
IPV4出口
(选择1) 安装warp
https://gitlab.com/fscarmen/warp
ipv6可能无法访问部分资源,需要提前设置ipv4出口
安装bashapk add bash
下载并运行脚本wget -N https://gitlab.com/fscarmen/warp/-/raw/main/menu.sh && bash menu.sh
选择为 IPv6 only 添加 WARP IPv4 网络接口 (bash menu.sh 4)
(选择2) DNS64
https://nat64.xyz/ 这里查看更多
探针列表 https://stats.uptimerobot.com/GQ5RyTJLKZ
修改 /etc/resolv.conf
nameserver 2a00:1098:2c::1nameserver 2a01:4f9:c010:3f02::1nameserver 2a00:1098:2b::1