Linux-mount

linux挂载相关命令

注意挂载操作不要在挂载目录里面操作

1
2
3
4
5
6
7
8
9
10
11
12
#查看磁盘分区情况
lsblk
#查看磁盘详情
fdisk -l
#挂载 ,提前建好挂在目录,这句诗挂载sdc设备的第五个分区
mount /dev/sdc5 /mnt/udisk
# 挂载ntfs的系统需要先安装ntfs-3g
yum install ntfs-3g
# 查看是否挂载成功
df -h
# 卸载
umount

hyper-v centos挂载其他vhd 硬盘

mount: unknown filesystem type 'LVM2_member'

1
2
3
fdisk -l
mount /dev/mapper/centos-root /mnt/disk
umount /mnt/disk

腾讯云初始化和挂载硬盘

  1. fdisk -l查看磁盘, 如果没有输出硬盘检查云盘状态是否已挂载

    1
    Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
  2. fdisk /dev/vdb创建新分区依次输入“n”(新建分区)、“p”(新建主分区)、“1”(使用第1个主分区),两次回车(使用默认配置),输入“wq”(保存分区表)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    Welcome to fdisk (util-linux 2.23.2).

    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.

    Device does not contain a recognized partition table
    Building a new DOS disklabel with disk identifier 0x45f0094c.

    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, default 1): 1
    First sector (2048-209715199, default 2048):
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
    Using default value 209715199
    Partition 1 of type Linux and of size 100 GiB is set

    Command (m for help): wq
    The partition table has been altered!

    Calling ioctl() to re-read partition table.
    Syncing disks.
  3. fdisk -l 检查

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x000c5e30

    Device Boot Start End Blocks Id System
    /dev/vda1 * 2048 104857599 52427776 83 Linux

    Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x45f0094c

    Device Boot Start End Blocks Id System
    /dev/vdb1 2048 209715199 104856576 83 Linux
  4. mkdir /data如果没有创建挂载目录

  5. mkfs.ext3 /dev/vdb1 格式化硬盘

  6. mount /dev/vdb1 /data设置挂载

  7. vim /etc/fstab设置开机启动自动挂载,fstab追加行

    1
    /dev/vdb1            /data                ext3       defaults              0 0

青云centos7.8挂载扩容docker目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 分区 n ——>p ——>1 ——>回车 ——>回车 ——>w
fdisk /dev/sdc
# 格式化
mkfs.ext4 /dev/sdc
# 创建挂载目录
mkdir -p /var/lib/docker
# 挂载
mount /dev/sdc /var/lib/docker
# 查看
df -h
#---------------------
# 设置重启自动挂载
# 查看dev/sdc硬盘对应UUID
blkid /dev/sdc
# 在该文件/etc/fstab追加一行,修改UUID的值为上个命令对应的UUID
echo 'UUID=36ef3867-0b8a-4e99-8c0e-ffd8ebc1a226 /var/lib/docker ext4 defaults 0 0' >>/etc/fstab

参考

How to Mount a NTFS Drive on CentOS / RHEL / Scientific Linux

修改fstab文件磁盘标识方式为UUID