auto mount disk while booting

for most time after we add an new disk under linux, we have to format and mount it after device boot.

even if the OS would mount it auto, the new added partitions/disk are mounted under certain file nodes like /media/ /mnt/, with an not read-friendly name.

while we'd more prefer to make the disk/partitions looks normal, like partition "/dev/hda1" mounted as file "/", CD device of "/dev/hdc" as "/media/cdrom0".

fstab from linux just plays the role to config this as you want.

all you need is just to add your config into /etc/fstab. here list one sample from the web

# <file system> <mount point> <type> <options> <dump> <pass>
proc              /proc              proc            defaults              0            0
/dev/hda1   /                       ext3        errors=remount-ro     0       1
/swapfile       swap               swap           defaults              0            0
/dev/hdc     /media/cdrom0   udf,iso9660   user,noauto        0         0
the first column, file system, can be the disk/partition number or the uuid of it.

the second is the target file point you want the partition to be mounted. then following the file system type of the partition. others left can just follow the same of your existed items in the fstab file. if you want to know more details, some info is fetch-able from Google or Baidu.

as partition number may always be changed, it is recommended to config partitions by uuid.

just like below:

UUID=c6c3dc13-980e-4d8a-9a42-fba296bc9aed none    swap    sw              0 0

to get the uuid of the partition/disk, you can check the dev file directly or by blkid util:

get uuid

after adding your target config, just reboot the machine. and you'll get what you want.

all above are base on Ubuntu, while it should be common for unix OS.

reference:

http://blog.sina.com.cn/s/blog_142e95b170102vx2a.html

http://blog.sina.com.cn/s/blog_437ff56b0101bvbv.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值