What happens if you delete a device file?

Clash Royale CLAN TAG#URR8PPP
up vote
20
down vote
favorite
I roughly know about the files located under /dev.
I know there are two types (character/block), accessing these files communicates with a driver in the kernel.
I want to know what happens if I delete one -- specifically for both types of file. If I delete a block device file, say /dev/sda, what effect -- if any --
does this have? Have I just unmounted the disk?
Similarly, what if I delete /dev/mouse/mouse0 -- what happens? Does the mouse stop working? Does it automatically replace itself?
Can I even delete these files? If I had a VM set up, I'd try it.
linux linux-kernel udev devices block-device
add a comment |Â
up vote
20
down vote
favorite
I roughly know about the files located under /dev.
I know there are two types (character/block), accessing these files communicates with a driver in the kernel.
I want to know what happens if I delete one -- specifically for both types of file. If I delete a block device file, say /dev/sda, what effect -- if any --
does this have? Have I just unmounted the disk?
Similarly, what if I delete /dev/mouse/mouse0 -- what happens? Does the mouse stop working? Does it automatically replace itself?
Can I even delete these files? If I had a VM set up, I'd try it.
linux linux-kernel udev devices block-device
1
I deleted /dev/zero on a SVR4 system once. Bad idea. Took a bit of work to get my system bootable again.
â Brad Lanam
Feb 9 at 16:30
add a comment |Â
up vote
20
down vote
favorite
up vote
20
down vote
favorite
I roughly know about the files located under /dev.
I know there are two types (character/block), accessing these files communicates with a driver in the kernel.
I want to know what happens if I delete one -- specifically for both types of file. If I delete a block device file, say /dev/sda, what effect -- if any --
does this have? Have I just unmounted the disk?
Similarly, what if I delete /dev/mouse/mouse0 -- what happens? Does the mouse stop working? Does it automatically replace itself?
Can I even delete these files? If I had a VM set up, I'd try it.
linux linux-kernel udev devices block-device
I roughly know about the files located under /dev.
I know there are two types (character/block), accessing these files communicates with a driver in the kernel.
I want to know what happens if I delete one -- specifically for both types of file. If I delete a block device file, say /dev/sda, what effect -- if any --
does this have? Have I just unmounted the disk?
Similarly, what if I delete /dev/mouse/mouse0 -- what happens? Does the mouse stop working? Does it automatically replace itself?
Can I even delete these files? If I had a VM set up, I'd try it.
linux linux-kernel udev devices block-device
edited Feb 16 at 1:07
Jeff Schaller
31.3k846105
31.3k846105
asked Feb 9 at 11:21
alpha
1,241317
1,241317
1
I deleted /dev/zero on a SVR4 system once. Bad idea. Took a bit of work to get my system bootable again.
â Brad Lanam
Feb 9 at 16:30
add a comment |Â
1
I deleted /dev/zero on a SVR4 system once. Bad idea. Took a bit of work to get my system bootable again.
â Brad Lanam
Feb 9 at 16:30
1
1
I deleted /dev/zero on a SVR4 system once. Bad idea. Took a bit of work to get my system bootable again.
â Brad Lanam
Feb 9 at 16:30
I deleted /dev/zero on a SVR4 system once. Bad idea. Took a bit of work to get my system bootable again.
â Brad Lanam
Feb 9 at 16:30
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
30
down vote
accepted
Those are simply (special) files. They only serve as "pointers" to the actual device. (i.e. the driver module inside the kernel.)
If some command/service already opened that file, it already has a handle to the device and will continue working.
If some command/service tries to open a new connection, it will try to access that file and fail because of "file not found".
Usually those files are populated by udev, which automatically creates them at system startup and on special events like plugging in a USB device, but you could also manually create those using mknod.
3
This doesn't really answer the question...
â Gogeta70
Feb 9 at 16:53
"Usually those files are populated by udev" Usually, but on Linux. There'smakedevcommand which usually does the job, and unlikeudevit seems to be present among most unix-like os.
â Sergiy Kolodyazhnyy
Feb 9 at 17:07
1
@Gogeta70 which part of the question does this post leave unanswered?
â Ruslan
Feb 10 at 17:40
@RonJohn The question is taggedlinuxandudev
â Michael Mrozekâ¦
Feb 10 at 23:18
1
@RonJohn Yes,but with a "but". The Ubuntu Hacks book which is from like '06 shows there is/etc/init.d/makedev. The freebsd manual mentions MAKEDEV appeared in 4.2BSD (from 1983). I think in 1983 it would be just as logical to makeMAKEDEVautomated via init as in 06
â Sergiy Kolodyazhnyy
Feb 11 at 1:01
 |Â
