LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-12-2024, 07:19 PM   #16
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

I guess that recording may be good enough until I get a safe enough way to set created at times. I have never seen a changed at time setter. I think I actually saw another thing called debugfs without a ext4. I am not totally sure but at least it is for all ext2 to ext4. I know subsecond precision is included in like my recordings. Thanks. X E.
 
Old 01-12-2024, 08:05 PM   #17
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://geek-university.com/debug-a-file-system/
https://command-not-found.com/debugfs
https://linuxlink.timesys.com/docs/w...TO_Use_debugfs
https://www.opensourceforu.com/2010/...-with-debugfs/
Some of like my research. Can I have Ubuntu Pro with this? Is it safe enough to run a fake file system while running main system? Who or what should I ask? X E.

Last edited by maybeJosiah; 01-12-2024 at 09:40 PM. Reason: how?
 
Old 01-13-2024, 05:09 AM   #18
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,815

Rep: Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491
Quote:
Originally Posted by maybeJosiah View Post
I have seen ending like MM:SS, unsure whether I could add .nanos.
Haven't you tried it yourself? Let's change ctime to 2025-01-01 12:34:56.123456789 UTC.

First nanoseconds for _extra:
Code:
$ echo $((4*123456789))                                       
493827156
Code:
root@linux:~ # debugfs -w /dev/sdc1
debugfs 1.43.1 (08-Jun-2016)
debugfs:  sif /home/kaukasoi/.bash_history ctime 20250101123456
debugfs:  sif /home/kaukasoi/.bash_history ctime_extra 493827156
debugfs:  quit
root@linux:~ # mount /disk3;TZ=UTC stat /disk3/home/kaukasoi/.bash_history;umount /disk3                     
  File: '/disk3/home/kaukasoi/.bash_history'
  Size: 6493            Blocks: 16         IO Block: 4096   regular file
Device: 821h/2081d      Inode: 17956886    Links: 1
Access: (0600/-rw-------)  Uid: ( 1000/kaukasoi)   Gid: (  100/   users)
Access: 2024-01-11 14:55:05.519576943 +0000
Modify: 2024-01-11 14:55:05.519576943 +0000
Change: 2025-01-01 12:34:56.123456789 +0000
 Birth: -

Last edited by Petri Kaukasoina; 01-13-2024 at 05:35 AM.
 
1 members found this post helpful.
Old 01-13-2024, 05:13 AM   #19
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,815

Rep: Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491
Quote:
Originally Posted by maybeJosiah View Post
https://geek-university.com/debug-a-file-system/
https://command-not-found.com/debugfs
https://linuxlink.timesys.com/docs/w...TO_Use_debugfs
https://www.opensourceforu.com/2010/...-with-debugfs/
Some of like my research. Can I have Ubuntu Pro with this? Is it safe enough to run a fake file system while running main system? Who or what should I ask? X E.
The first two links are about command 'debugfs' which you can use to manipulate your ext4 file system.

The other two links are about the 'debugfs' file system which is totally different.

What do you mean running a fake file system?
 
1 members found this post helpful.
Old 01-13-2024, 10:37 AM   #20
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
I think I meant like do not use this on your main hardware file system like for example /dev/sda1. Why I do not try it is it is supposedly dangerous for running systems. I would like a full backup before that and all USB sticks I currently have are toast, hold stuff I would rather not erase to use as ext4, or are that one USB that won't write as ext4. I would do it like myself if I had a backup. Since you ran it, can you run "set_inode_field -l" and post result? That would be in debugfs shell. To sum up what I found, there is a kernel option that must be enabled to have debugfs work. CONFIG_DEBUG_FS=y

That I do not know how to enable or check. I thought others were useful because they were how other people used debugfs successfully. If you do not have a good backup, get one before continuing this Petri Kaukasoina. Not much else in those links. Also, in debugfs "help" might be good. Knowing you, you probably have a good backup. Not sure why I am like alone on this save crtime and ctime thing. X E.
 
Old 01-13-2024, 10:49 AM   #21
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
Thanks Petri Kaukasoina, it works for change time. Also, I do not have a root password and would recommend using sudo. Also, are you using a secondary partition? Nice if you are, I do not have that. Maybe I should use this on an ext4 USB if I ever get one to use. Maybe soon. Also, I thought debugfs was like no / start for relative to outside of debugfs pwd and inside debugfs /something... meant inside debugfs file system. I thought many said do not ever use this on a mounted file system. I guess if mounted as debugfs it is safe enough. Your tests are ground breaking. X E.
 
