Ubuntu 开机自动挂载硬盘
前段时间ubuntu18.0.4系统搞崩溃了,重装系统导致,直接安装默认盘下,原来的系统中资料成为另一个磁盘,导致使用不方便,考虑重新挂载,执行如下操作。
1、查看Linux硬盘信息:
$ sudo fdisk -l
2、格式化硬盘(根据需要确定文件系统):
sudo mkfs.xfs /dev/sdb
3、创建/data目录
sudo mkdir /data
4、挂载分区:
sudo mount /dev/sdb /data
5、查看磁盘分区的UUID
$ sudo blkid /dev/sda1: UUID="8048997a-16c9-447b-a209-82e4d380326e" TYPE="ext4" /dev/sda5: UUID="0c5f073a-ad3f-414f-85c2-4af83f6a437f" TYPE="swap" /dev/sdb1: UUID="11263962-9715-473f-9421-0b604e895aaa" TYPE="ext4" /dev/sr0: LABEL="Join Me" TYPE="iso9660"
6、配置开机自动挂载:
mount命令重启后会失效,将分区信息写入 /etc/fstab 文件启动自动挂载:
sudo vim /etc/fstab
加入:
UUID=11263962-9715-473f-9421-0b604e895aaa /data xfs defaults 0 1
注:<fs spec> <fs file> <fs vfstype> <fs mntops> <fs freq> <fs passno>
具体说明,以挂载/dev/sdb1为例:
<fs spec>:分区定位,可以给UUID或LABEL,例如:UUID=6E9ADAC29ADA85CD或LABEL=software <fs file>:具体挂载点的位置,例如:/data<fs vfstype>:挂载磁盘类型,linux 分区一般为 ext4,windows 分区一般为 ntfs <fs mntops>:挂载参数,一般为defaults <fs freq>:磁盘检查,默认为0 <fs passno>:磁盘检查,默认为0,不需要检查 第一个叫fs_freq,用来决定哪一个文件系统需要执行dump操作,0就是不需要; 第二个叫fs_passno,是系统重启时fsck程序检测磁盘的顺序号 1 是root文件系统,2 是别的文件系统。fsck按序号检测磁盘,0表示该文件系统不被检测 dump 执行ext2的文件系统的备份操作 fsck 检测和修复文件系统
7、重启系统
修改完/etc/fstab文件后,运行
sudo mount -a
验证配置是否正确,配置不正确可能会导致系统无法正常启动。
_________________________________________________________________________________________________________________________________________________
每一个不曾起舞的日子,都是对生命的辜负。
But it is the same with man as with the tree. The more he seeks to rise into the height and light, the more vigorously do his roots struggle earthward, downward, into the dark, the deep - into evil.
其实人跟树是一样的,越是向往高处的阳光,它的根就越要伸向黑暗的地底。----尼采
每一个不曾起舞的日子,都是对生命的辜负。
But it is the same with man as with the tree. The more he seeks to rise into the height and light, the more vigorously do his roots struggle earthward, downward, into the dark, the deep - into evil.
其实人跟树是一样的,越是向往高处的阳光,它的根就越要伸向黑暗的地底。----尼采