一、挂载硬盘(不超2T)
1.1 虚拟机新加一块硬盘
1.2 查看新增的硬盘
[root@centos78 ~]# fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors # 原有的40G盘 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: 0x000b63e0 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 83886079 40893440 8e Linux LVM Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors # 新增20G硬盘, 盘符为/dev/sdb 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@centos78 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 40G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 39G 0 part ├─centos-root 253:0 0 37G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 20G 0 disk sr0 11:0 1 4.5G 0 rom
1.3 硬盘分区
[root@centos78 ~]# fdisk /dev/sdb 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 0xe3c58cf4. Command (m for help): m # 查看帮助 Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) 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-41943039, default 2048): # 起始扇区, 回车使用默认值 Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): # 结束扇区 Using default value 41943039 Partition 1 of type Linux and of size 20 GiB is set Command (m for help): w # 保存配置 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0xe3c58cf4 Device Boot Start End Blocks Id System /dev/sdb1 2048 41943039 20970496 83 Linux # 出现分区盘符
1.4 分区格式化
[root@centos78 ~]# mkfs. mkfs.btrfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.minix mkfs.xfs [root@centos78 ~]# mkfs.xfs /dev/sdb1 meta-data=/dev/sdb1 isize=512 agcount=4, agsize=1310656 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=5242624, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
1.5 挂载
[root@centos78 ~]# mkdir /data [root@centos78 ~]# mount /dev/sdb1 /data [root@centos78 ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 475M 0 475M 0% /dev tmpfs 487M 0 487M 0% /dev/shm tmpfs 487M 7.7M 479M 2% /run tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/mapper/centos-root 37G 1.5G 36G 4% / /dev/sda1 1014M 137M 878M 14% /boot tmpfs 98M 0 98M 0% /run/user/0 /dev/sdb1 20G 33M 20G 1% /data
1.6 开启自启动挂载
[root@centos78 ~]# blkid /dev/sda1: UUID="67218b41-d9cc-4aed-b03d-59ffede4be40" TYPE="xfs" /dev/sda2: UUID="VLE9DP-n2tl-HbKO-QHSb-Hkfl-Y2ul-JEP1Ny" TYPE="LVM2_member" /dev/sdb1: UUID="1e1bbaac-a773-4c0f-af7e-ed5a3a0d417f" TYPE="xfs" /dev/sr0: UUID="2020-04-22-00-54-00-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos" /dev/mapper/centos-root: UUID="7ceacd9a-3cef-42ab-b9a7-50f77ccaeb6e" TYPE="xfs" /dev/mapper/centos-swap: UUID="6bf5b53d-0b59-4794-bdc2-83ac8d32d6ef" TYPE="swap"
[root@centos78 ~]# vi /etc/fstab UUID=1e1bbaac-a773-4c0f-af7e-ed5a3a0d417f /data xfs defaults 0 0
二、 挂载U盘
2.1 保证U盘的格式为fat格式
# cd /mnt
# mkdir usb
2.2 插上U盘,使用fdisk -l,查看是否有新的硬盘添加上。
# fdisk -l
2.3 执行挂载
# mount -t vfat /dev/sdb /mnt/usb
2.4 查看分区
# cd /mnt/usb