1
0
Эх сурвалжийг харах

Oracle VM VirtualBox 安装虚拟机 Debian 10 挖坑填坑笔记

hongwenjun 4 жил өмнө
parent
commit
fd51e1e7b1
5 өөрчлөгдсөн 481 нэмэгдсэн , 0 устгасан
  1. 4 0
      README.md
  2. 312 0
      debian/README.md
  3. 8 0
      debian/autonet.sh
  4. 53 0
      debian/config.sh
  5. 104 0
      debian/sskcp.sh

+ 4 - 0
README.md

@@ -87,6 +87,10 @@ DOMAIN=ssl.srgb888.ga
 ### Debian 10 Buster 管理员手册  [在线阅读](https://debian-handbook.info/browse/zh-CN/stable/)
 
 - Debian 开发者和 Debian 手册作者 Raphaël Hertzog 宣布面向 Debian 10 的最新版本 Debian 管理员手册已上线。
+
+---
+### Oracle VM VirtualBox  安装虚拟机 Debian 10  挖坑填坑笔记 [在线阅读](https://github.com/hongwenjun/vps_setup/blob/master/debian/README.md)
+---
 ### 网友视频和白话文档
 
 - 白话文档: [OpenWRT配置](https://git.io/wrt.wg)   [Nginx反代V2ray原理](https://git.io/v2ray.nginx)   [rclone使用教程](https://github.com/hongwenjun/vps_setup/blob/master/rclone/README.md)   [Debian 安装Transmission教程和一键脚本](https://github.com/hongwenjun/vps_setup/blob/master/rclone/transmission.md)

+ 312 - 0
debian/README.md

@@ -0,0 +1,312 @@
+# Oracle VM VirtualBox  安装虚拟机 Debian 10  挖坑填坑笔记
+
+###  VirtualBox 安装虚拟机 Debian 系统 省略
+- 下载 mini.iso 网络安装,或者 debian-10.5.0-amd64-xfce-CD-1.iso 图形安装
+
+- 注意: 选择中文语言,使用中国大陆镜像,推荐中科大软件源,如果选择默认的官方站速度会很慢;即使选对中科大镜像源在安装过程中
+还是会从官方下载证书文件卡住,可以ctrl+alt+f4 切换到后台,ctrl+c停止从官方源下载资源包,不影响系统安装。安装软件选择SSH
+方便远程登陆,不要选择xfce或者KDE图形桌面,安装完成后,按下面修改 软件源
+
+-  sources.list  修改 apt 中科大软件源 配置
+```
+# vim /etc/apt/sources.list
+
+deb http://mirrors.ustc.edu.cn/debian/ buster main
+deb-src http://mirrors.ustc.edu.cn/debian/ buster main
+
+deb http://mirrors.ustc.edu.cn/debian-security buster/updates main
+deb-src http://mirrors.ustc.edu.cn/debian-security buster/updates main
+
+deb http://mirrors.ustc.edu.cn/debian/ buster-updates main
+deb-src http://mirrors.ustc.edu.cn/debian/ buster-updates main
+```
+
+## dd 命令是备份Linux系统,或者是linux系统杀手
+- 所以建立虚拟vmdk磁盘只分配了2G,方便DD,或者写U盘镜像 
+```
+#  dd指令 语法格式
+dd  [option] if=file:输入文件名,缺省为标准输入  of=file:输出文件名,缺省为标准输出
+
+测试纯写入性能
+dd if=/dev/zero of=test bs=8k count=10000 oflag=direct
+测试纯读取性能
+dd if=test of=/dev/null bs=8k count=10000 iflag=direct
+
+root@debian:~$ fdisk -l
+
+Disk /dev/sda: 2 GiB, 2147483648 bytes, 4194304 sectors
+Disk model: VBOX HARDDISK
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disklabel type: dos
+Disk identifier: 0x4ea1acbd
+
+Device     Boot Start     End Sectors Size Id Type
+/dev/sda1  *     2048 4192255 4190208   2G 83 Linux
+
+
+Disk /dev/sdb: 4 GiB, 4294967296 bytes, 8388608 sectors
+Disk model: VBOX HARDDISK
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+
+root@debian:~$ dd if=/dev/sda  of=/dev/sdb
+记录了4194304+0 的读入
+记录了4194304+0 的写出
+2147483648 bytes (2.1 GB, 2.0 GiB) copied, 91.3932 s, 23.5 MB/s
+
+
+root@debian:~$ mkfs.ext4 /dev/sdb1
+
+mke2fs 1.44.5 (15-Dec-2018)
+/dev/sdb1 contains a ext4 file system
+        last mounted on / on Tue Sep 15 20:33:12 2020
+Proceed anyway? (y,N) y
+Creating filesystem with 523776 4k blocks and 131072 inodes
+Filesystem UUID: ebe2ce7e-1543-43a7-8df9-0e7596448227
+Superblock backups stored on blocks:
+        32768, 98304, 163840, 229376, 294912
+
+Allocating group tables: done
+Writing inode tables: done
+Creating journal (8192 blocks): done
+Writing superblocks and filesystem accounting information: done
+
+
+mkdir /root/d
+mount /dev/sdb1 /root/d
+
+root@debian:~$ df -h
+文件系统        容量  已用  可用 已用% 挂载点
+udev            102M     0  102M    0% /dev
+tmpfs            24M  3.0M   21M   13% /run
+/dev/sda1       2.0G  1.3G  621M   67% /
+tmpfs           116M     0  116M    0% /dev/shm
+tmpfs           5.0M     0  5.0M    0% /run/lock
+tmpfs           116M     0  116M    0% /sys/fs/cgroup
+tmpfs            24M     0   24M    0% /run/user/0
+/dev/sdb1       2.0G  6.0M  1.9G    1% /root/d
+
+root@debian:~$ dd  if=/dev/sda | gzip > /root/d/image.gz
+记录了4194304+0 的读入
+记录了4194304+0 的写出
+2147483648 bytes (2.1 GB, 2.0 GiB) copied, 102.968 s, 20.9 MB/s
+
+```
+## VirtualBox 中如何使用U盘
+```
+以 管理员身份 打开命令提示符 CMD 查看一下U盘的 DeviceID【磁盘标识盘】:
+
+wmic diskdrive list brief
+
+使用 VBoxManage 命令生成vmdk文件 usb.vmdk
+
+cd "C:\Program Files\Oracle\VirtualBox"
+
+VBoxManage.exe internalcommands createrawvmdk -filename "C:\VPC\usb.vmdk" -rawdisk \\.\PhysicalDrive3
+
+RAW host disk access VMDK file C:\VPC\usb.vmdk created successfully.
+
+===   usb.vmdk  文件内容 ===
+
+# Disk DescriptorFile
+version=1
+CID=db9f2dfb
+parentCID=ffffffff
+createType="fullDevice"
+
+# Extent description
+RW 8036352 FLAT "\\.\PhysicalDrive3" 0
+
+# The disk Data Base 
+#DDB
+
+ddb.virtualHWVersion = "4"
+ddb.adapterType="ide"
+ddb.geometry.cylinders="7972"
+ddb.geometry.heads="16"
+ddb.geometry.sectors="63"
+ddb.uuid.image="8dcce260-7a5f-462c-878f-01786958e77f"
+ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
+ddb.uuid.modification="00000000-0000-0000-0000-000000000000"
+ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
+
+```
+
+## 使用 VBoxManage 将vmdk文件转换成IMG文件
+- 语法:VBoxManage clonehd  源文件.vmdk  目标文件.img  --format RAW
+```
+VBoxManage clonehd  debian-disk001.vmdk   debian10.img --format RAW
+
+0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
+Clone medium created in format 'RAW'. UUID: 76294339-5652-45d9-97e0-eab5688aa2aa
+```
+
+## Debian 10 默认安装了N多  realtek  intel 等主要硬件厂商网卡
+```
+ls /lib/modules/4.19.0-10-amd64/kernel/drivers/net/ethernet
+
+3com     alteon    atheros   chelsio  emulex     huawei   mellanox   natsemi    packetengines  sfc    sun     xircom
+8390     amazon    broadcom  cisco    fealnx.ko  intel    micrel     neterion   qlogic         silan  tehuti
+adaptec  amd       brocade   dec      fujitsu    jme.ko   microchip  netronome  rdc            sis    ti
+agere    aquantia  cavium    dlink    hp         marvell  myricom    nvidia     realtek        smsc   via
+
+lspci | grep Ethernet
+
+00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
+
+lsmod
+e1000                 155648  0
+
+```
+## Debian 10 迁移系统网卡不能自动获取IP修改方法
+```
+ip addr
+
+2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
+    link/ether 08:00:27:d3:49:8d brd ff:ff:ff:ff:ff:ff
+    inet 192.168.1.111/24 brd 192.168.1.255 scope global dynamic enp0s3
+
+cat /etc/network/interfaces
+
+# This file describes the network interfaces available on your system
+# and how to activate them. For more information, see interfaces(5).
+
+source /etc/network/interfaces.d/*
+
+# The loopback network interface
+auto lo
+iface lo inet loopback
+
+# The primary network interface
+allow-hotplug enp0s3
+iface enp0s3 inet dhcp
+
+
+vim /etc/network/interfaces
+### 修改interfaces中的网卡名字enp0s3同 ip addr获得的网卡名字相同
+
+systemctl restart networking.service
+
+# debian系统下重启停止网卡命令
+ifdown enp0s3
+ifup enp0s3
+```
+![](https://raw.githubusercontent.com/hongwenjun/img/master/debian/autonet.png)
+
+##  autonet.sh  自动修改interfaces 网卡自动加载
+```
+lspci | grep Ethernet
+ni=$(ip addr | grep enp | head -n 1 | awk -F ': '  '{print $2}')
+sed -i "s/enp[a-zA-Z0-9]*/${ni}/g"  /etc/network/interfaces
+ifup $ni
+```
+
+## debian使用 parted 工具 调整磁盘分区
+```
+apt install parted
+
+root@debian:~$ partx /dev/sda
+NR START     END SECTORS SIZE NAME UUID
+ 1  2048 4192255 4190208   2G      4ea1acbd-01
+
+root@debian:~$ parted
+
+(parted) help
+	print     显示分区表,可用设备,可用空间,所有找到的分区或特定分区
+	quit                     退出程序
+
+	resizepart NUMBER END    调整分区号
+	rm NUMBER                删除分区
+
+其他详细命令
+https://www.howtoing.com/parted-command-to-create-resize-rescue-linux-disk-partitions/
+
+```
+## debian 使用 ntfs-3g 挂载读取Windows NTFS系统文件
+```
+  apt search ntfs-3g     # 搜索工具在哪个安装包
+  apt install  ntfs-3g
+
+	使用语法:mount  -t  ntfs-3g  分区设备文件名    挂载点
+	
+	查找分区的设备文件名:fdisk -l
+	
+	执行挂载:mount  -t ntfs-3g /dev/sdb1  /mnt/usb
+	
+	访问数据:ls -l  /mnt/usb
+	
+	卸载:umount  /mnt/usb
+  
+  umount -a  全卸载挂载
+```
+## Debian 语言设置
+-   vim /etc/default/locale
+```
+# 英文显示
+LANG=en_US.UTF-8
+
+# 中文显示
+LANG="zh_CN.UTF-8"
+LANGUAGE="zh_CN:zh"
+```
+
+## DEBIAN LOCALE LANGUAGE SETTINGS & Modify Interfaces
+```
+#########   Debain config.sh  ###########
+#!/bin/bash
+
+en_US()
+{
+	cat <<EOF >/etc/default/locale
+LANG=en_US.UTF-8
+EOF
+	echo -e "Please log in again on Debian tty1"
+}
+
+zh_CN()
+{
+	cat <<EOF >/etc/default/locale
+# 中文显示
+LANG="zh_CN.UTF-8"
+LANGUAGE="zh_CN:zh"
+EOF
+
+	echo -e "Please log in again on Debian tty1"
+
+}
+
+autonet()
+{
+# 自动修改interfaces 网卡自动加载
+lspci | grep Ethernet
+ni=$(ip addr | grep enp | head -n 1 | awk -F ': '  '{print $2}')
+sed -i "s/enp[a-zA-Z0-9]*/${ni}/g"  /etc/network/interfaces
+ifup $ni
+
+}
+
+# 设置菜单
+start_menu()
+{
+    echo -e ":: DEBIAN LOCALE LANGUAGE SETTINGS & Modify Interfaces"
+    read -p ":: Please enter the number <1>:English  <2>:Chinese :: <8> AutoModify Interfaces  "  num_x
+    case "$num_x" in
+        1)
+        en_US
+        ;;
+        2)
+        zh_CN
+        ;;
+        8)
+        autonet
+        ;;
+		esac
+}
+start_menu
+
+#################################################
+```
+

+ 8 - 0
debian/autonet.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+# autonet.sh  自动修改interfaces 网卡自动加载
+
+lspci | grep Ethernet
+ni=$(ip addr | grep enp | head -n 1 | awk -F ': '  '{print $2}')
+sed -i "s/enp[a-zA-Z0-9]*/${ni}/g"  /etc/network/interfaces
+ifup $ni
+

+ 53 - 0
debian/config.sh

@@ -0,0 +1,53 @@
+#########   Debain config.sh  ###########
+#!/bin/bash
+
+en_US()
+{
+	cat <<EOF >/etc/default/locale
+LANG=en_US.UTF-8
+EOF
+	echo -e "Please log in again on Debian tty1"
+}
+
+zh_CN()
+{
+	cat <<EOF >/etc/default/locale
+# 中文显示
+LANG="zh_CN.UTF-8"
+LANGUAGE="zh_CN:zh"
+EOF
+
+	echo -e "Please log in again on Debian tty1"
+}
+
+autonet()
+{
+# 自动修改interfaces 网卡自动加载
+lspci | grep Ethernet
+ni=$(ip addr | grep enp | head -n 1 | awk -F ': '  '{print $2}')
+sed -i "s/enp[a-zA-Z0-9]*/${ni}/g"  /etc/network/interfaces
+ifup $ni
+
+}
+
+# 设置菜单
+start_menu()
+{
+    echo -e ":: DEBIAN LOCALE LANGUAGE SETTINGS & Modify Interfaces"
+    read -p ":: Please enter the number <1>:English  <2>:Chinese :: <8> AutoModify Interfaces  "  num_x
+    case "$num_x" in
+        1)
+        en_US
+        ;;
+        2)
+        zh_CN
+        ;;
+        8)
+        autonet
+        ;;
+		esac
+}
+start_menu
+
+#################################################
+

