简介
linux下对于文件系统的操作的一些集合
开机挂载文件
查看Linux硬盘信息:
sudo fdisk -l
格式化硬盘
sudo mkfs.ext4 /dev/sdb
创建/data目录
sudo mkdir /data
挂载分区:
sudo mount /dev/sdb /data
查看磁盘分区的UUID
sudo sudo blkid
挂配置开机自动挂载:
echo "UUID= /data ext4 defaults 0 1" >> /etc/fstab
测试配置文件是否正确:
sudo mount -a
扩充硬盘
安装parted
apt-get install -y parted
parted
➜ parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 236GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 236GB 236GB ext4
(parted) resizepart 1
Warning: Partition /dev/sdb is being used. Are you sure you want to continue?
Yes/No? yes
End? [236GB]?
(parted) q
Information: You may need to update /etc/fstab.
resize2fs
➜ resize2fs /dev/sdb
resize2fs 1.44.5 (15-Dec-2018)
Filesystem at /dev/sdb is mounted on /data; on-line resizing required
old_desc_blocks = 27, new_desc_blocks = 28
The filesystem on /dev/sdb is now 57671680 (4k) blocks long.