Old 01-13-2024, 11:22 AM   #22
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,815

Rep: Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491
Quote:
Originally Posted by maybeJosiah View Post
I think I meant like do not use this on your main hardware file system like for example /dev/sda1. Why I do not try it is it is supposedly dangerous for running systems.
Yes, I tested it on /dev/sdc1 which was not mounted while I ran the debugfs command. I only mounted it for running stat to see the results.
If you want to use it on your main OS, you can boot to a live linux (usb stick) and use debugfs there to edit your main file systems on disk.

You don't need to be root or need write access to any fs if you want to see what you asked:
Code:
$ debugfs
debugfs 1.47.0 (5-Feb-2023)
debugfs:  sif -l
Inode fields supported by the set_inode command:
        mode                            unsigned integer
        uid[_hi|_lo]                    unsigned integer
        size[_hi|_lo]                   unsigned integer
        atime[_hi|_lo]                  date/time
        ctime[_hi|_lo]                  date/time
        mtime[_hi|_lo]                  date/time
        dtime                           date/time
        gid[_hi|_lo]                    unsigned integer
        links_count                     unsigned integer
        blocks[_hi|_lo]                 unsigned integer
        flags                           unsigned integer
        version[_hi|_lo]                unsigned integer
        translator                      unsigned integer
        block[12]                       unsigned integer
        block[IND]                      unsigned integer
        block[DIND]                     unsigned integer
        block[TIND]                     unsigned integer
        generation                      unsigned integer
        file_acl[_hi|_lo]               unsigned integer
        faddr                           unsigned integer
        frag                            unsigned integer
        fsize                           unsigned integer
        checksum[_hi|_lo]               unknown
        author                          unsigned integer
        extra_isize                     unsigned integer
        ctime_extra                     unsigned integer
        mtime_extra                     unsigned integer
        atime_extra                     unsigned integer
        crtime[_hi|_lo]                 date/time
        crtime_extra                    unsigned integer
        projid                          unsigned integer
        bmap[]                          set physical->logical block map
debugfs:  help
Available debugfs requests:

show_debugfs_params, params
                         Show debugfs parameters
open_filesys, open       Open a filesystem
close_filesys, close     Close the filesystem
freefrag, e2freefrag     Report free space fragmentation
feature, features        Set/print superblock features
dirty_filesys, dirty     Mark the filesystem as dirty
init_filesys             Initialize a filesystem (DESTROYS DATA)
show_super_stats, stats  Show superblock statistics
ncheck                   Do inode->name translation
icheck                   Do block->inode translation
change_root_directory, chroot
                         Change root directory
change_working_directory, cd
                         Change working directory
list_directory, ls       List directory
show_inode_info, stat    Show inode information 
dump_extents, extents, ex
                         Dump extents information 
blocks                   Dump blocks used by an inode 
filefrag                 Report fragmentation information for an inode
link, ln                 Create directory link
unlink                   Delete a directory link
mkdir                    Create a directory
rmdir                    Remove a directory
rm                       Remove a file (unlink and kill_file, if appropriate)
kill_file                Deallocate an inode and its blocks
copy_inode               Copy the inode structure
clri                     Clear an inode's contents
freei                    Clear an inode's in-use flag
seti                     Set an inode's in-use flag
testi                    Test an inode's in-use flag
freeb                    Clear a block's in-use flag
setb                     Set a block's in-use flag
testb                    Test a block's in-use flag
modify_inode, mi         Modify an inode by structure
find_free_block, ffb     Find free block(s)
find_free_inode, ffi     Find free inode(s)
print_working_directory, pwd
                         Print current working directory
expand_dir, expand       Expand directory
mknod                    Create a special file
list_deleted_inodes, lsdel
                         List deleted inodes
