LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 01-11-2024, 08:12 PM   #1
maybeJosiah
Member
 
Registered: Jan 2024
Location: USA
Distribution: Ubuntu, Android, Ubuntu Touch, Jolla Sailfish maybe
Posts: 195
Blog Entries: 2

Rep: Reputation: 5
Question Does debugfs with set_inode_field for timestamps work?


For created at:
sudo debugfs -w -R 'set_inode_field <'$inode'> crtime '$formatted_time'' "$device"
Also like this for changed at time:
sudo debugfs -w -R 'set_inode_field <'$inode'> ctime '$formatted_time'' "$device"

Like my source is man debugfs and zzzcode.ai. Latter was unsure whether to include <> but man debugfs clears that up. These are Ubuntu commands. Use on a bootable USB for main drive if ever on main drive. From what I remember stat may be used for $inode. What I am trying for is if, for record, this actually works.

I saw a thing on Linux and Unix Stack Exchange someone did in fact set crtime with a hi and lo. https://unix.stackexchange.com/quest...4fs-filesystem
What I try for is a program that uses a file to set all timestamps that can be set like originals from a backup. I already have a recorder and a reader that maybe sets timestamps. I would be using Bash. All I need to know is if I can set created at time and changed at time with debugfs. If there is a way I may accept that answer. Test it before saying there is a way. I do not have a full backup yet so I can't do it like myself. Maybe a blank computer with Ubuntu freshly installed would be a good thing for testing. Try to lose nothing and be careful. From what I can tell format for time is Seconds.nanos like some big number of seconds, a ., nanos. This can mess up your system so be careful. Maybe read "man debugfs" for details before testing this.

From what I underatand -w means use in read write mode, -R means execute one command and exit (needed for in Bash) that in quotes is command, set_inode_field is like it states, filespec, either <inode> or file path, comes next, which field, ctime for changed at or crtime for created at, is next, next is to set it to formatted, out of quotes, next is device that is with files to set, like /dev/sda1 but should not be that with safer usage. Just can debugfs set created at and changed at and maybe some how to answer. I already saw another question that could use an answer to this.
https://www.linuxquestions.org/quest...t4-4175625229/
X E.
 
Old 01-12-2024, 09:08 AM   #2
maybeJosiah
Member
 
Registered: Jan 2024
Location: USA
Distribution: Ubuntu, Android, Ubuntu Touch, Jolla Sailfish maybe
Posts: 195

Original Poster
Blog Entries: 2

Rep: Reputation: 5
Many debugfs commands take a filespec as an argument to specify an inode (as opposed to a pathname) in the filesystem which is currently opened by debugfs. The filespec argument may be specified in two forms. The first form is an inode number surrounded by angle brackets, e.g., <2>. The second form is a pathname; if the pathname is prefixed by a forward slash ('/'), then it is interpreted relative to the root of the filesystem which is currently opened by debugfs. If not, the pathname is interpreted relative to the current working directory as maintained by debugfs. This may be modified by using the debugfs command cd.

set_inode_field filespec field value
Modify the inode specified by filespec so that the inode field field has value value. The list of valid inode fields which can be set via this command can be displayed by using the command: set_inode_field -l

https://linux.die.net/man/8/debugfs
That from man debugfs. Still no official word in that what format timestamps should be in. If you try set_inode_field -l it should show more and if you try, post results please. I can't find more information. If it helps I am trying to set date with nanos and although it has been wrong before you may use zzzcode.ai. Note for relative path to current directory omit first /. All else is like inside debugfs. Also, use file paths for this. Be careful where you are like with cd.

https://zzzcode.ai/answer-question?i...2-3e96c61a1703
I am trying to set times to nanosecond precision and maybe this helps. X E.

Last edited by maybeJosiah; 01-12-2024 at 09:48 AM. Reason: format maybe
 
Old 01-12-2024, 10:31 AM   #3
maybeJosiah
Member
 
Registered: Jan 2024
Location: USA
Distribution: Ubuntu, Android, Ubuntu Touch, Jolla Sailfish maybe
Posts: 195

Original Poster
Blog Entries: 2

Rep: Reputation: 5
There is no more information out there so I contacted author of debugfs. X E.
 
Old 01-13-2024, 01:03 PM   #4
maybeJosiah
Member
 
Registered: Jan 2024
Location: USA
Distribution: Ubuntu, Android, Ubuntu Touch, Jolla Sailfish maybe
Posts: 195

Original Poster
Blog Entries: 2

Rep: Reputation: 5
https://www.linuxquestions.org/quest...530/page2.html
Yes it can be done and this is tested by Petri Kaukasoina. Thank you. X E.
 
  


Reply

Tags
backup, bash, timestamp



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
[SOLVED] What order should I restore timestamps including with debugfs? maybeJosiah Ubuntu 42 01-15-2024 08:02 AM
batch commands to debugfs with a read-only filesystem billhowe Red Hat 1 08-21-2004 11:02 AM
Using undel command in debugfs chii-chan Linux - Newbie 6 03-01-2004 07:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 12:53 AM.

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