unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Help with auto-mounting a specific file-system.
@ 2020-04-20  6:37 Raghav Gururajan
  2020-04-20  9:15 ` Pierre Neidhardt
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Raghav Gururajan @ 2020-04-20  6:37 UTC (permalink / raw)
  To: help-guix

Hello Guix!

I wanted to make use of my memory card slot in my X200-T and decided to use it to store cloned git repos. I have placed a 32GB card, with formatted btrfs file-system, with label "repo". I wanted to auto-mount this file-system at ~/repo. So I used the following in 'file-systems' section of my config.scm.

  (file-systems (append
                 (list (file-system
                         (device (uuid "1234-ABCD"))
                         (mount-point "/")
                         (type "btrfs")
                         (needed-for-boot? #t)
                         (dependencies mapped-devices))
                       (file-system
                         (device (file-system-label "repo"))
                         (mount-point "/home/user/repo")
                         (type "btrfs")
                         (needed-for-boot? #f)))
                 %base-file-systems))

Now, the setup work and the file-system 'repo' gets auto-mounted at ~/repo. But I am facing two issues:

[1] ~/repo becomes 'root protected' and stays like that.
[2] Despite declaring `(needed-for-boot? #f)`, system does not boot when the memory card is absent/unplugged.

How do I overcome these issues?

Thank you!

Regards,
RG.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Help with auto-mounting a specific file-system.
  2020-04-20  6:37 Help with auto-mounting a specific file-system Raghav Gururajan
@ 2020-04-20  9:15 ` Pierre Neidhardt
  2020-04-20  9:22 ` Raghav Gururajan
  2020-04-20 19:45 ` Michael Rohleder
  2 siblings, 0 replies; 9+ messages in thread
From: Pierre Neidhardt @ 2020-04-20  9:15 UTC (permalink / raw)
  To: Raghav Gururajan, help-guix

[-- Attachment #1: Type: text/plain, Size: 489 bytes --]

If you are using GNOME or some high-level desktop environment, the SD
card should be automatically mounted when you insert it.

For less sophisticated desktop environments, you can starts tools like
udisksie on login, then pendrives, SD cards and the like will be
automatically mounted to /media/$USER/$VOLUMENAME.

> [1] ~/repo becomes 'root protected' and stays like that.

What do you mean?  Does `sudo chown ...` work for you?

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Help with auto-mounting a specific file-system.
  2020-04-20  6:37 Help with auto-mounting a specific file-system Raghav Gururajan
  2020-04-20  9:15 ` Pierre Neidhardt
@ 2020-04-20  9:22 ` Raghav Gururajan
  2020-04-20  9:29   ` Pierre Neidhardt
  2020-04-20  9:42   ` Raghav Gururajan
  2020-04-20 19:45 ` Michael Rohleder
  2 siblings, 2 replies; 9+ messages in thread
From: Raghav Gururajan @ 2020-04-20  9:22 UTC (permalink / raw)
  To: Pierre Neidhardt, help-guix

Hi Pierre!

> If you are using GNOME or some high-level desktop environment, the SD
> card should be automatically mounted when you insert it.
> 
> For less sophisticated desktop environments, you can starts tools like
> udisksie on login, then pendrives, SD cards and the like will be
> automatically mounted to /media/$USER/$VOLUMENAME.

I am currently using dwm+dmenu. But I have already tried the above and it works. It is useful for general hot-swapping.

In this case, I would like to manage things with guix. And I want a specific file-system to be mounted at a specific mount-point (home directory), upon every boot.

>> [1] ~/repo becomes 'root protected' and stays like that.
> 
> What do you mean? Does `sudo chown ...` work for you?

The directory becomes writable only by root. I am able to manually change the permissions, but it resets on every boot.

Regards,
RG.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Help with auto-mounting a specific file-system.
  2020-04-20  9:22 ` Raghav Gururajan
@ 2020-04-20  9:29   ` Pierre Neidhardt
  2020-04-20  9:42   ` Raghav Gururajan
  1 sibling, 0 replies; 9+ messages in thread
From: Pierre Neidhardt @ 2020-04-20  9:29 UTC (permalink / raw)
  To: Raghav Gururajan, help-guix

[-- Attachment #1: Type: text/plain, Size: 505 bytes --]

> In this case, I would like to manage things with guix. And I want a specific file-system to be mounted at a specific mount-point (home directory), upon every boot.

I think the best way to do this is to use Guix to set the right Udev
rules for Udisks:

https://wiki.archlinux.org/index.php/Udisks

> The directory becomes writable only by root. I am able to manually change the permissions, but it resets on every boot.

Weird, it should stick.

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Help with auto-mounting a specific file-system.
  2020-04-20  9:22 ` Raghav Gururajan
  2020-04-20  9:29   ` Pierre Neidhardt
@ 2020-04-20  9:42   ` Raghav Gururajan
  2020-04-20  9:52     ` Pierre Neidhardt
  1 sibling, 1 reply; 9+ messages in thread
From: Raghav Gururajan @ 2020-04-20  9:42 UTC (permalink / raw)
  To: Pierre Neidhardt, help-guix

Hi Pierre!
 
> I think the best way to do this is to use Guix to set the right Udev
> rules for Udisks:
> 
> https://wiki.archlinux.org/index.php/Udisks

I thought I could use the same concept of mounting /home or /boot or /store etc., from another disk. But all these are immediately after root directory "/" and are likely to be protected. So then I should not be using this technique to mount something under user's directory "~/".

Okay, no problem. I can just do git operations by 'cd'ing to /media/foo/bar, which is mounted by udisks/udiskie.

Now, I am would like to modify udisks-service-type, to include an option like `enable-udiskie? boolean` in udisks-configuration. If it is #t, udiskie will run along with udisks service, on every start-up. Could you help me with a scheme code to achieve this?

Btw, this is not just for me. We can patch it in guix. This will be very handy for folks using light-weight DE or window-managers. :-)

Regards,
RG.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Help with auto-mounting a specific file-system.
  2020-04-20  9:42   ` Raghav Gururajan
@ 2020-04-20  9:52     ` Pierre Neidhardt
  2020-04-20 13:39       ` Raghav Gururajan
  0 siblings, 1 reply; 9+ messages in thread
From: Pierre Neidhardt @ 2020-04-20  9:52 UTC (permalink / raw)
  To: Raghav Gururajan, help-guix

[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]

"Raghav Gururajan" <raghavgururajan@disroot.org> writes:

> Okay, no problem. I can just do git operations by 'cd'ing to /media/foo/bar, which is mounted by udisks/udiskie.

To clarify, you can configure udisks to mount your drives somewhere else
like your home directory.

> Now, I am would like to modify udisks-service-type, to include an
> option like `enable-udiskie? boolean` in udisks-configuration. If it
> is #t, udiskie will run along with udisks service, on every
> start-up. Could you help me with a scheme code to achieve this?

Udiskie is a user service, so I don't think it makes sense to include it
in udisks-service-type.

But you can run shepherd as user.  I have this service:

--8<---------------cut here---------------start------------->8---
(define auto-mount
  (make <service>
    #:provides '(auto-mount)
    #:start (make-system-constructor "udiskie &")
    #:stop (make-system-destructor "pkill udiskie")
    #:respawn? #t))
--8<---------------cut here---------------end--------------->8---

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Help with auto-mounting a specific file-system.
  2020-04-20  9:52     ` Pierre Neidhardt
@ 2020-04-20 13:39       ` Raghav Gururajan
  2020-04-20 14:32         ` Pierre Neidhardt
  0 siblings, 1 reply; 9+ messages in thread
From: Raghav Gururajan @ 2020-04-20 13:39 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: help-guix


> To clarify, you can configure udisks to mount your drives somewhere else
> like your home directory.

Ah I see. Btw, guix does not use udisks to mount file-systems right?

Like mounting root file-system at "/", guix just uses mount command correct?

> Udiskie is a user service, so I don't think it makes sense to include it
> in udisks-service-type.

Oh. I have to read about types of services then. As a guess, is it the
difference between service running 'system-wide' and 'as and for that user'?

> But you can run shepherd as user.  I have this service:
> 
> --8<---------------cut here---------------start------------->8---
> (define auto-mount
>   (make <service>
>     #:provides '(auto-mount)
>     #:start (make-system-constructor "udiskie &")
>     #:stop (make-system-destructor "pkill udiskie")
>     #:respawn? #t))
> --8<---------------cut here---------------end--------------->8---

Thanks so much. Just to double check, should I put this in my config.scm?

Regards,
RG.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Help with auto-mounting a specific file-system.
  2020-04-20 13:39       ` Raghav Gururajan
@ 2020-04-20 14:32         ` Pierre Neidhardt
  0 siblings, 0 replies; 9+ messages in thread
From: Pierre Neidhardt @ 2020-04-20 14:32 UTC (permalink / raw)
  To: Raghav Gururajan; +Cc: help-guix

[-- Attachment #1: Type: text/plain, Size: 1387 bytes --]

Raghav Gururajan <raghavgururajan@disroot.org> writes:

> Ah I see. Btw, guix does not use udisks to mount file-systems right?

>
> Like mounting root file-system at "/", guix just uses mount command correct?

Correct.

> Oh. I have to read about types of services then. As a guess, is it the
> difference between service running 'system-wide' and 'as and for that user'?

Correct.  For now Guix does not deal with user services.
>
>> --8<---------------cut here---------------start------------->8---
>> (define auto-mount
>>   (make <service>
>>     #:provides '(auto-mount)
>>     #:start (make-system-constructor "udiskie &")
>>     #:stop (make-system-destructor "pkill udiskie")
>>     #:respawn? #t))
>> --8<---------------cut here---------------end--------------->8---
>
> Thanks so much. Just to double check, should I put this in my config.scm?

No, since Guix does not deal with user services.
You'd put the above snippet in ~/.config/shepherd/init.scm:

--8<---------------cut here---------------start------------->8---
(register-services (list auto-mount))
(action 'shepherd 'daemonize)
(for-each start (append (list auto-mount)))
--8<---------------cut here---------------end--------------->8---

(Untested.)

See my dotfiles of a complete example:

https://gitlab.com/ambrevar/dotfiles

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Help with auto-mounting a specific file-system.
  2020-04-20  6:37 Help with auto-mounting a specific file-system Raghav Gururajan
  2020-04-20  9:15 ` Pierre Neidhardt
  2020-04-20  9:22 ` Raghav Gururajan
@ 2020-04-20 19:45 ` Michael Rohleder
  2 siblings, 0 replies; 9+ messages in thread
From: Michael Rohleder @ 2020-04-20 19:45 UTC (permalink / raw)
  To: Raghav Gururajan; +Cc: help-guix

[-- Attachment #1: Type: text/plain, Size: 659 bytes --]

"Raghav Gururajan" <raghavgururajan@disroot.org> writes:
> Now, the setup work and the file-system 'repo' gets auto-mounted at ~/repo. But I am facing two issues:
>
> [1] ~/repo becomes 'root protected' and stays like that.
> [2] Despite declaring `(needed-for-boot? #f)`, system does not boot when the memory card is absent/unplugged.
>
> How do I overcome these issues?

I have the same problem as in [2], but for nfs.
Only work around was (mount? #f) ...

Maybe (service pam-mount-service-type) could help here, see
http://guix.gnu.org/manual/en/guix.html#PAM-Mount-Service


-- 
Wer unsere Traeume stiehlt, gibt uns den Tod.  (Konfuzius)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-04-20 19:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20  6:37 Help with auto-mounting a specific file-system Raghav Gururajan
2020-04-20  9:15 ` Pierre Neidhardt
2020-04-20  9:22 ` Raghav Gururajan
2020-04-20  9:29   ` Pierre Neidhardt
2020-04-20  9:42   ` Raghav Gururajan
2020-04-20  9:52     ` Pierre Neidhardt
2020-04-20 13:39       ` Raghav Gururajan
2020-04-20 14:32         ` Pierre Neidhardt
2020-04-20 19:45 ` Michael Rohleder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).