show 3 more comments
up vote
8
down vote
Device files are actually a filesystem alias for an entry in the kernel's device table. If you look at the /dev files with "ls -l" you'll see they have a major device number and a minor device number. If you delete the files from the filesystem, you can always recreate them using the appropriate tools to relink the special file to the entry in the kernel device table -- see mknod(1).
add a comment |Â
up vote
3
down vote
From that moment on, they can only be accessed by programs that had those devices already open. So, it's no way to unmount filesystems. And with udev, a reboot might restore those devices. A strange way to learn unix.
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
30
down vote
accepted
Those are simply (special) files. They only serve as "pointers" to the actual device. (i.e. the driver module inside the kernel.)
If some command/service already opened that file, it already has a handle to the device and will continue working.
If some command/service tries to open a new connection, it will try to access that file and fail because of "file not found".
Usually those files are populated by udev, which automatically creates them at system startup and on special events like plugging in a USB device, but you could also manually create those using mknod.
3
This doesn't really answer the question...
â Gogeta70
Feb 9 at 16:53
"Usually those files are populated by udev" Usually, but on Linux. There'smakedevcommand which usually does the job, and unlikeudevit seems to be present among most unix-like os.
â Sergiy Kolodyazhnyy
Feb 9 at 17:07
1
@Gogeta70 which part of the question does this post leave unanswered?
â Ruslan
Feb 10 at 17:40
@RonJohn The question is taggedlinuxandudev
â Michael Mrozekâ¦
Feb 10 at 23:18
1
@RonJohn Yes,but with a "but". The Ubuntu Hacks book which is from like '06 shows there is/etc/init.d/makedev. The freebsd manual mentions MAKEDEV appeared in 4.2BSD (from 1983). I think in 1983 it would be just as logical to makeMAKEDEVautomated via init as in 06
â Sergiy Kolodyazhnyy
Feb 11 at 1:01
 |Â
show 3 more comments
up vote
30
down vote
accepted
Those are simply (special) files. They only serve as "pointers" to the actual device. (i.e. the driver module inside the kernel.)
If some command/service already opened that file, it already has a handle to the device and will continue working.
If some command/service tries to open a new connection, it will try to access that file and fail because of "file not found".
Usually those files are populated by udev, which automatically creates them at system startup and on special events like plugging in a USB device, but you could also manually create those using mknod.
3
This doesn't really answer the question...
â Gogeta70
Feb 9 at 16:53
"Usually those files are populated by udev" Usually, but on Linux. There'smakedevcommand which usually does the job, and unlikeudevit seems to be present among most unix-like os.
â Sergiy Kolodyazhnyy
Feb 9 at 17:07
1
@Gogeta70 which part of the question does this post leave unanswered?
â Ruslan
Feb 10 at 17:40
@RonJohn The question is taggedlinuxandudev
â Michael Mrozekâ¦
Feb 10 at 23:18
1
@RonJohn Yes,but with a "but". The Ubuntu Hacks book which is from like '06 shows there is/etc/init.d/makedev. The freebsd manual mentions MAKEDEV appeared in 4.2BSD (from 1983). I think in 1983 it would be just as logical to makeMAKEDEVautomated via init as in 06
â Sergiy Kolodyazhnyy
Feb 11 at 1:01
 |Â
show 3 more comments
up vote
30
down vote
accepted
up vote
30
down vote
accepted
Those are simply (special) files. They only serve as "pointers" to the actual device. (i.e. the driver module inside the kernel.)
If some command/service already opened that file, it already has a handle to the device and will continue working.
If some command/service tries to open a new connection, it will try to access that file and fail because of "file not found".
Usually those files are populated by udev, which automatically creates them at system startup and on special events like plugging in a USB device, but you could also manually create those using mknod.
Those are simply (special) files. They only serve as "pointers" to the actual device. (i.e. the driver module inside the kernel.)
If some command/service already opened that file, it already has a handle to the device and will continue working.
If some command/service tries to open a new connection, it will try to access that file and fail because of "file not found".
Usually those files are populated by udev, which automatically creates them at system startup and on special events like plugging in a USB device, but you could also manually create those using mknod.
edited Feb 16 at 1:00
Jeff Schaller
31.3k846105
31.3k846105
answered Feb 9 at 11:30
michas
14.5k33468
14.5k33468
3
This doesn't really answer the question...
â Gogeta70
Feb 9 at 16:53
"Usually those files are populated by udev" Usually, but on Linux. There'smakedevcommand which usually does the job, and unlikeudevit seems to be present among most unix-like os.
â Sergiy Kolodyazhnyy
Feb 9 at 17:07
1
@Gogeta70 which part of the question does this post leave unanswered?
â Ruslan
Feb 10 at 17:40
@RonJohn The question is taggedlinuxandudev
â Michael Mrozekâ¦
Feb 10 at 23:18
1
@RonJohn Yes,but with a "but". The Ubuntu Hacks book which is from like '06 shows there is/etc/init.d/makedev. The freebsd manual mentions MAKEDEV appeared in 4.2BSD (from 1983). I think in 1983 it would be just as logical to makeMAKEDEVautomated via init as in 06
â Sergiy Kolodyazhnyy
Feb 11 at 1:01
 |Â
