linux下挂载磁盘

1.使用fdisk 查看硬盘信息

[root@localhost ~]# fdisk -l

Disk /dev/sdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


//Disk /dev/sda: 161.1 GB, 161061273600 bytes
255 heads, 63 sectors/track, 19581 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000955d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64         325     2097152   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             325       19582   154676224   83  Linux
[root@localhost ~]# 

  

2.格式化硬盘、挂载硬盘、卸载挂载

mkfs -t ext4 /dev/sda  //格式化硬盘
mkdir data //创建挂载目录


#mount 硬盘地址  要挂载的地址、需指定文件目录
#mount /dev/sdb  /data //挂载

#df -h //查看是否挂载
#umount /dev/sdb  //卸载硬盘挂载

  

3.配置开机自动挂载

//因为mount挂载在重启服务器后会失效,所以需要将分区信息写到/etc/fstab文件中让它永久挂载:
[root@oracle /]# vim /etc/fstab

加入:
/dev/sdb1(磁盘分区)  /data1(挂载目录) ext3(文件格式)defaults  0  0

  

另附:linux硬盘分区:http://blog.chinaunix.net/uid-25829053-id-3067619.html

原文地址:https://www.cnblogs.com/Alexr/p/9385584.html