ubuntu自动挂载硬盘方法

首先建立挂载目录

例如:

sudo mkdir /movie #根目录下建立movie文件夹
sudo mkdir /work   #根目录下建立work文件夹

然后查看硬盘信息

sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x6fd074d4

   Device Boot      Start         End      Blocks   Id System
/dev/sda1   *           1        3251    26113626    7 HPFS/NTFS
/dev/sda2            3252       48177   360868095    f W95 Ext'd (LBA)
/dev/sda3           48178       60801   101402280   83 Linux
/dev/sda5            3252        8414    41471766    7 HPFS/NTFS
/dev/sda6            8415       21800   107523013+   7 HPFS/NTFS
/dev/sda7           21801       47934   209921323+   7 HPFS/NTFS
/dev/sda8           47935       48177     1951866   82 Linux swap / Solaris

Disk /dev/sdb: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x4fd353d4

   Device Boot      Start         End      Blocks   Id System
/dev/sdb1               1       12876   103425446    7 HPFS/NTFS
/dev/sdb2           12876       38914   209151681    7 HPFS/NTFS

这里要把sda7 sdb2自动挂载在work和movie下

修改fstab文件

sudo vim /etc/fstab

sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0
/dev/fd0        /media/floppy0 auto    rw,user,noauto,exec,utf8 0       0
/dev/sda6       /doc            auto                             0        0
/dev/sdb1       /xp             auto                             0        0
/dev/sda7       /work           auto                             0       0
/dev/sdb2       /movie          auto                             0       0

加黑是手动加入的
保存退出重新启动就ok了

    原文作者:itbird01
    原文地址: https://www.jianshu.com/p/b1e606a8a423
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