Skip to content

Latest commit

 

History

History
192 lines (156 loc) · 6.32 KB

filesystem.md

File metadata and controls

192 lines (156 loc) · 6.32 KB

metadata

# modify creation time
inode_number=
debugfs -w -R "set_inode_field $inode_number crtime 200001010101.11" /dev/sdb1

memory-mapped temporary files

shm_dir=$(mktemp -p /dev/shm/)
dd if=/dev/zero of="$shm_dir" bs=500M count=1
# xref. `top` - used memory increased by 500M
# ref. https://superuser.com/questions/45342/when-should-i-use-dev-shm-and-when-should-i-use-tmp

mount -t tmpfs -o size=500M tmpfs /mnt/ramdisk
# ref. https://unix.stackexchange.com/questions/188536/how-to-make-a-temporary-file-in-ram

mknod -m 660 /dev/ramdisk b 1 1
chown root:disk /dev/ramdisk
dd if=/dev/zero of=/dev/ramdisk bs=1k count=4k
/sbin/mkfs -t ext2 -m 0 /dev/ramdisk 4096
mount -t ext2 /dev/ramdisk /mnt/ramdisk
# ref. http://surfer.nmr.mgh.harvard.edu/partition/ramdisk.html

testing graceful degradation on constrained environment

mount -t tmpfs -o size=10M,nr_inodes=10,mode=700 tmpfs /mnt/low_nr_inodes_disk

partitioning

sudo parted /dev/hdz
# print
# mkpart TYPE linux-swap START END

# || On error: unable to satisfy all constraints
sudo fdisk /dev/hdz
# || GPT
sudo gdisk /dev/hdz
# p => print
# n => new
# t => change partition type
# w => write changes
sudo mkfs -t vfat /dev/hdz1
# || NTFS, fast format
sudo mkntfs -f /dev/hdz1 --label foo

mkswap /dev/hdz2
swapon /dev/hdz2

# Validation:
cat /proc/swaps
# Filename  Type      Size    Used Priority
# /dev/hdz2 partition 2047996 0-2
cat /etc/fstab
# /dev/hdz2 swap swap defaults 0 0

Format/Flash USB disk

cfdisk -z /dev/sdX

BIN/CUE

# Conversion
bin2iso input.cue
vcdgear -cue2raw input.cue output.iso
# From bin to iso+wav
bchunk -w input.bin input.cue output

CD-ROM

# Conversion
iat -i input.img --iso -o output.iso

ISO

# Make
mkisofs -r -N -allow-leading-dots -d -J -T -o target.iso target

# Read
# For wine: Configure "$target-dir" in: winecfg > Drives > d: (Advanced > Type > CD-ROM)
mount -o loop -t iso9660 foo.iso "$target_dir"
# || Setup loop device
udisksctl loop-setup -r -f foo.iso

# Read ISO9660/HFS hybrid
mount -o loop -t hfs foo.iso

# Read files deleted in multi-session CD-ROM
# Identification: ksv ~/opt/isolyzer/testFiles/multisession.iso ~/opt/kaitai_struct/formats/filesystem/iso9660.ksy
mount /dev/cdrom /mnt/cdrom -t iso9660 -o session=0

# Extract files
bsdtar -C DESTINATION -xf foo.iso ISO_DIR
xorriso -osirrox on -indev foo.iso -extract ISO_DIR DESTINATION
isoinfo -J -x /ISO_DIR/FILE -i foo.iso > DESTINATION/FILE
7z x -oDESTINATION -i\!ISO_DIR foo.iso

ECM

ecm d input.img.ecm output.img

VHD