Linux磁盘挂接教程
磁盘管理
查询磁盘情况
fdisk -l
查询绑定情况
df -h
格式化磁盘
- 使用fdisk 命令
fdisk /dev/vdb
- 输入m,可以查看支持的操作模式
- 输入p,查询当前硬盘分区:
- 输入F,查询硬盘中未分区的磁盘空间:
- 输入n,用未分配的磁盘空间 创建新的分区,同时键入 必要的硬盘信息
- 输入w或者退出磁盘命令
- 输入d,删除分区
- 格式化磁盘
mkfs.ext4 /dev/sdb4
磁盘绑定
mount /dev/vdb1 /userDir/
自动加载硬盘
- 查看UUID
sudo blkid
- 执行绑定
sudo vim /etc/fstab
增加
UUID=087AA7CC7AA7B4BA /home/zifeiy/mystorage ext4 defaults 0 0
新建子文件夹
更改权限
同步
partprobe
重启
# 更换更新源
## 查看codename
lsb_release -a
> No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
~~## 确认阿里源支持
~~ubuntu-dists安装包下载_开源镜像站-阿里云
~~## 备份文件
cp /etc/apt/sources.list /etc/apt/sources.list_backup
~~
## 删除源文件
rm /etc/apt/sources.list
~~## 添加新的源文件
sudo vi /etc/apt/sources.list
~~
> deb ubuntu安装包下载_开源镜像站-阿里云 bionic main multiverse restricted universe
deb ubuntu安装包下载_开源镜像站-阿里云 bionic-backports main multiverse restricted universe
deb ubuntu安装包下载_开源镜像站-阿里云 bionic-proposed main multiverse restricted universe
deb ubuntu安装包下载_开源镜像站-阿里云 bionic-security main multiverse restricted universe
deb ubuntu安装包下载_开源镜像站-阿里云 bionic-updates main multiverse restricted universe
deb-src ubuntu安装包下载_开源镜像站-阿里云 bionic main multiverse restricted universe
deb-src ubuntu安装包下载_开源镜像站-阿里云 bionic-backports main multiverse restricted universe
deb-src ubuntu安装包下载_开源镜像站-阿里云 bionic-proposed main multiverse restricted universe
deb-src ubuntu安装包下载_开源镜像站-阿里云 bionic-security main multiverse restricted universe
deb-src ubuntu安装包下载_开源镜像站-阿里云 bionic-updates main multiverse restricted universe
保存更新
sudo apt-get update
sudo apt-get upgrade
重启
ssh保持长时间连接
vi /etc/ssh/ssh_config
TCPKeepAlive yes
ServerAliveInterval 300