Linux 挂载新硬盘的方法
1. 使用fdisk -l查看现在挂载的物理硬盘和分区情况
注:本例使用阿里云做为操作演示,硬盘为vda,vdb,一般物理服务器的硬盘为sda,sdb,实际操作根据fdisk -l具体查询到的结果进行操作。
[root@Test ~]# fdisk -l Disk /dev/vda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 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: 0x00020f03 Device Boot Start End Blocks Id System /dev/vda1 * 1 5222 41940992 83 Linux Disk /dev/vdb: 107.4 GB, 107374182400 bytes 16 heads, 63 sectors/track, 208050 cylinders Units = cylinders of 1008 * 512 = 516096 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
2. 对新加载的物理硬盘进行分区fdisk /dev/vdb
[root@BeiJian ~]# fdisk /dev/vdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x9181bf7a. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): Value out of range. Partition number (1-4): 1 First cylinder (1-208050, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-208050, default 208050): Using default value 208050 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
3. 再次使用fdisk -l查看现在挂载的物理硬盘和分区情况,发现新分区/dev/vdb1
此处由于忘了查看,所有无法贴图,此处可以看到新的分区 /dev/vdb1
4. 使用格式化新分区
[root@Test ~]# mkfs.ext4 /dev/vdb1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 6553600 inodes, 26214292 blocks 1310714 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 800 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: 1^H^[[3~ done This filesystem will be automatically checked every 25 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
5. 格式化完成,再次使用fdisk -l查看分区
[root@Test ~]# fdisk -l Disk /dev/vda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 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: 0x00020f03 Device Boot Start End Blocks Id System /dev/vda1 * 1 5222 41940992 83 Linux Disk /dev/vdb: 107.4 GB, 107374182400 bytes 16 heads, 63 sectors/track, 208050 cylinders Units = cylinders of 1008 * 512 = 516096 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x9181bf7a Device Boot Start End Blocks Id System /dev/vdb1 1 208050 104857168+ 83 Linux
6. 创建文件夹,挂载硬盘,设置开机启动
mkdir /data mount /dev/vdb1 /data echo '/dev/vdb1 /data ext4 defaults 0 0' >>/etc/fstab
除特别注明外,本站所有文章均为奇妙伞原创,转载请注明出处来自https://qm3.com.cn/post/207.html