ext3


How do I create a file with a specific inode number?


How can I create a file in ext3 filesystem
with a specific inode number?
(ex: I want to create a file with inode-number = 12253)
I don't think there's any programmatic way to request a specific inode number when creating a file from userspace. Other than being visible in stat() results, inode numbers have no significance in userspace; they're part of the filesystem's internal bookkeeping data, just like the block numbers where the file contents are allocated.
You could probably use debugfs to "change" an existing file's inode number, by copying the contents of one inode to another, then updating any directory entries to point to the new inode and deallocating the old one. So you could create your file with any inode number, then "change" it to the desired one. This would have to be done with extreme care, however, since mistakes are likely to result in filesystem corruption and data loss. You'd also have to account for the possibility that your desired inode number is already in use by another file.
The inode number is assigned by the system. User code cannot specify it when creating a file.
That's a pretty low number, so chances are it's already in use; if not, you could run a Bash script to create a few thousand files: something like for i in $(seq 1 12000); do touch $i.txt; done. Then find the one you want: find / -inum 12253, and rename it to whatever you want, and put in it what you want. If you don't overwrite the allocated space, in which case a new inode will most likely be created, that should do it. It's a sloppy solution, though, and there must be a better way.

Related Links

Is there any patch available for EXT3 file system to compress?
How do I create a file with a specific inode number?
ext4 Specifications?

Categories

HOME
cloud
amazon-ec2
zeromq
plone
graphql
survey
onelogin
facebook-messenger-bot
slick-slider
iggrid
ssl-client-authentication
nano-server
kentor-authservices
handsontable
google-apps-marketplace
php-7.1
messages
decomposition
highlight.js
saxon
database-replication
core-text
restful-authentication
smb
shopware
numerical-methods
opentype
nat
media-queries
copying
uiswipegesturerecognizer
mozilla
language-concepts
mapdb
libraries
event-driven
sqlite2
webdriver-manager
elmah
filepicker
apache-fop
python-webbrowser
csound
magma
pg-dump
jspdf-autotable
yt-project
websitepanel
apachebench
nessus
php-internals
historian
srand
separator
xna-4.0
collapse
spidermonkey
emailrelay
drawbitmap
method-parameters
mmc
apache-commons-net
bigbluebutton
clicktag
relocation
issuu
onactivityresult
concurrent-collections
oracle-warehouse-builder
terminal-services
page-layout
ms-project-server-2010
gridfs
quartz-graphics
jplaton
shellexecute
pygit2
drools-planner
distutils
cascalog
appconkit
regsvr32
qtkit
ohm
hgsubversion
libc++
window-management
locationlistener
ecl
winbugs14
project-hosting
genealogy
post-build

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App