Skip to Content
Linux Shell Scripting Cookbook - Third Edition
book

Linux Shell Scripting Cookbook - Third Edition

by Clif Flynt, Sarath Lakshman, Shantanu Tushar
May 2017
Beginner
552 pages
28h 47m
English
Packt Publishing
Content preview from Linux Shell Scripting Cookbook - Third Edition

How to do it...

To create a 1 GB ext4 filesystem in a file, follow these steps:

  1. Use dd to create a 1 GB file:
        $ dd if=/dev/zero of=loobackfile.img bs=1G count=1
        1024+0 records in
        1024+0 records out
        1073741824 bytes (1.1 GB) copied, 37.3155 s, 28.8 MB/s

 The size of the created file exceeds 1 GB because the hard disk is a block device, and hence, storage must be allocated by integral multiples of blocks size.

  1. Format the 1 GB file to ext4 using the mkfs command:
        $ mkfs.ext4 loopbackfile.img
  1. Check the file type with the file command:
        $ file loobackfile.img
        loobackfile.img: Linux rev 1.0 ext4 filesystem data,   
        UUID=c9d56c42-   
        f8e6-4cbd-aeab-369d5056660a (extents) (large files) (huge files)
  1. Create a mount point and mount the loopback ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Linux Shell Scripting - Second Edition

Mastering Linux Shell Scripting - Second Edition

Mokhtar Ebrahim, Andrew Mallett

Publisher Resources

ISBN: 9781785881985