【Linux相关】ubuntu部署说明
一、配置远程桌面连接
1、配置网络
- 修改网络配置信息
root@node253:~# cat /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
ens160:
dhcp4: false
addresses: [172.16.21.243/24]
ens192:
dhcp4: false
addresses: [66.66.67.253/24]
gateway4: 66.66.66.1
nameservers:
addresses: [114.114.114.114,8.8.8.8]
root@node253:~# netplan --debug apply
2、配置ssh登录
- 安装openssh-server,开放22端口
sudo apt-get install openssh-server
sudo ufw allow 22
- 配置允许root用户远程登录,重启ssh服务
root@node253:~# cat /etc/ssh/sshd_config
LoginGraceTime 2m
PermitRootLogin yes
StrictModes yes
root@node253:~# systemctl restart sshd
- Q&A
- 使用xftp上传文件失败,提示
服务器发送了一个意外的数据包。received:3,expected:20
查看相关资料为新版sshd与xshell存在兼容性问题,需要追加配置信息如下,重启sshd服务即可
- 使用xftp上传文件失败,提示
root@node253:~# echo "KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1" >> /etc/ssh/sshd_config
root@node253:~# systemctl restart sshd
3、配置远程桌面
注:GUI界面下执行快捷键
Ctl + Alt + T
可调出命令行窗口
3.1、设置桌面分辨率
安装ubuntu系统之后,默认只有1024 x 768和800 x 600两种分辨率
- 增加分辨率选项配置
添加1920x1080及1366x768分辨率配置如下:
xrandr --newmode $(cvt 1920 1080 60 | grep Mode | sed -e 's/.*"/1920x1080/')
xrandr --addmode VGA-1 1920x1080
xrandr --newmode $(cvt 1366 768 60 | grep Mode | sed -e 's/.*"/1366x768/')
xrandr --addmode VGA-1 1366x768
- 选择
设置-显示器
,设置对应分辨率选项,应用配置即可
Q&A
1、xrandr:failed to get size of gamma for output default
- 问题描述:
在使用xrandr进行分辨率设置的时候,出现错误“xrandr:failed to get size of gamma for output default”,尝试多种方法无解,使用以下方法方可解决,但暂不清楚具体什么原因,此处只做记录,后续再研究下 - 解决方法:
添加以下配置文件信息,重启即可
root@node254:~# cat /etc/xorg.conf
Section "Monitor"
Identifier "Monitor0"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
HorizSync 28.0 - 70.0
VertRefresh 56.0 - 75.0
EndSection
Section "Device"
Identifier "VMware SVGA"
Driver "vesa"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
SubSection "Display"
Viewport 0 0
Depth 24
Modes "1920x1080_60.00"
EndSubSection
EndSection
3.2、配置远程桌面
3.2.1、开启屏幕共享
选择设置-共享
,点击屏幕共享选项,打开设置开关,勾选需要密码,选择对应网卡
3.2.2、安装xrdp
sudo apt-get install xrdp -y
3.2.3、安装dconf-editor及配置
此步骤主要用于关闭远程连接加密请求,否则会出现“vnc连接提示不支持安全类型”错误
- 安装dcof-editor
sudo apt-get install dconf-editor
- 配置remote-access
启动dconf编辑器,选择org->gnome->desktop->remote-access
,关闭"requlre-encryption"开关
3.2.3、windows远程访问
此时,使用windows的mstsc远程桌面访问即可,选择vnc-any会话,输入ip和密码即可访问ubuntu远程桌面
二、更换系统内核版本
Ubuntu 20.04.2 LTS系统默认内核版本为5.4.0-42-generic
1、查看当前指定版本可用软件包
root@node254:~# apt-cache search 5.4.0-42-generic
linux-buildinfo-5.4.0-42-generic - Linux kernel buildinfo for version 5.4.0 on 64 bit x86 SMP
linux-cloud-tools-5.4.0-42-generic - Linux kernel version specific cloud tools for version 5.4.0-42
linux-headers-5.4.0-42-generic - Linux kernel headers for version 5.4.0 on 64 bit x86 SMP
linux-image-5.4.0-42-generic - Signed kernel image generic
linux-image-unsigned-5.4.0-42-generic - Linux kernel image for version 5.4.0 on 64 bit x86 SMP
linux-modules-5.4.0-42-generic - Linux kernel extra modules for version 5.4.0 on 64 bit x86 SMP
linux-modules-extra-5.4.0-42-generic - Linux kernel extra modules for version 5.4.0 on 64 bit x86 SMP
linux-tools-5.4.0-42-generic - Linux kernel version specific tools for version 5.4.0-42
linux-modules-nvidia-390-5.4.0-42-generic - Linux kernel nvidia modules for version 5.4.0-42
linux-modules-nvidia-418-server-5.4.0-42-generic - Linux kernel nvidia modules for version 5.4.0-42
linux-modules-nvidia-435-5.4.0-42-generic - Linux kernel nvidia modules for version 5.4.0-42
linux-modules-nvidia-440-5.4.0-42-generic - Linux kernel nvidia modules for version 5.4.0-42
linux-modules-nvidia-440-server-5.4.0-42-generic - Linux kernel nvidia modules for version 5.4.0-42
2、下载指定版本linux-images和linux-headers
root@node254:~# apt-get install linux-image-5.4.0-42-generic linux-headers-5.4.0-42-generic -y
3、设置系统默认启动内核版本
- 查看当前系统启动项
root@node254:~# grep menuentry /boot/grub/grub.cfg
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
menuentry_id_option=""
export menuentry_id_option
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-98224eb1-df53-4a47-bc17-d2a84efd4225' {
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-98224eb1-df53-4a47-bc17-d2a84efd4225' {
menuentry 'Ubuntu,Linux 5.8.0-53-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.8.0-53-generic-advanced-98224eb1-df53-4a47-bc17-d2a84efd4225' {
menuentry 'Ubuntu, with Linux 5.8.0-53-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.8.0-53-generic-recovery-98224eb1-df53-4a47-bc17-d2a84efd4225' {
menuentry 'Ubuntu,Linux 5.8.0-43-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.8.0-43-generic-advanced-98224eb1-df53-4a47-bc17-d2a84efd4225' {
menuentry 'Ubuntu, with Linux 5.8.0-43-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.8.0-43-generic-recovery-98224eb1-df53-4a47-bc17-d2a84efd4225' {
menuentry 'Ubuntu,Linux 5.4.0-42-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-42-generic-advanced-98224eb1-df53-4a47-bc17-d2a84efd4225' {
menuentry 'Ubuntu, with Linux 5.4.0-42-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-42-generic-recovery-98224eb1-df53-4a47-bc17-d2a84efd4225' {
menuentry 'Memory test (memtest86+)' {
menuentry 'Memory test (memtest86+, serial console 115200)' {
如上所示,启动过程中GRUB菜单如下,GRUB_DEFAULT
默认为0,即默认使用ubuntu选项启动系统
选项索引从0开始,当需要选择子菜单选项时,则表示为一级菜单索引号> 二级菜单索引号
;示例需要选择Ubuntu,Linux 5.4.0-42-generic
选项启动,则GRUB_DEFAULT
为1> 4
注:>
后需加空格隔开
- Ubuntu
- Advanced options for Ubuntu
- Ubuntu,Linux 5.8.0-53-generic
- Ubuntu, with Linux 5.8.0-53-generic (recovery mode)
- Ubuntu,Linux 5.8.0-43-generic
- Ubuntu, with Linux 5.8.0-43-generic (recovery mode)
- Ubuntu,Linux 5.4.0-42-generic
- Ubuntu, with Linux 5.4.0-42-generic (recovery mode)
- Memory test (memtest86+)
- Memory test (memtest86+, serial console 115200)
注:系统引导页面示意如下:
- 修改启动选项,更新grub信息,重启系统即可
root@node254:~# cat /etc/default/grub | grep "GRUB_DEFAULT"
GRUB_DEFAULT="1> 4"
root@node254:~# update-grub
root@node254:~# reboot