G
G
Grigory Pestov2017-09-17 19:27:01
linux
Grigory Pestov, 2017-09-17 19:27:01

Is it possible to completely hide one physical HDD from Ubuntu 16.04 LTS?

There was a need for two OS. I put the second Win7 OS (on a separate HDD), updated grub, everything is like clockwork here. Now it is necessary to make it so that when Ubuntu starts and fdisk is executed, it does not see the screw on which Windows is installed. !I didn't mount it, I didn't see it! Having gone through a lot of English-language reading matter, I found out that there is such an opportunity by creating my own rule for the udev daemon. In theory, everything is simple: we create our own rule in /etc/udev/rules.d/20-myudev.rules with the content:

SUBSYSTEM=="block", ATTRS{model}=="HDS722580VLAT20 ", OPTIONS:="ignore_device"
we get the necessary values ​​as a result of the execution:
udevadm info -a -n /dev/sda
save the file, restart udev and in theory everything should work. But the miracle did not happen ... After reading more, I came to another option:
SUBSYSTEM=="block", ATTRS{model}=="HDS722580VLAT20 ", ENV{UDISKS_IGNORE} = "1"
but it didn't work either. As a result of testing:
udevadm testdev/sda1
it turns out that my rule is read without errors:
version 229
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

=== trie on-disk ===
tool version:          229
file size:         7064122 bytes
header size             80 bytes
strings            1764282 bytes
nodes              5299760 bytes
Load module index
timestamp of '/etc/systemd/network' changed
timestamp of '/lib/systemd/network' changed
Parsed configuration file /lib/systemd/network/99-default.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
Reading rules file: /etc/udev/rules.d/30-myudev.rules
Reading rules file: /lib/udev/rules.d/39-usbmuxd.rules
Reading rules file: /lib/udev/rules.d/40-crda.rules

but the result is an error:
rules contain 393216 bytes tokens (32768 * 12 bytes), 35796 bytes strings
26645 strings (221318 bytes), 23040 de-duplicated (189128 bytes), 3606 trie nodes used
sd-device: syspath '/sysdev/sda1' is not a subdirectory of /sys
unable to open device '/sysdev/sda1'
Unload module index
Unloaded link configuration context.

I would like to hear the opinion of more experienced Linux users, what am I doing wrong and how it is possible to do what I need.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Moseychuk, 2017-09-17
@fshp

/sysdev/sda1

Where did you get this path from?

P
pfg21, 2017-09-17
@pfg21

played from 16.04, the result is in the spoiler

udevadm info -a -n /dev/sda
looking at device '/devices/pci0000:00/0000:00:07.1/ata1/host0/target0:0:0/0:0:0:0/block/sda':
KERNEL=="sda"
SUBSYSTEM=="block"
DRIVER==""
ATTR{alignment_offset}=="0"
ATTR{capability}=="50"
ATTR{discard_alignment}=="0"
ATTR{events}==""
ATTR{events_async}==""
ATTR{events_poll_msecs}=="-1"
ATTR{ext_range}=="256"
ATTR{inflight}==" 0 0"
ATTR{range}=="16"
ATTR{removable}=="0"
ATTR{ro}=="0"
ATTR{size}=="625140335"
ATTR{stat}=="15934769 6700311 769875367 35978384 684761 382635 88319416 27522076 0 21761480 63430820"
looking at parent device '/devices/pci0000:00/0000:00:07.1/ata1/host0/target0:0:0/0:0:0:0':
KERNELS=="0:0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{device_blocked}=="0"
ATTRS{device_busy}=="0"
ATTRS{dh_state}=="detached"
ATTRS{eh_timeout}=="10"
ATTRS{evt_capacity_change_reported}=="0"
ATTRS{evt_inquiry_change_reported}=="0"
ATTRS{evt_lun_change_reported}=="0"
ATTRS{evt_media_change}=="0"
ATTRS{evt_mode_parameter_change_reported}=="0"
ATTRS{evt_soft_threshold_reached}=="0"
ATTRS{inquiry}==""
ATTRS{iocounterbits}=="32"
ATTRS{iodone_cnt}=="0x10072bd"
ATTRS{ioerr_cnt}=="0x493"
ATTRS{iorequest_cnt}=="0x10072bd"
ATTRS{model}=="Hitachi HDP72503"
ATTRS{queue_depth}=="1"
ATTRS{queue_type}=="none"
ATTRS{rev}=="A4CA"
ATTRS{scsi_level}=="6"
ATTRS{state}=="running"
ATTRS{timeout}=="30"
ATTRS{type}=="0"
ATTRS{vendor}=="ATA "
ATTRS{vpd_pg80}==""
ATTRS{vpd_pg83}==""
If you look closely, you can see that the attribute ATTRS{model}=="Hitachi HDP72503" is in the same section with SUBSYSTEMS=="scsi", and there is no "model" in the section with SUBSYSTEM=="block".
those. matching by your rule will never work.
look at the output of your info, maybe because of this.
I would directly block partitions with file systems, they have a UUID

Z
zlen13, 2017-09-19
@zlen13

try udevadm test / block /sda

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question