Linux mount 硬盘挂载

「爱情、让人受尽委屈。」 2022-04-06 10:14 437阅读 0赞

欢迎访问我的个人博客网站:http://www.yanmin99.com/

1、查看硬盘信息

  • fdisk -l

    1. Disk /dev/xvda: 21.5 GB, 21474836480 bytes
    2. 255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
    3. Units = sectors of 1 * 512 = 512 bytes
    4. Sector size (logical/physical): 512 bytes / 512 bytes
    5. I/O size (minimum/optimal): 512 bytes / 512 bytes
    6. Disk identifier: 0x000da36d
    7. Device Boot Start End Blocks Id System
    8. /dev/xvda1 * 2048 41940991 20969472 83 Linux
    9. Disk /dev/xvdb: 107.4 GB, 107374182400 bytes
    10. 255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
    11. Units = sectors of 1 * 512 = 512 bytes
    12. Sector size (logical/physical): 512 bytes / 512 bytes
    13. I/O size (minimum/optimal): 512 bytes / 512 bytes
    14. Disk identifier: 0x00000000
    15. Disk /dev/xvdb doesn't contain a valid partition table

2、进入磁盘,对磁盘进行分区

  • fdisk /dev/xvdb

    1. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    2. Building a new DOS disklabel with disk identifier 0xabf49954.
    3. Changes will remain in memory only, until you decide to write them.
    4. After that, of course, the previous content won't be recoverable.
    5. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
    6. Command (m for help): n
    7. Partition type:
    8. p primary (0 primary, 0 extended, 4 free)
    9. e extended
    10. 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 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.

  • fdisk -l

    1. Disk /dev/xvda: 21.5 GB, 21474836480 bytes
    2. 255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
    3. Units = sectors of 1 * 512 = 512 bytes
    4. Sector size (logical/physical): 512 bytes / 512 bytes
    5. I/O size (minimum/optimal): 512 bytes / 512 bytes
    6. Disk identifier: 0x000da36d
    7. Device Boot Start End Blocks Id System
    8. /dev/xvda1 * 2048 41940991 20969472 83 Linux
    9. Disk /dev/xvdb: 107.4 GB, 107374182400 bytes
    10. 43 heads, 44 sectors/track, 110843 cylinders, total 209715200 sectors
    11. Units = sectors of 1 * 512 = 512 bytes
    12. Sector size (logical/physical): 512 bytes / 512 bytes
    13. I/O size (minimum/optimal): 512 bytes / 512 bytes
    14. Disk identifier: 0xabf49954
    15. Device Boot Start End Blocks Id System
    16. /dev/xvdb1 2048 209715199 104856576 83 Linux

3、格式化分区

  • mkfs.ext3 /dev/xvdb1 (将/dev/xvdb1格式化为ext3类型)

    1. mke2fs 1.42.9 (4-Feb-2014)
    2. Filesystem label=
    3. OS type: Linux
    4. Block size=4096 (log=2)
    5. Fragment size=4096 (log=2)
    6. Stride=0 blocks, Stripe width=0 blocks
    7. 6553600 inodes, 26214144 blocks
    8. 1310707 blocks (5.00%) reserved for the super user
    9. First data block=0
    10. Maximum filesystem blocks=4294967296
    11. 800 block groups
    12. 32768 blocks per group, 32768 fragments per group
    13. 8192 inodes per group
    14. Superblock backups stored on blocks:
    15. 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
    16. 4096000, 7962624, 11239424, 20480000, 23887872
    17. Allocating group tables: done
    18. Writing inode tables: done
    19. Creating journal (32768 blocks): done
    20. Writing superblocks and filesystem accounting information: done

4、创建/disk2目录

  • mkdir /disk2

5、挂载

  • mount /dev/xvdb1 /disk2/

6、查看硬盘大小以及挂载分区

  • df -h

    1. Filesystem Size Used Avail Use% Mounted on
    2. /dev/xvda1 20G 16G 3.4G 82% /
    3. none 4.0K 0 4.0K 0% /sys/fs/cgroup
    4. udev 3.9G 4.0K 3.9G 1% /dev
    5. tmpfs 799M 392K 799M 1% /run
    6. none 5.0M 0 5.0M 0% /run/lock
    7. none 3.9G 0 3.9G 0% /run/shm
    8. none 100M 0 100M 0% /run/user
    9. /dev/xvdb1 99G 60M 94G 1% /disk2

7、配置开机自动挂载

  • vim /etc/fstab

    1. /dev/xvdb1 /disk2 ext3 defaults 0 0

发表评论

表情:
评论列表 (有 0 条评论,437人围观)

还没有评论,来说两句吧...

相关阅读