CentOS7 X磁碟掛載

2021-10-08 17:52:55 字數 2882 閱讀 8248

假設掛載點為/www

假設磁碟為/dev/vdc

假設磁碟只有卷/dev/vdc1

該方案可能會丟失磁碟所有資料,操作前請先備份

磁碟已格式化(用過的磁碟)

磁碟立即掛載

mkdir /www

mount /dev/vdc1 /www

啟用開機掛載

# 獲取磁碟id

ll /dev/disk/by-path

# lrwxrwxrwx. 1 root root 9 dec 2 00:25 ************************1 -> ../../sda

# lrwxrwxrwx. 1 root root 9 dec 2 00:25 ************************1-part1 -> ../../sda1

# lrwxrwxrwx. 1 root root 9 dec 2 00:25 ************************2 -> ../../vdc

# lrwxrwxrwx. 1 root root 9 dec 2 00:25 ************************2-part1 -> ../../vdc1

# 可以看出磁碟/dev/vdc1的id為

# /dev/disk/by-path/************************2-part1

# 開機掛載磁碟(根據磁碟id掛載)

echo "/dev/disk/by-path/************************2-part1 /www ext4 defaults 0 0" >> /etc/fstab

磁碟未格式化(全新的磁碟)

磁碟進行分割槽

fdisk /dev/vdc

# 下面是執行過程

command(m for help): n(回車)

partition type:

p primary (0 primary, 0 extended, 4 free)

e extended

select (default p): p(回車)

partition number (1-4): 1(回車)

first cylinder(2048-******xx,default 2048):(回車)

last cylinder(2048-******xx,default ******xx):(回車)

command(m for help): wq(回車)

分割槽錯誤處理

# 如果上一步遇到【partition table entries are not in disk order】錯誤

# 則按以下步驟修復磁碟

fdisk /dev/vdc

command(m for help): x(專家模式)

command(m for help): f(修復分割槽)

command(m for help): wq(儲存分割槽)

格式化磁碟

mkfs.ext4 /dev/vdc1

writing superblocks and filesystem accounting information:(回車)

磁碟立即掛載

mkdir /www

mount /dev/vdc1 /www

啟用開機掛載

# 獲取磁碟id

ll /dev/disk/by-path

# lrwxrwxrwx. 1 root root 9 dec 2 00:25 ************************1 -> ../../sda

# lrwxrwxrwx. 1 root root 9 dec 2 00:25 ************************1-part1 -> ../../sda1

# lrwxrwxrwx. 1 root root 9 dec 2 00:25 ************************2 -> ../../vdc

# lrwxrwxrwx. 1 root root 9 dec 2 00:25 ************************2-part1 -> ../../vdc1

# 可以看出磁碟/dev/vdc1的id為

# /dev/disk/by-path/************************2-part1

# 開機磁碟掛載(根據磁碟id掛載)

echo "/dev/disk/by-path/************************2-part1 /www ext4 defaults 0 0" >> /etc/fstab

安裝psmisc

yum install psmisc -y

解除目錄占用

fuser -k /www

取消磁碟掛載

umount /dev/vdc1

取消開機掛載

vim /etc/fstab

# 刪除掛載/www目錄的那一行

/dev/disk/by-path/************************2-part1 /www ext4 defaults 0 0

esc:wq

開機掛載

新增掛載

移動磁碟

分割槽型別

擴容mbr

擴容gpt

CentOS7 X磁碟擴容

假設掛載點為 www 假設磁碟為 dev vdc 假設磁碟只有卷 dev vdc1 該方案可能會丟失磁碟所有資料,操作前請先備份 檢視磁碟是否已分割槽,以及分割槽方式為 mbr 還是 gpt 如果包含 device 資訊,表示已分割槽 分割槽表型別dos表示分割槽方式為 mbr 分割槽表型別gpt表...

centos7 x掛載共享盤

背景 機器1 192.168.31.11 機器2 192.168.22.12 機器1是一台公用的共享盤機器,硬碟有2t,機器2是普通的應用機器,現在需要將機器1上的硬碟掛載到機器2上,供機器2做儲存使用。實操一 機器1 1 安裝nfs軟體 yum install nfs y systemctl st...

CentOS 7 X 安全手記

一 安裝雲鎖 1 報錯 2 關閉selinux vim etc selinux config 將 selinux enforcing 改 selinux disabled 3 重啟系統 reboot now 二 centos7相關的操作 1 防火牆 firewall cmd 1 禁止被ping 禁止...