User:Andy Crowd/sandbox/Create a test ground

From ArchWiki
Jump to navigation Jump to search

Create a test ground

The test ground is a place where you can test things without cause a damage to the environment.

Folder and Files - auto create - test ground

Creating a bunch of folders and files with a random content.

cd $Dest
for CreatingFolders in {0..20};   do
 mkdir "${Dest}/${tmpFolder}${CreatingFolders}" -p
    for CreatingFiles in {A..Z}; do
#echo "${Dest}/${tmpFolder}${CreatingFolders}/${CreatingFiles}"
 dd if=/dev/urandom of="${Dest}/${tmpFolder}${CreatingFolders}/${CreatingFiles} ZZ PP.tmp" bs=$RANDOM count=1
find /tmp/AA >> /tmp/AA/aa.txt
sed -i 's/tmp$/tmp|/g' /tmp/AA/aa.txt

Damage a file for integrity tests

Make a copy/backup of a known not corrupted file and use a hex-editor such as a hexedit to make some changes in a copied/backup file.

Partition in a file

Linux can also make a lot of actions on files as if it were a system devices.

Create an empty file filled with zeros by dd of size 98M.

$ dd if=/dev/zero of=./empty-test-file.tmp bs=1024 count=100000

Other input devices that can be used for tests are /dev/random and /dev/urandom. As they are doing what their names tells, generates a randomized data.

This will create an ext4 partition inside a file by formating it with the mkfs command.

$ mkfs.ext4 ./empty-test-file.tmp
mke2fs 1.42.11 (09-Jul-2014)
Discarding device blocks: done                            
Creating filesystem with 100000 1k blocks and 25064 inodes
Filesystem UUID: 7cd56407-7e9e-41e3-8d83-3b56da7344ff
Superblock backups stored on blocks: 
	8193, 24577, 40961, 57345, 73729

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

Fake environment

fakeroot - faking root rights to allow for external application create files with correct root permissions.

For some of advanced tasks e.g. test a Live CD or the operative system, recommended to use a virtual solutions such a vmware or a virtualbox.