Tuesday, December 24, 2013

Prepare sparse raw image with ntfs

Create sparse file
dd if=/dev/zero of=test.img bs=1 count=0 seek=1995G
0+0 records in
0+0 records out
0 bytes (0 B) copied, 1.1611e-05 s, 0.0 kB/s
Create partition table
echo 'n
p
1


t
7
w
' | /sbin/fdisk -u test.img
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x2cddb521.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): Partition number (1-4, default 1): First sector (2048-4183818239, default 2048): Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4183818239, default 4183818239): Using default value 4183818239

Command (m for help): Selected partition 1
Hex code (type L to list codes): Changed system type of partition 1 to 7 (HPFS/NTFS/exFAT)

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

Syncing disks.
Format first partition
/sbin/kpartx -a test.img
/usr/sbin/mkntfs -c4096 -s512 -p63 -H255 -S63 -Ff --label Drive_E /dev/mapper/loop0p1
/sbin/kpartx -d test.img
loop deleted : /dev/loop0
Mount/umount first partition
/sbin/kpartx -a test.img
mkdir exposed
/usr/bin/ntfs-3g -o rw,noatime,force,entry_timeout=60000,negative_timeout=60000,attr_timeout=60000,ac_attr_timeout=60000 /dev/mapper/loop0p1 exposed
...
umount exposed
/sbin/kpartx -d test.img
loop deleted : /dev/loop0

No comments:

Post a Comment