diff --git a/system/base/eudev/actions.py b/system/base/eudev/actions.py index 850297ec..f24a82b3 100644 --- a/system/base/eudev/actions.py +++ b/system/base/eudev/actions.py @@ -70,7 +70,4 @@ def install(): # Add man files pisitools.doman("man/*.5", "man/*.7", "man/*.8") - pisitools.dodoc("README*", "NOTES") - - # Add rules for mount storage - pisitools.insinto("/lib/udev/rules.d","rules/60-persistent-storage.rules") \ No newline at end of file + pisitools.dodoc("README*", "NOTES") \ No newline at end of file diff --git a/system/base/eudev/files/10-flash-mounts.rules.old b/system/base/eudev/files/10-flash-mounts.rules.old new file mode 100644 index 00000000..f2f66f44 --- /dev/null +++ b/system/base/eudev/files/10-flash-mounts.rules.old @@ -0,0 +1,75 @@ +#! /bin/sh + +####################################### +# USB Flash Drives automounting # +####################################### + +# start at sdb to ignore the system hard drive +KERNEL!="sd[b-z]*", GOTO="exit" +ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="exit" + +# import some useful filesystem info as variables +IMPORT{program}="/sbin/blkid -o udev -p %N" + +# get the label if present, otherwise assign one based on device/partition +ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}" +ENV{ID_FS_LABEL}=="", ENV{dir_name}="flash_drive_%k" + +# create the dir in /media and symlink it to /mnt +ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'" + +# global mount options +#ACTION=="add", ENV{mount_options}="relatime" + +# filesystem-specific mount options (777/666 dir/file perms for ntfs/vfat) + + + +######## +# vfat # +######## + +# vfat specific mount options +ACTION=="add", ENV{mount_options_vfat}="gid=100,dmask=000,fmask=111,utf8,flush,rw,noatime,users" + +# add device to /etc/fstab +ACTION=="add", ENV{ID_FS_TYPE}=="vfat", RUN+="/bin/sed -i '$a\/dev/%k /media/%E{dir_name} vfat %E{mount_options_vfat} 0 0' /etc/fstab" + +# mount device +ACTION=="add", ENV{ID_FS_TYPE}=="vfat", RUN+="/bin/mount -t auto -o %E{mount_options_vfat} /dev/%k '/media/%E{dir_name}'" + + + +######## +# ntfs # +######## + +# ntfs specific mount options +ACTION=="add", ENV{mount_options_ntfs}="gid=100,dmask=000,fmask=111,utf8,flush,rw,noatime,users" + +# add device to /etc/fstab +ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/sed -i '$a\/dev/%k /media/%E{dir_name} ntfs-3g %E{mount_options_ntfs} 0 0' /etc/fstab" + +# mount device +ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/mount -t ntfs-3g -o %E{mount_options_ntfs} /dev/%k '/media/%E{dir_name}'" + + + +##################### +# other filesystems # +##################### + +# ntfs specific mount options +ACTION=="add", ENV{mount_options_other}="gid=100,dmask=000,fmask=111,utf8,flush,rw,noatime,users" + +# automount all other filesystems +ACTION=="add", ENV{ID_FS_TYPE}!="(ntfs|vfat)", RUN+="/bin/mount -t auto -o %E{mount_options_other} /dev/%k '/media/%E{dir_name}'" + +################################# +# clean up after device removal # +################################# +ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l '/media/%E{dir_name}'", RUN+="/bin/rmdir '/media/%E{dir_name}'" +ACTION=="remove", ENV{ID_FS_TYPE}!="", RUN+="/bin/sed -i '/\/dev\/%k /d' /etc/fstab" + +# exit +LABEL="exit" diff --git a/system/base/eudev/files/10-sdcards-mounts.rules b/system/base/eudev/files/10-sdcards-mounts.rules new file mode 100644 index 00000000..7a893e68 --- /dev/null +++ b/system/base/eudev/files/10-sdcards-mounts.rules @@ -0,0 +1,75 @@ +#! /bin/sh + +####################################### +# USB Flash Drives automounting # +####################################### + +# start at sdb to ignore the system hard drive +KERNEL!="mmcblk[0-9]p[0-9]", GOTO="exit" +ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="exit" + +# import some useful filesystem info as variables +IMPORT{program}="/sbin/blkid -o udev -p %N" + +# get the label if present, otherwise assign one based on device/partition +ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}" +ENV{ID_FS_LABEL}=="", ENV{dir_name}="sd_card_%k" + +# create the dir in /media and symlink it to /mnt +ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'" + +# global mount options +#ACTION=="add", ENV{mount_options}="relatime" + +# filesystem-specific mount options (777/666 dir/file perms for ntfs/vfat) + + + +######## +# vfat # +######## + +# vfat specific mount options +ACTION=="add", ENV{mount_options_vfat}="gid=100,dmask=000,fmask=111,utf8,flush,rw,noatime,users" + +# add device to /etc/fstab +ACTION=="add", ENV{ID_FS_TYPE}=="vfat", RUN+="/bin/sed -i '$a\/dev/%k /media/%E{dir_name} vfat %E{mount_options_vfat} 0 0' /etc/fstab" + +# mount device +ACTION=="add", ENV{ID_FS_TYPE}=="vfat", RUN+="/bin/mount -t auto -o %E{mount_options_vfat} /dev/%k '/media/%E{dir_name}'" + + + +######## +# ntfs # +######## + +# ntfs specific mount options +ACTION=="add", ENV{mount_options_ntfs}="gid=100,dmask=000,fmask=111,utf8,flush,rw,noatime,users" + +# add device to /etc/fstab +ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/sed -i '$a\/dev/%k /media/%E{dir_name} ntfs-3g %E{mount_options_ntfs} 0 0' /etc/fstab" + +# mount device +ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/mount -t ntfs-3g -o %E{mount_options_ntfs} /dev/%k '/media/%E{dir_name}'" + + + +##################### +# other filesystems # +##################### + +# ntfs specific mount options +ACTION=="add", ENV{mount_options_other}="gid=100,dmask=000,fmask=111,utf8,flush,rw,noatime,users" + +# automount all other filesystems +ACTION=="add", ENV{ID_FS_TYPE}!="(ntfs|vfat)", RUN+="/bin/mount -t auto -o %E{mount_options_other} /dev/%k '/media/%E{dir_name}'" + +################################# +# clean up after device removal # +################################# +ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l '/media/%E{dir_name}'", RUN+="/bin/rmdir '/media/%E{dir_name}'" +ACTION=="remove", ENV{ID_FS_TYPE}!="", RUN+="/bin/sed -i '/\/dev\/%k /d' /etc/fstab" + +# exit +LABEL="exit" diff --git a/system/base/eudev/files/60-persistent-storage.rules b/system/base/eudev/files/60-persistent-storage.rules new file mode 100644 index 00000000..71c35008 --- /dev/null +++ b/system/base/eudev/files/60-persistent-storage.rules @@ -0,0 +1,82 @@ +# do not edit this file, it will be overwritten on update + +# persistent storage links: /dev/disk/{by-id,by-uuid,by-label,by-path} +# scheme based on "Linux persistent device names", 2004, Hannes Reinecke + +ACTION=="remove", GOTO="persistent_storage_end" + +SUBSYSTEM!="block", GOTO="persistent_storage_end" +KERNEL!="loop*|mmcblk*[0-9]|msblk*[0-9]|mspblk*[0-9]|nvme*|sd*|sr*|vd*", GOTO="persistent_storage_end" + +# ignore partitions that span the entire disk +TEST=="whole_disk", GOTO="persistent_storage_end" + +# for partitions import parent information +ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*" + +# virtio-blk +KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}" +KERNEL=="vd*[0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}-part%n" + +# ATA +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $devnode" + +# ATAPI devices (SPC-3 or later) +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{type}=="5", ATTRS{scsi_level}=="[6-9]*", IMPORT{program}="ata_id --export $devnode" + +# Run ata_id on non-removable USB Mass Storage (SATA/PATA disks in enclosures) +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", ATTR{removable}=="0", SUBSYSTEMS=="usb", IMPORT{program}="ata_id --export $devnode" + +# Fall back usb_id for USB devices +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id" + +# SCSI devices +KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="scsi" +KERNEL=="sd*|sr*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}" +KERNEL=="sd*", ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n" + +# FireWire +KERNEL=="sd*[!0-9]|sr*", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}" +KERNEL=="sd*[0-9]", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}-part%n" + +# MMC +KERNEL=="mmcblk[0-9]", SUBSYSTEMS=="mmc", ATTRS{name}=="?*", ATTRS{serial}=="?*", \ + ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}" +KERNEL=="mmcblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}-part%n" + +# Memstick +KERNEL=="msblk[0-9]|mspblk[0-9]", SUBSYSTEMS=="memstick", ATTRS{name}=="?*", ATTRS{serial}=="?*", \ + ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}" +KERNEL=="msblk[0-9]p[0-9]|mspblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}-part%n" + +# by-path +ENV{DEVTYPE}=="disk", DEVPATH!="*/virtual/*", IMPORT{builtin}="path_id" +ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}" +ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n" + +# probe filesystem metadata of optical drives which have a media inserted +KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", \ + IMPORT{program}="/sbin/blkid --offset=$env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}" +# single-session CDs do not have ID_CDROM_MEDIA_SESSION_LAST_OFFSET +KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="", \ + IMPORT{program}="/sbin/blkid --noraid" + +# probe filesystem metadata of disks +KERNEL!="sr*", IMPORT{program}="/sbin/blkid" + +# by-label/by-uuid links (filesystem metadata) +ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" +ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" + +# by-id (World Wide Name) +ENV{DEVTYPE}=="disk", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}" +ENV{DEVTYPE}=="partition", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}-part%n" + +# by-partlabel/by-partuuid links (partition metadata) +ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}" +ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}" + +# add symlink to GPT root disk +ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_GPT_AUTO_ROOT}=="1", SYMLINK+="gpt-auto-root" + +LABEL="persistent_storage_end" diff --git a/system/base/eudev/files/70-yali.rules b/system/base/eudev/files/70-yali.rules new file mode 100644 index 00000000..582c5aa4 --- /dev/null +++ b/system/base/eudev/files/70-yali.rules @@ -0,0 +1,53 @@ +# If $YALI isn't set in the environment, skip all these rules. +#ENV{YALI}!="?*", GOTO="yali_end" + +ACTION!="add|change", GOTO="yali_end" +SUBSYSTEM!="block", GOTO="yali_end" + +# for device-mapper device we are supposed to only operate on "change" events +KERNEL=="dm-*", ACTION=="add", GOTO="yali_end" + +KERNEL=="dm-*", ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="yali_end" +KERNEL=="dm-*", ENV{DM_NAME}!="?*", GOTO="yali_end" +KERNEL=="dm-*", ENV{DM_SUSPENDED}=="1", GOTO="yali_end" +KERNEL=="dm-*", ENV{DM_SUSPENDED}=="Suspended", GOTO="yali_end" + +IMPORT{program}="/sbin/blkid -o udev -p $tempnode" + +LABEL="yali_mdraid" +KERNEL!="md*", GOTO="yali_mdraid_member" + +# container devices have a metadata version of e.g. 'external:ddf' and +# never leave state 'inactive' +ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state" +TEST!="md/array_state", GOTO="yali_mdraid_member" +ATTR{md/array_state}=="|clear|inactive", GOTO="yali_mdraid_member" +LABEL="md_ignore_state" + +IMPORT{program}="/sbin/mdadm --detail --export $tempnode" +ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace" +ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}" +ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}" +ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace" +ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n" +ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n" +ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n" + +OPTIONS+="link_priority=100" +OPTIONS+="watch" +ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" +ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" + +LABEL="yali_mdraid_member" +# probe raid metadata of mdraid member devices +ENV{ID_FS_TYPE}=="linux_raid_member", IMPORT{program}="/sbin/mdadm --examine --export $tempnode" +ENV{ID_FS_TYPE}=="isw_raid_member", IMPORT{program}="/sbin/mdadm --examine --export $tempnode" + +# probe metadata of LVM2 physical volumes +ENV{ID_FS_TYPE}=="LVM2_member", IMPORT{program}="/usr/sbin/lvm pvs --ignorelockingfailure --units k --nosuffix --nameprefixes --rows --unquoted --noheadings -opv_name,pv_uuid,pv_size,vg_name,vg_uuid,pv_pe_count,pv_pe_alloc_count,pe_start $tempnode" +ENV{LVM2_VG_NAME}!="?*", GOTO="yali_end" +ENV{ID_FS_TYPE}=="LVM2_member", IMPORT{program}="/usr/sbin/lvm vgs --ignorelockingfailure --units k --nosuffix --nameprefixes --rows --unquoted --noheadings -ouuid,size,free,extent_size,extent_count,free_count,pv_count $env{LVM2_VG_NAME}" +ENV{ID_FS_TYPE}=="LVM2_member", IMPORT{program}="/usr/sbin/lvm lvs -a --ignorelockingfailure --units k --nosuffix --nameprefixes --rows --unquoted --noheadings -olv_name,lv_uuid,lv_size,lv_attr $env{LVM2_VG_NAME}" + +LABEL="yali_end" + diff --git a/system/base/eudev/pspec.xml b/system/base/eudev/pspec.xml index f1cf0bd1..31c33354 100644 --- a/system/base/eudev/pspec.xml +++ b/system/base/eudev/pspec.xml @@ -64,7 +64,8 @@ tmpfiles.conf - 10-flash-mounts.rules + 60-persistent-storage.rules + 70-yali.rules System.Package @@ -121,7 +122,7 @@ - 2016-01-03 + 2016-01-04 3.1.2 Add rules for mount storage, ntfs usb disc too. Ertuğrul Erata