+ 104 - 0
debian/sskcp.sh

@@ -0,0 +1,104 @@
+#!/bin/bash
+
+SERVER_IP=188.188.188.188
+PORT=1999
+PASSWORD=wg2999
+SS_PORT=40000
+
+start(){
+  # SS + KcpTun + Udp2RAW
+    udp2raw -c -r$SERVER_IP:$PORT -l0.0.0.0:4000 -k $PASSWORD --raw-mode  faketcp -a >> /var/log/udp2raw.log &
+    kcp-client -r 127.0.0.1:4000 -l :$SS_PORT --key $PASSWORD -mode fast2 -mtu 1300  >> /var/log/kcp-client.log  2>&1 &
+
+  # ss-local -s 服务器IP地址  -p 服务器端口  -b 绑定本地IP  -l 本地端口  -k 密码  -m 加密方式 [-c 配置文件]
+    ss-local -s 127.0.0.1 -p $SS_PORT -b 0.0.0.0 -l 1080 -k $PASSWORD -m aes-256-gcm  -t 300 >> /var/log/ss-local.log &
+
+    status
+}
+
+stop(){
+    killall -9 kcp-client
+    killall -9 udp2raw
+    killall -9 ss-local
+}
+
+restart(){
+    stop
+    start
+}
+
+help(){
+    echo -e "${SkyBlue}:: Source: ${Green}https://git.io/sskcp.sh  ${Font}By 蘭雅sRGB"
+    echo -e "${SkyBlue}:: Usage: ${GreenBG} bash sskcp.sh ${Yellow} [start|stop|restart|set] ${Font}"
+    echo
+}
+
+status(){
+    # log 和 命令行参数
+    cat /var/log/udp2raw.log | tail
+    cat /var/log/kcp-client.log | tail
+    cat /var/log/ss-local.log | tail
+    echo
+
+    if [[ -e /etc/openwrt_release ]]; then
+       ps | grep  -e udp2raw -e kcp-client -e ss-local
+    else
+       ps ax | grep --color=auto -e udp2raw -e kcp-client -e ss-local
+    fi
+    echo
+}
+
+setconf()
+{
+    echo -e "${SkyBlue}:: 修改脚本sskcp.sh记录参数,按${RedBG}<Enter>${SkyBlue}不修改! ${Yellow}"
+    head -n 6 sskcp.sh | tail -n 4  &&  echo -e "${SkyBlue}"
+
+    read -p ":: 1.请输入远程服务器IP: "  sv_ip
+    read -p ":: 2.请输入udp2raw 端口: "  port
+    read -p ":: 3.请输入套接转发密码: "  passwd
+    read -p ":: 4.请输入 SS 服务端口: "  ss_port
+
+    if [[ ! -z "${sv_ip}" ]]; then
+        sed -i "s/^SERVER_IP=.*/SERVER_IP=${sv_ip}/g"  "sskcp.sh"
+    fi
+    if [[ ! -z "${port}" ]]; then
+        sed -i "s/^PORT=.*/PORT=${port}/g"  "sskcp.sh"
+    fi
+    if [[ ! -z "${passwd}" ]]; then
+        sed -i "s/^PASSWORD=.*/PASSWORD=${passwd}/g"  "sskcp.sh"
+    fi
+    if [[ ! -z "${ss_port}" ]]; then
+        sed -i "s/^SS_PORT=.*/SS_PORT=${ss_port}/g"  "sskcp.sh"
+    fi
+
+    echo -e "${Yellow}" && head -n 6 sskcp.sh | tail -n 4 &&  echo -e "${Font}"
+}
+
+system_def(){
+	Green="\033[32m"  && Red="\033[31m" && GreenBG="\033[42;37m" && RedBG="\033[41;37m"
+	Font="\033[0m"  && Yellow="\033[0;33m" && SkyBlue="\033[0;36m"
+}
+
+# 脚本命令参数
+system_def
+if [[ $# > 0 ]]; then
+    key="$1"
+    case $key in
+        start)
+          start
+        ;;
+        stop)
+          stop
+        ;;
+        restart)
+          restart
+        ;;
+        set)
+          setconf
+        ;;
+    esac
+else
+    status
+fi
+help
+