LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 01-27-2020, 12:04 PM   #1
YuvalAvra
LQ Newbie
 
Registered: Nov 2019
Posts: 12

Rep: Reputation: Disabled
Do block device changes propgate to mounts


I've been using debugfs to write/change block devices directly, and I'm seeing inconsistencies when it comes to existing mounts of that block device, the changes I make don't always appear in the mount.

When do changes to the block device propagate to existing mount points of that device?
If the mount is read-only - does that have any effect?

For example:
Code:
$ debugfs -w /dev/rootfs_device
 (debugfs) cd lib64
 (debugfs) write my_library.so library.so
 (debugfs) close -a
$ ls -al /lib64  # Changes don't always propagate to mount (maybe there's a correlation to file size?)
Thanks
 
Old 01-27-2020, 12:37 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,786

Rep: Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215
Any data blocks or filesystem metadata that the kernel is holding in its cache will continue to be used, and if any of that gets altered in the running system the dirty blocks will be written out to the disk, overwriting your changes. You can easily end up with the filesystem metadata in an inconsistent state (data blocks being used in an inode but marked free in the block map, that sort of thing), so it's a really bad idea to be writing to a mounted filesystem.
 
1 members found this post helpful.
Old 01-28-2020, 03:32 AM   #3
YuvalAvra
LQ Newbie
 
Registered: Nov 2019
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
Any data blocks or filesystem metadata that the kernel is holding in its cache will continue to be used, and if any of that gets altered in the running system the dirty blocks will be written out to the disk, overwriting your changes. You can easily end up with the filesystem metadata in an inconsistent state (data blocks being used in an inode but marked free in the block map, that sort of thing), so it's a really bad idea to be writing to a mounted filesystem.
Thanks! that makes sense.
Come to think about it, I'm not sure how any file I created was propagated to the mount, as the wouldn't appear in the dentry cache.
Perhaps the file was created in a directory that was yet to be touched by the running system?
 
Old 01-28-2020, 08:44 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,786

Rep: Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215Reputation: 2215
Quote:
Originally Posted by YuvalAvra View Post
Perhaps the file was created in a directory that was yet to be touched by the running system?
Most likely. The block bitmap would still be a concern. If the kernel is using a cached version of the portion of the map that you've altered, that mismatch would create a situation that needs to be cleaned up by fsck, with a possibility of corrupted files.

Last edited by rknichols; 01-28-2020 at 08:45 AM.
 
  


Reply

Tags
block device, mount



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to affect changes to a Flash Drive that only mounts read only bushy Linux - Newbie 17 08-20-2019 11:56 AM
LXer: Technology Changes Us, Changes Society, and Changes Governments LXer Syndicated Linux News 0 10-10-2016 02:00 PM
ls -l shows mounts with a green block of colour round them 0ddba11 Linux - Server 4 03-18-2015 10:18 AM
Block device /dev/sda3 is not a valid root device.. rincewind Linux - Hardware 7 06-09-2006 04:47 AM
UL 1.0 GRUB: could not find device for /boot: not found or not a block device cma Linux - General 4 12-12-2005 03:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 05:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration