Linux自动挂载windows分区

前言

我是双系统,每次重启ubuntu之后呢,之前建立的在wondows下的硬盘的分区的软链接都会掉,并且每次打开pycharm、vscode之类的软件都会找不到工程。因此我希望能够开机的时候就自动挂在window的分区,就像是本身就是ubuntu的分区一样。

自动挂载

在media下建立一个同名文件夹并修改权限

sudo mkdir /media/E
sudo chmod -R 777 /media/E

获取要自动挂载的分区的UUID和分区类型TYPE

(base) liuxin@liuxin:/media/Program$ sudo blkid
[sudo] liuxin 的密码: 
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/nvme0n1: PTUUID="931ed29b-c87c-4054-a803-89403c82e806" PTTYPE="gpt"
/dev/nvme0n1p1: UUID="65F3-3762" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="05bf9a01-c9a7-48ec-915f-25aeb52eec5b"
/dev/nvme0n1p2: PARTLABEL="Microsoft reserved partition" PARTUUID="e7c8f0dd-778e-4c36-88e6-751b93039aa1"
/dev/nvme0n1p3: LABEL="SYSTEM" UUID="06923F99923F8C65" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="4617713b-a17a-497e-9085-a88cdf7c45dc"
/dev/nvme0n1p4: LABEL="SOFTWARE" UUID="D4FA828F299D817A" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="40929858-8b22-4915-9cbd-41e8cd949dce"
/dev/nvme0n1p5: LABEL="DATA" UUID="C022AA4B225A6D42" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="d29abe98-a645-4335-ba86-dba2c7edc39d"
/dev/sda1: UUID="EC7A-B4DF" TYPE="vfat" PARTUUID="2b94cfbd-e295-4b1c-a00f-2b150b0728a0"
/dev/sda2: UUID="54fcc0f9-e48e-44ed-95d9-90a95a2bee9a" TYPE="swap" PARTUUID="10b31fc1-2c97-4fd8-bb62-8f7bad28ae00"
/dev/sda3: UUID="492fa3df-210b-4393-8fc2-188d2ae604aa" TYPE="ext4" PARTUUID="6645105c-e6cf-478d-815a-b5b893ebd7b4"
/dev/sda4: UUID="ad95c2eb-e7ac-4cb2-9a0b-4ea6144bc585" TYPE="ext4" PARTUUID="fad07471-cfe3-4a51-803f-ef3a33f57536"
/dev/sda5: LABEL="Program" UUID="654DED92178D4274" TYPE="ntfs" PTTYPE="dos" PARTUUID="69483b5a-7ab5-40cf-b7f2-ea1864991747"
/dev/sdb1: UUID="2427-11EF" TYPE="vfat" PARTUUID="cf8ad515-01"
/dev/sdb2: UUID="58564FB5564F9324" TYPE="ntfs" PARTUUID="cf8ad515-02"
/dev/loop8: TYPE="squashfs"
/dev/loop9: TYPE="squashfs"
/dev/loop10: TYPE="squashfs"
/dev/loop11: TYPE="squashfs"
/dev/loop12: TYPE="squashfs"
/dev/loop13: TYPE="squashfs"
/dev/loop14: TYPE="squashfs"
/dev/loop15: TYPE="squashfs"
/dev/loop16: TYPE="squashfs"
/dev/loop17: TYPE="squashfs"
/dev/loop18: TYPE="squashfs"
/dev/loop19: TYPE="squashfs"

找到你想挂载的那个,我想挂载的是Program这个分区

/dev/sda5: LABEL="Program" UUID="654DED92178D4274" TYPE="ntfs" PTTYPE="dos" PARTUUID="69483b5a-7ab5-40cf-b7f2-ea1864991747"

记住sda5和ntfs
挂载

sudo mount -t ntfs /dev/sda5 /media/Program

编辑fstab文件
sudo vim /etc/fstab
加入:

/dev/sda5 /media/Program ntfs defaults 0 2

保存,退出。

sudo mount -a

如果没有提示,则表示配置正确。
如有错误,按提示检查/etc/fstab有没有写错。

你可能感兴趣的:(随笔)