Git Product home page Git Product logo

helm-linux-disks's Introduction

Build Status

helm-linux-disks

udiskie is a useful program for mounting/unmounting removable devices in Linux, but it doesn't support LVM at present. This helm-linux-disks package provides an alternative, manual interface for mounting volumes in Linux through udisks2 with minimal support for LVM.

Features

  • Display a hierarchy of block devices using lsblk command
  • Use udisksctl command to run a bunch of operations on a device
    • Mount/unmount a file system
      • Kill Emacs buffers under its mount point before unmounting the file system
    • Lock/unlock a dm-crypted device
    • Power off a device
  • Primitive support for LVM which helps you handle a LVM-on-LUKS device
    • Activate/deactivate a LVM volume group
  • Run dired on the mount point of a device
  • Run terminal on the mount point of a device
  • You can operate on multiple devices without closing the Helm window through helm-execute-persistent-action

Prerequisites

  • Emacs 25.1
  • Helm
  • udisks2 package and udisksctl command

Because udisks2 is specific to Linux, helm-linux-disks is for Linux.

Installation

This package is not available on MELPA. Maybe it will never be on MELPA because it is limited to Linux? Use Quelpa or something to install the package from this repository.

To perform an actual mount/unmount operation on a device, udisksd daemon must be running. See this tutorial for information.

Usage

udiskie is an easier, automatic way to mount removable devices. helm-linux-disks may be useful when you unmount a device.

The main entry point is helm-linux-disks command, which is a Helm interface displaying a list of devices.

Operations on a lsblk entry

The primary Helm source of the command displays entries from lsblk command.

It supports various operations on the selected device or on the mount point of the device:

  • "Dwim" action, i.e. mount/unmount, lock/unlock, or power off the entire device depending on the type and state of the entry
  • Run dired
  • Run a terminal
  • Display information

The type of the terminal is customizable as linux-disk-terminal-type variable.

Operations on a LVM volume group

The secondary Helm source of the command displays a list of LVM volume groups. The following operations on a selected volume group are supported:

  • Deactivate all the logical volumes in the volume group (default)
  • Activate all the logical volumes in the volume group
  • Display information on the volume group

Note that there is no dwim action for a volume group. The default action deactivates all the logical volumes in the group, so use it with caution. This is because the LVM support is primarily intended for removing a device.

Multiple operations

Because helm-linux-disks is based on Helm, the following commands are supported in the session:

  • helm-execute-persistent-action (default C-j) runs the default action but keep the Helm window open
  • helm-refresh (default C-c C-u) refresh contents in the Helm buffer

This can be especially useful in removing a device. For example, if you have to remove a storage device /dev/sdb containing a file system /dev/sdb1 which is currently mounted at somewhere, you can take the following steps in helm-linux-disks:

  1. Move the cursor to /dev/sdb1.
  2. C-j to unmount the file system.
  3. C-c C-u to refresh the list.
  4. Move the cursor to /dev/sdb.
  5. C-j to power off the device.
  6. Close the Helm window.

Likewise, you can take a similar process to remove a crypted device:

  1. Unmount the file system.
  2. Lock the device.
  3. Power off the device.

You can even operate on a device with an encrypted partition containing a LVM physical volume:

  1. Unmount the file systems in the device.
  2. Deactivate the corresponding volume group.
  3. Lock the device.
  4. Power off the device.

Note that the pattern of running C-j (helm-execute-persistent-action) and C-c C-u (helm-refresh) in sequence is so common when you use helm-linux-disks.

Non-goals

The following goals are not supported by this utility:

  • Create/remove/shrink/expand a file system: You can use GParted (or a command line) for those tasks. However, helm-linux-disks can help mount/unmount file systems.
  • Mac or Windows support: They won't be supported because those platforms have neither lsblk nor udisks2. Because helm-linux-disks is basically a wrapper around lsblk and udisksctl, supporting platforms with none of those means re-implementing most parts of the package. And I suppose those platforms already have a good GUI utility for the purpose.

Alternatives

The following volume mounters are known to exist for Linux:

License

GPL v3

helm-linux-disks's People

Contributors

akirak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

helm-linux-disks's Issues

Melpa recipe

It would be nice if this package were available on Melpa.

Use findmnt --json

What about using findmnt --json instead?

  • It is cross-platform (I think)
  • It displays all mount points (I think), e.g. including FUSE mounts.
  • Using --json is much more reliable than parsing the tree output of lsblk.

We could then rename this package to helm-disks or helm-mounts :)

It could also be nice if the findmnt interface would be separate from the Helm frontend.
Thoughts?

lsblk entry for a mounted device without filesystem type

While I was using Chrome OS, I encountered an lsblk entry like this:

/dev/vda        disk  248M /opt/google/cros-containers

That is, a disk device mounted at a directory without a file system type. I have to handle this properly.

`sudo lsblk` fails if password is not cached

In the following

(defun helm-linux-disks--lsblk-with-levels ()
  "Run lsblk command and annotate each line with its level."
  (mapcar (lambda (raw-output)
            (cons (helm-linux-disks--lsblk-get-level raw-output) raw-output))
          (process-lines "sudo" "lsblk" "-n" "-p" "-o" "name,mountpoint,fstype,type,size")))

the process-lines fails if the password is not cached by sudo.
I'm not sure how to fix it, but lsblk works without sudo for me (on Guix System).

Add support for systemd-mount/systemd-umount

It would be great to use it instead of udiskie because we can automatically fsck before the mount to ensure that we always get a clean fs and we can use automount option to defer actual mounting to the time whenfs is really accessed. We can also use timeout-idle-sec to protect fs on removable drive from corruption due to sudden removalor power loss.

Spaces are not supported in mountpoints

When a drive name contains a space, most actions will fail due to mountpoint only containing the first part of the name until the first space.

The relevant code is here I believe

(defun helm-linux-disks--lsblk ()
  "Get an alist of candidates for `helm-linux-disks--lsblk-source'."
  (cl-loop for ((level . raw) . kdr) on (helm-linux-disks--lsblk-with-levels)
           for next-level = (when kdr (caar kdr))
           for has-child = (and next-level
                                (< level next-level))
           for (name mountpoint fstype type _size) = (pcase (split-string
                                                             (helm-linux-disks--lsblk-trim raw))
                                                       (`(,name ,type ,size)
                                                        (list name nil nil type nil size))
                                                       (`(,name ,fstype ,type ,size)
                                                        (list name nil fstype type size))
                                                       (fields fields))
           collect (cons raw
                         (make-linux-disk
                          :path name
                          :mountpoint mountpoint
                          :fstype fstype
                          :type (intern type)
                          :has-child-p has-child))))

You could either get the mountpoint as "everything but the last 2 words" or by calling
lsblk -n -p -o "mountpoint" or something like that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.