How to create a virtual disk using dd? [SOLVED]

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

How to create a virtual disk using dd? [SOLVED]

#1 Post by Argolance »

Bonjour,
I explored the net to find out how to create a virtual disk using command lines.
Here is the result of my research and what I am doing:

Code: Select all

root@puppypc28983 ~ 
# dd if=/dev/zero of=$HOME/virtual_disk/DISK.img bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 1,31024 s, 410 MB/s
root@puppypc28983 ~ 
# losetup /dev/loop3 $HOME/virtual_disk/DISK.img
losetup: /dev/loop3
root@puppypc28983 ~ 
# fdisk /dev/loop3
Welcome to fdisk (util-linux 2.21.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): o
Building a new DOS disklabel with disk identifier 0x1ad8c107.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-1048575, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1048575, default 1048575): 
Using default value 1048575
Partition 1 of type Linux and of size 511 MiB is set

Command (m for help): a
Partition number (1-4): 1

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
root@puppypc28983 ~ 
#
At this point, what's wrong?

Thanks.
Cordialement.
Last edited by Argolance on Wed 23 Jan 2019, 14:43, edited 1 time in total.

williams2
Posts: 337
Joined: Fri 14 Dec 2018, 22:18

#2 Post by williams2 »

Code: Select all

dd if=/dev/zero of=/mnt/home/PUP1/v.3fs bs=1M count=512
mkfs.ext3 /mnt/home/PUP1/v.3fs
mount -o loop /mnt/home/PUP1/v.3fs /mnt/data/

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#3 Post by Argolance »

Thank you for replying.
These are the basic commands I already tried and they indeed works fine with vfat and extX file systems but not with ntfs (don't ask me why I need such a partition :o : I can only say that the image *.img file of this virtual disk is later intended to be dumped to an USB stick and then enlarged to the size of that drive).

Code: Select all

root@puppypc28983 ~ 
# mkfs -t ntfs /mnt/home/virtual_disk/2PVD.img
/mnt/home/virtual_disk/2PVD.img is not a block device.
Refusing to make a filesystem here!
It is the reason why I didn't use the given basic commands and tried to find another way to do the job.
Last edited by Argolance on Sat 26 Jan 2019, 17:55, edited 1 time in total.

foxpup
Posts: 1132
Joined: Fri 29 Jul 2016, 21:08

#4 Post by foxpup »

I found this here, on mkfs.ntfs:
-F, --force
Force mkntfs to run, even if the specified device is not a block special device, or appears to be mounted

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#5 Post by musher0 »

Hello Argolance.

You should be sent to Linux Supreme Court for suggesting that a virtual disk be
formatted in ntfs. :lol:

In any case, you have to use the ntfs-3g exec in /bin to format your contraption :lol:,
not mkfs.

Finally, the killer question:: why ntfs on a Puppy "project"?

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#6 Post by Argolance »

foxpup wrote:I found this here, on mkfs.ntfs:
-F, --force
Force mkntfs to run, even if the specified device is not a block special device, or appears to be mounted
Tanks, it works! So I no longer need to go through:

Code: Select all

losetup: /dev/loop3 

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#7 Post by Argolance »


Post Reply