页次: 1
在开机的时候,对于/mnt/d挂载点,先尝试挂载物理硬盘,如果挂载失败,然后尝试挂载网络硬盘。不知有没有办法实现这个功能
目前试了/etc/fstab里面写两行,似乎不行。还有写一个systemd.service,不知为何明明service执行成功,但是却没有挂载上去
离线
你 service 怎么写的?
离线
我的service
❯ cat mnt-d_1.service
[Unit]
Description=D
[Service]
ExecStart=/bin/mount -o uid=1000 /dev/disk/by-label/D /mnt/d
ExecStop=/bin/umount /mnt/d
[Install]
WantedBy=multi-user.target
输出正常
❯ systemctl status mnt-d_1.service
● mnt-d_1.service - D
Loaded: loaded (/etc/systemd/system/mnt-d_1.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Wed 2020-12-23 21:37:01 CST; 1min 16s ago
Process: 546 ExecStart=/bin/mount -o uid=1000 /dev/disk/by-label/D /mnt/d (code=exited, status=0/SUCCESS)
Process: 613 ExecStop=/bin/umount /mnt/d (code=exited, status=0/SUCCESS)
Main PID: 546 (code=exited, status=0/SUCCESS)
12月 23 21:37:01 FlyInWind systemd[1]: Started D.
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Version 2017.3.23 external FUSE 29
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Mounted /dev/nvme0n1p2 (Read-Write, label "D", NTFS 3.1)
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Cmdline options: rw,uid=1000
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Mount options: rw,allow_other,nonempty,relatime,default_permissions,fsname=/dev/nvme0n1p2,blkdev,blksize=4096
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Global ownership and permissions enforced, configuration type 7
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Unmounting /dev/nvme0n1p2 (D)
12月 23 21:37:01 FlyInWind systemd[1]: mnt-d_1.service: Succeeded.
曾经看见过systemd可以创建一个虚拟的环境,然后运行命令,在想是不是默认情况下使用了虚拟环境
离线
我的service
❯ cat mnt-d_1.service
[Unit]
Description=D[Service]
ExecStart=/bin/mount -o uid=1000 /dev/disk/by-label/D /mnt/d
ExecStop=/bin/umount /mnt/d[Install]
WantedBy=multi-user.target输出正常
❯ systemctl status mnt-d_1.service
● mnt-d_1.service - D
Loaded: loaded (/etc/systemd/system/mnt-d_1.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Wed 2020-12-23 21:37:01 CST; 1min 16s ago
Process: 546 ExecStart=/bin/mount -o uid=1000 /dev/disk/by-label/D /mnt/d (code=exited, status=0/SUCCESS)
Process: 613 ExecStop=/bin/umount /mnt/d (code=exited, status=0/SUCCESS)
Main PID: 546 (code=exited, status=0/SUCCESS)12月 23 21:37:01 FlyInWind systemd[1]: Started D.
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Version 2017.3.23 external FUSE 29
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Mounted /dev/nvme0n1p2 (Read-Write, label "D", NTFS 3.1)
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Cmdline options: rw,uid=1000
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Mount options: rw,allow_other,nonempty,relatime,default_permissions,fsname=/dev/nvme0n1p2,blkdev,blksize=4096
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Global ownership and permissions enforced, configuration type 7
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Unmounting /dev/nvme0n1p2 (D)
12月 23 21:37:01 FlyInWind systemd[1]: mnt-d_1.service: Succeeded.曾经看见过systemd可以创建一个虚拟的环境,然后运行命令,在想是不是默认情况下使用了虚拟环境
啥虚拟环境?你这是没看手册瞎写啊。
mount 执行之后就退出了,然后服务停止,然后 umount……
Type=oneshot 了解一下?RemainAfterExit 了解一下?
离线
FlyInWind 说:我的service
❯ cat mnt-d_1.service
[Unit]
Description=D[Service]
ExecStart=/bin/mount -o uid=1000 /dev/disk/by-label/D /mnt/d
ExecStop=/bin/umount /mnt/d[Install]
WantedBy=multi-user.target输出正常
❯ systemctl status mnt-d_1.service
● mnt-d_1.service - D
Loaded: loaded (/etc/systemd/system/mnt-d_1.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Wed 2020-12-23 21:37:01 CST; 1min 16s ago
Process: 546 ExecStart=/bin/mount -o uid=1000 /dev/disk/by-label/D /mnt/d (code=exited, status=0/SUCCESS)
Process: 613 ExecStop=/bin/umount /mnt/d (code=exited, status=0/SUCCESS)
Main PID: 546 (code=exited, status=0/SUCCESS)12月 23 21:37:01 FlyInWind systemd[1]: Started D.
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Version 2017.3.23 external FUSE 29
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Mounted /dev/nvme0n1p2 (Read-Write, label "D", NTFS 3.1)
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Cmdline options: rw,uid=1000
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Mount options: rw,allow_other,nonempty,relatime,default_permissions,fsname=/dev/nvme0n1p2,blkdev,blksize=4096
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Global ownership and permissions enforced, configuration type 7
12月 23 21:37:01 FlyInWind ntfs-3g[611]: Unmounting /dev/nvme0n1p2 (D)
12月 23 21:37:01 FlyInWind systemd[1]: mnt-d_1.service: Succeeded.曾经看见过systemd可以创建一个虚拟的环境,然后运行命令,在想是不是默认情况下使用了虚拟环境
啥虚拟环境?你这是没看手册瞎写啊。
mount 执行之后就退出了,然后服务停止,然后 umount……
Type=oneshot 了解一下?RemainAfterExit 了解一下?
谢谢,问题解决了。
离线
页次: 1