Thursday, November 17, 2016

Creating a disk image and mount it using linux



#Using dd commands
dd if=/dev/zero of=dsk.img bs=100M count=1

#make terminal to super user privileges
sudo su

#attaching a virtual device
losetup /dev/loop1 dsk.img

#making the file structure
mkfs -t vfat /dev/loop1

#making a folder to mount
mkdir /mnt/f1

#mounting the image
mount -t vfat /dev/loop1 /mnt/f1/

#open nano editor
nano /mnt/f1/abc.txt

#unmount device
unmount /mnt/f1

#search using grep. if text saved in the device it'll print matches
grep "SCS2016" dsk.img