undelete, undel          Undelete file
write                    Copy a file from your native filesystem
dump_inode, dump         Dump an inode out to a file
cat                      Dump an inode out to stdout
lcd                      Change the current directory on your native filesystem
rdump                    Recursively dump a directory to the native filesystem
set_super_value, ssv     Set superblock value
set_inode_field, sif     Set inode field
set_block_group, set_bg  Set block group descriptor field
logdump                  Dump the contents of the journal
htree_dump, htree        Dump a hash-indexed directory
dx_hash, hash            Calculate the directory hash of a filename
dirsearch                Search a directory for a particular filename
bmap                     Calculate the logical->physical block mapping for an inode
fallocate                Allocate uninitialized blocks to an inode
punch, truncate          Punch (or truncate) blocks from an inode by deallocating them
symlink                  Create a symbolic link
imap                     Calculate the location of an inode
dump_unused              Dump unused blocks
set_current_time         Set current time to use when setting filesystem fields
supported_features       Print features supported by this version of e2fsprogs
dump_mmp                 Dump MMP information
set_mmp_value, smmp      Set MMP value
extent_open, eo          Open inode for extent manipulation
zap_block, zap           Zap block: fill with 0, pattern, flip bits etc.
block_dump, bdump, bd    Dump contents of a block
ea_list                  List extended attributes of an inode
ea_get                   Get an extended attribute of an inode
ea_set                   Set an extended attribute of an inode
ea_rm                    Remove an extended attribute of an inode
list_quota, lq           List quota
get_quota, gq            Get quota
inode_dump, idump, id    Dump the inode structure in hex
journal_open, jo         Open the journal
journal_close, jc        Close the journal
journal_write, jw        Write a transaction to the journal
journal_run, jr          Recover the journal
help                     Display info on command or topic.
list_requests, lr, ?     List available commands.
quit, q                  Leave the subsystem.
Quote:
To sum up what I found, there is a kernel option that must be enabled to have debugfs work. CONFIG_DEBUG_FS=y
No. It is a totally different thing. It is a virtual file system used by kernel developers to debug the kernel.

Last edited by Petri Kaukasoina; 01-13-2024 at 11:24 AM.
 
1 members found this post helpful.
Old 01-13-2024, 11:48 AM   #23
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
Anyway, thanks and here is an example of 4 timestamps I try to set from.
Quote:
2023-12-19 20:09:04.890596247 -0500
2024-01-04 11:16:13.502644619 -0500
2024-01-04 11:16:13.506644619 -0500
2024-01-04 11:16:13.502644619 -0500
All needed is that format. In set_inode_field (sif) I saw it could be date/time. Anyway, now just how to set based on these. Also, I think I really should thank you somehow if I can more than just saying it, so how about you get to use like my timestamp recorder and restorer if it ever gets done? I will do like my own research on how to convert too. X E.
 
Old 01-13-2024, 11:54 AM   #24
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
#! /bin/bash
# Store the time format in a variable
time_format="2023-12-19 20:09:04.890596247 -0500"

# Convert the time format to system time with second precision
system_time=$(date -d "$time_format" +"%s")

# Convert the nanoseconds to nanoseconds times 4
nanoseconds=$(date -d "$time_format" +"%N")
nanoseconds_times_4=$((nanoseconds * 4))

# Print the converted values
echo "System Time: $system_time"
echo "Nanoseconds Times 4: $nanoseconds_times_4"
#X E
This seem correct?
 
Old 01-13-2024, 12:13 PM   #25
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
I realize now that I will need to have setting be all debugfs usage and I am unsure how if there is a way to get if a file or folder exists in debugfs because I do not want to screw with non-existent things. I have code that should set it all but can't check existence and may need that. If I use this for full backup, would nothing change if I use a bootable USB, record all timestamps on computer main to a file, then rsync whole main to a USB not using main except as to get from? I realize now there IS ls so I may use that. X E.

Last edited by maybeJosiah; 01-13-2024 at 12:29 PM. Reason: more info maybe
 
Old 01-13-2024, 12:14 PM   #26
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,815

Rep: Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491
Look how I did it in post #18.
Code:
2025-01-01 12:34:56.123456789 UTC
YYYY-MM-DD HH:MM:SS.nanosecs  UTC
I put to ctime:
Code:
20250101123456
YYYYMMDDHHMMSS
You could use:
Code:
system_time=$(TZ=UTC date -d "$time_format" +%Y%m%d%H%M%S)

Last edited by Petri Kaukasoina; 01-13-2024 at 12:20 PM.
 
1 members found this post helpful.
Old 01-13-2024, 12:34 PM   #27
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,815