show 3 more comments
3
This doesn't really answer the question...
â Gogeta70
Feb 9 at 16:53
"Usually those files are populated by udev" Usually, but on Linux. There'smakedevcommand which usually does the job, and unlikeudevit seems to be present among most unix-like os.
â Sergiy Kolodyazhnyy
Feb 9 at 17:07
1
@Gogeta70 which part of the question does this post leave unanswered?
â Ruslan
Feb 10 at 17:40
@RonJohn The question is taggedlinuxandudev
â Michael Mrozekâ¦
Feb 10 at 23:18
1
@RonJohn Yes,but with a "but". The Ubuntu Hacks book which is from like '06 shows there is/etc/init.d/makedev. The freebsd manual mentions MAKEDEV appeared in 4.2BSD (from 1983). I think in 1983 it would be just as logical to makeMAKEDEVautomated via init as in 06
â Sergiy Kolodyazhnyy
Feb 11 at 1:01
3
3
This doesn't really answer the question...
â Gogeta70
Feb 9 at 16:53
This doesn't really answer the question...
â Gogeta70
Feb 9 at 16:53
"Usually those files are populated by udev" Usually, but on Linux. There's
makedev command which usually does the job, and unlike udev it seems to be present among most unix-like os.â Sergiy Kolodyazhnyy
Feb 9 at 17:07
"Usually those files are populated by udev" Usually, but on Linux. There's
makedev command which usually does the job, and unlike udev it seems to be present among most unix-like os.â Sergiy Kolodyazhnyy
Feb 9 at 17:07
1
1
@Gogeta70 which part of the question does this post leave unanswered?
â Ruslan
Feb 10 at 17:40
@Gogeta70 which part of the question does this post leave unanswered?
â Ruslan
Feb 10 at 17:40
@RonJohn The question is tagged
linux and udevâ Michael Mrozekâ¦
Feb 10 at 23:18
@RonJohn The question is tagged
linux and udevâ Michael Mrozekâ¦
Feb 10 at 23:18
1
1
@RonJohn Yes,but with a "but". The Ubuntu Hacks book which is from like '06 shows there is
/etc/init.d/makedev. The freebsd manual mentions MAKEDEV appeared in 4.2BSD (from 1983). I think in 1983 it would be just as logical to make MAKEDEV automated via init as in 06â Sergiy Kolodyazhnyy
Feb 11 at 1:01
@RonJohn Yes,but with a "but". The Ubuntu Hacks book which is from like '06 shows there is
/etc/init.d/makedev. The freebsd manual mentions MAKEDEV appeared in 4.2BSD (from 1983). I think in 1983 it would be just as logical to make MAKEDEV automated via init as in 06â Sergiy Kolodyazhnyy
Feb 11 at 1:01
 |Â
show 3 more comments
up vote
8
down vote
Device files are actually a filesystem alias for an entry in the kernel's device table. If you look at the /dev files with "ls -l" you'll see they have a major device number and a minor device number. If you delete the files from the filesystem, you can always recreate them using the appropriate tools to relink the special file to the entry in the kernel device table -- see mknod(1).
add a comment |Â
up vote
8
down vote
Device files are actually a filesystem alias for an entry in the kernel's device table. If you look at the /dev files with "ls -l" you'll see they have a major device number and a minor device number. If you delete the files from the filesystem, you can always recreate them using the appropriate tools to relink the special file to the entry in the kernel device table -- see mknod(1).
add a comment |Â
up vote
8
down vote
up vote
8
down vote
Device files are actually a filesystem alias for an entry in the kernel's device table. If you look at the /dev files with "ls -l" you'll see they have a major device number and a minor device number. If you delete the files from the filesystem, you can always recreate them using the appropriate tools to relink the special file to the entry in the kernel device table -- see mknod(1).
Device files are actually a filesystem alias for an entry in the kernel's device table. If you look at the /dev files with "ls -l" you'll see they have a major device number and a minor device number. If you delete the files from the filesystem, you can always recreate them using the appropriate tools to relink the special file to the entry in the kernel device table -- see mknod(1).
answered Feb 9 at 16:11
Stephen M. Webb
23113
23113
add a comment |Â
add a comment |Â
up vote
3
down vote
From that moment on, they can only be accessed by programs that had those devices already open. So, it's no way to unmount filesystems. And with udev, a reboot might restore those devices. A strange way to learn unix.
add a comment |Â
up vote
3
down vote
From that moment on, they can only be accessed by programs that had those devices already open. So, it's no way to unmount filesystems. And with udev, a reboot might restore those devices. A strange way to learn unix.
add a comment |Â
up vote
3
down vote
up vote
3
down vote
From that moment on, they can only be accessed by programs that had those devices already open. So, it's no way to unmount filesystems. And with udev, a reboot might restore those devices. A strange way to learn unix.
From that moment on, they can only be accessed by programs that had those devices already open. So, it's no way to unmount filesystems. And with udev, a reboot might restore those devices. A strange way to learn unix.
answered Feb 9 at 11:28
Gerard H. Pille
1,179212
1,179212
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f423012%2fwhat-happens-if-you-delete-a-device-file%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
I deleted /dev/zero on a SVR4 system once. Bad idea. Took a bit of work to get my system bootable again.
â Brad Lanam
Feb 9 at 16:30