Linux Tutorials

Tips on how to Create a Digital HardDisk Quantity Utilizing a File in Linux

SEOClerks

Digital Exhausting Disk (VHD) is a disk picture file format which represents a digital exhausting disk drive, able to storing the entire contents of a bodily exhausting drive. It’s a container file that acts just like a bodily exhausting drive. The disk picture replicates an present exhausting drive and contains all information and structural options.

Identical to a bodily exhausting drive, a VHD can incorporates a file system, and you need to use it to retailer and run an working system, purposes, in addition to retailer information. One of many typical makes use of of VHDs in VirtualBox Digital Machines (VMs) to retailer working programs and software, and information.

On this article, we’ll reveal find out how to create a digital exhausting disk quantity utilizing a file in Linux. This information is helpful for creating VHDs for testing functions in your IT atmosphere. For the aim of this information, we’ll create a VHD quantity of measurement 1GB, and format it with EXT4 file system kind.

Create a New Picture to Maintain Digital Drive Quantity

There are variety of methods you are able to do this, however essentially the most simplest way is utilizing the next dd command. On this instance, we can be making a VHD quantity of measurement 1GB picture.

$ sudo dd if=/dev/zero of=VHD.img bs=1M rely=1200

The place:

if=/dev/zero: enter file to offer a personality stream for initializing information storage
of=VHD.img: picture file to be created as storage quantity
bs=1M: learn and write as much as 1M at a time
rely=1200: copy solely 1200M (1GB) enter blocks
Create VHD Image File in LinuxCreate VHD Image File in Linux

Create VHD Picture File in Linux

Subsequent, we have to format the EXT4 file system kind within the VHD picture file with the mkfs utility. Reply y, when prompted that /media/VHD.img will not be a block particular gadget as proven within the following screenshot.

$ sudo mkfs -t ext4 /media/VHD.img

Format VHD ImageFormat VHD Image

Format VHD Picture

As a way to entry the VHD quantity, we have to mount to a listing (mount level). Run these instructions to create the mount level and mount the VHD quantity, respectively. The -o is used to specify choices for mounting, right here, the choice loop signifies the gadget node beneath the /dev/ listing.

$ sudo mkdir /mnt/VHD/
$ sudo mount -t auto -o loop /media/VHD.img /mnt/VHD/

Be aware: The VHD filesystem will solely stay mounted till the subsequent reboot, to mount it at system boot, add this entry within the /and so forth/fstab file.

/media/VHD.img /mnt/VHD/ ext4 defaults zero zero

Now you’ll be able to confirm the newly created VHD filesystem with mount level utilizing the next df command.

$ df -hT

Check VHD FilesystemCheck VHD Filesystem

Examine VHD Filesystem

Eradicating Digital Drive Quantity

For those who don’t want the VHD quantity anymore, run the next instructions to unmount the VHD filesystem, then delete the picture file:

$ sudo umount /mnt/VHD/
$ sudo rm /media/VHD.img

Utilizing the identical concept, you may as well create a swap space/house utilizing a file in Linux.

That’s all! On this information, now we have demonstrated find out how to create a digital exhausting disk quantity utilizing a file in Linux. You probably have any ideas to share or inquiries to ask, attain us by way of the remark kind under.

Source link

Related Articles

Leave a Reply

Back to top button