Rep: Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491
Quote:
Originally Posted by maybeJosiah View Post
Code:
2023-12-19 20:09:04.890596247 -0500
2024-01-04 11:16:13.502644619 -0500
2024-01-04 11:16:13.506644619 -0500
2024-01-04 11:16:13.502644619 -0500
Code:
root@linux:~ # cat commands                                                    
sif /home/kaukasoi/.bash_history atime 20231220010904
sif /home/kaukasoi/.bash_history atime_extra 3562384988
sif /home/kaukasoi/.bash_history mtime 20240104161613
sif /home/kaukasoi/.bash_history mtime_extra 2010578476
sif /home/kaukasoi/.bash_history ctime 20240104161613
sif /home/kaukasoi/.bash_history ctime_extra 2026578476
root@linux:~ # debugfs -w -f commands /dev/sdc1                                
debugfs 1.43.1 (08-Jun-2016)
debugfs: sif /home/kaukasoi/.bash_history atime 20231220010904
debugfs: sif /home/kaukasoi/.bash_history atime_extra 3562384988
debugfs: sif /home/kaukasoi/.bash_history mtime 20240104161613
debugfs: sif /home/kaukasoi/.bash_history mtime_extra 2010578476
debugfs: sif /home/kaukasoi/.bash_history ctime 20240104161613
debugfs: sif /home/kaukasoi/.bash_history ctime_extra 2026578476
root@linux:~ # mount /disk3;TZ=EST stat /disk3/home/kaukasoi/.bash_history;umount /disk3
  File: '/disk3/home/kaukasoi/.bash_history'
  Size: 6440            Blocks: 16         IO Block: 4096   regular file
Device: 821h/2081d      Inode: 17956870    Links: 1
Access: (0600/-rw-------)  Uid: ( 1000/kaukasoi)   Gid: (  100/   users)
Access: 2023-12-19 20:09:04.890596247 -0500
Modify: 2024-01-04 11:16:13.502644619 -0500
Change: 2024-01-04 11:16:13.506644619 -0500
 Birth: -
root@linux:~ #
I didn't change crtime, because this file system is from year 2012 and crtime is a newer addition.

Last edited by Petri Kaukasoina; 01-13-2024 at 12:39 PM.
 
1 members found this post helpful.
Old 01-13-2024, 12:44 PM   #28
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
Quote:
#!/bin/bash

# Path to the device file
device="/dev/sda1"

# File to check for existence
result="/path/to/file"

# Run the debugfs command to check if the file exists
output=$(debugfs -R "stat "$result"" "$device" 2>/dev/null)

# Check the output for the existence of the file
if [[ $output =~ "File not found" ]]; then
exists=false
else
exists=true
fi

# Print the result
echo "File exists: $exists"
#X E.
For maybe getting if file exists. I got that from zzzcode.ai so unsure. Looks like created, accessed, modified, changed times. Thank you. I think that because crtime should be like constant. Just to be sure though, can you run it with different times for mtime and ctime? Note: never /dev/sda1. X E.

Last edited by maybeJosiah; 01-13-2024 at 12:45 PM. Reason: X E.
 
Old 01-13-2024, 12:45 PM   #29
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,815

Rep: Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491
Quote:
Originally Posted by maybeJosiah View Post
I realize now that I will need to have setting be all debugfs usage and I am unsure how if there is a way to get if a file or folder exists in debugfs because I do not want to screw with non-existent things. I have code that should set it all but can't check existence and may need that.
No problem, you get a message:
Code:
root@linux:~ # debugfs -w  /dev/sdc1
debugfs 1.43.1 (08-Jun-2016)
debugfs:  sif /home/kaukasoi/non_existant_file atime 20231220010904
/home/kaukasoi/non_existant_file: File not found by ext2_lookup 
debugfs:  sif /home/kaukasoi/.bash_history atime 20231220010904
debugfs:  q
root@linux:~ #
 
1 members found this post helpful.
Old 01-13-2024, 12:48 PM   #30
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
So I get a message. Does it screw with your system? Seemingly not but want to be sure. X E.
 
  


Reply

Tags
bash, timestamp, ubuntu



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
Google search will log and search for later. Including site tracking *including site check, copyrights,... and removing sites Xeratul General 7 11-01-2023 05:17 PM
Logi Sales Manager on Ncurses (invoice, invoicing, orders, order, sale order, sales order...)? Xeratul Linux - Software 0 03-25-2017 02:45 PM
How to restore deleted inodes using debugfs willsam100 Linux - General 7 08-20-2011 05:33 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 11:50 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